github.com/eth-easl/loader@v0.0.0-20230908084258-8a37e1d94279/Dockerfile.trace (about) 1 # syntax=docker/dockerfile:1.2.x 2 3 # Stage 0: Build # 4 # Use the official Golang image to create a build artifact. 5 # This is based on Debian and sets the GOPATH to /go. 6 FROM golang:1.19 as BUILDER 7 8 # Create and change to the app directory. 9 WORKDIR /app 10 11 # Retrieve application dependencies using go modules. 12 # Allows container builds to reuse downloaded dependencies. 13 COPY go.* ./ 14 RUN go mod download 15 16 # Copy local code to the container image. 17 COPY . ./ 18 19 # Build the binary. 20 WORKDIR /app/server/trace-func-go 21 22 # -mod=readonly: ensures immutable go.mod and go.sum in container builds. 23 # CGO_ENABLED=1: uses common libraries found on most major OS distributions. 24 # GOARCH=amd64 GOGCCFLAGS=-m64: specifies x86, 64-bit GCC. 25 RUN CGO_ENABLED=1 GOARCH=amd64 GOGCCFLAGS=-m64 GOOS=linux go build -mod=readonly -v -o server 26 27 # Stage 1: Run # 28 FROM debian:stable-slim 29 30 ARG FUNC_TYPE 31 ENV FUNC_TYPE_ENV=${FUNC_TYPE} 32 ARG FUNC_PORT 33 ENV FUNC_PORT_ENV=${FUNC_PORT} 34 35 # Copy the binary to the production image from the BUILDER stage. 36 COPY --from=BUILDER /app/server/trace-func-go/server /server 37 38 # Run the web service on container startup. 39 CMD /server ${FUNC_PORT_ENV} ${FUNC_TYPE_ENV}