Skip to content
Snippets Groups Projects
Unverified Commit 4b4d761b authored by Wolfgang Welz's avatar Wolfgang Welz Committed by GitHub
Browse files

harden docker image (#290)

parent 1befc3a9
Branches
Tags
No related merge requests found
.git
.gitignore
LICENSE
README.md
CHANGELOG.md
images/
docker-compose.yml
tools/
client/
# Database directory # Database directory
mainnetdb/ mainnetdb/
# we need to use alpine to build since cgo is required ############################
FROM golang:1.14-alpine AS build # Build
RUN apk add --no-cache git gcc g++ ############################
# golang:1.14.0-buster
FROM golang@sha256:fc7e7c9c4b0f6d2d5e8611ee73b9d1d3132750108878517bbf988aa772359ae4 AS build
# Ensure ca-certficates are up to date
RUN update-ca-certificates
# Set the current Working Directory inside the container # Set the current Working Directory inside the container
RUN mkdir /goshimmer RUN mkdir /goshimmer
WORKDIR /goshimmer WORKDIR /goshimmer
# Download dependencies # Use Go Modules
COPY go.mod . COPY go.mod .
COPY go.sum . COPY go.sum .
ENV GO111MODULE=on
RUN go mod download RUN go mod download
RUN go mod verify
# Copy everything from the current directory to the PWD(Present Working Directory) inside the container # Copy everything from the current directory to the PWD(Present Working Directory) inside the container
COPY . . COPY . .
# Build # Build the binary
RUN CGO_ENABLED=1 GOOS=linux go build -o /go/bin/goshimmer RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags='-w -s -extldflags "-static"' -a \
FROM alpine:latest -o /go/bin/goshimmer
RUN apk --no-cache add ca-certificates
WORKDIR /app ############################
# Image
############################
# using static nonroot image
# user:group is nonroot:nonroot, uid:gid = 65532:65532
FROM gcr.io/distroless/static@sha256:23aa732bba4c8618c0d97c26a72a32997363d591807b0d4c31b0bbc8a774bddf
VOLUME /app/mainnetdb VOLUME /mainnetdb
EXPOSE 14666/tcp EXPOSE 14666/tcp
EXPOSE 14626/udp EXPOSE 14626/udp
# Copy the Pre-built binary file from the previous stage # Copy the Pre-built binary file from the previous stage
COPY --from=build /go/bin/goshimmer . COPY --from=build /go/bin/goshimmer /run/goshimmer
# Copy the docker config # Copy the default config
COPY config.json config.json COPY config.default.json config.json
ENTRYPOINT ["./goshimmer"] ENTRYPOINT ["/run/goshimmer", "--database.directory=/mainnetdb"]
...@@ -11,7 +11,7 @@ services: ...@@ -11,7 +11,7 @@ services:
container_name: iota_goshimmer container_name: iota_goshimmer
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- ./mainnetdb:/app/mainnetdb:rw - ./mainnetdb/:/mainnetdb/:rw
ports: ports:
- "14666:14666/tcp" - "14666:14666/tcp"
- "14626:14626/udp" - "14626:14626/udp"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment