-
Notifications
You must be signed in to change notification settings - Fork 14
/
Dockerfile.wimpy
33 lines (24 loc) · 949 Bytes
/
Dockerfile.wimpy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# syntax=docker/dockerfile:1.2.x
# Stage 0: Build #
# Use the official Golang image to create a build artifact.
# This is based on Debian and sets the GOPATH to /go.
FROM golang:1.19 as BUILDER
# Create and change to the app directory.
WORKDIR /app
# Retrieve application dependencies using go modules.
# Allows container builds to reuse downloaded dependencies.
COPY go.* ./
RUN go mod download
# Copy local code to the container image.
COPY . ./
# Build the binary.
WORKDIR /app/server/wimpy
# -mod=readonly: ensures immutable go.mod and go.sum in container builds.
# CGO_ENABLED=0: avoid using common libraries are found on most major OS distributions.
RUN CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o server
# Stage 1: Run #
FROM debian:stable-slim
# Copy the binary to the production image from the BUILDER stage.
COPY --from=BUILDER /app/server/wimpy/server /server
# Run the web service on container startup.
CMD ["/server"]