github.com/eth-easl/loader@v0.0.0-20230908084258-8a37e1d94279/Dockerfile.wimpy (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/wimpy
    21  
    22  # -mod=readonly: ensures immutable go.mod and go.sum in container builds.
    23  # CGO_ENABLED=0: avoid using common libraries are found on most major OS distributions.
    24  RUN CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o server
    25  
    26  # Stage 1: Run #
    27  FROM debian:stable-slim
    28  
    29  # Copy the binary to the production image from the BUILDER stage.
    30  COPY --from=BUILDER /app/server/wimpy/server /server
    31  
    32  # Run the web service on container startup.
    33  CMD ["/server"]