From 31eb097883ee695ceb801f15a3659355496e98bc Mon Sep 17 00:00:00 2001 From: Denys Lemeshko Date: Sat, 14 Oct 2023 01:42:44 +0200 Subject: [PATCH] API Dockerfile review --- dockerfile | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/dockerfile b/dockerfile index bc94152..c9644bb 100644 --- a/dockerfile +++ b/dockerfile @@ -1,8 +1,21 @@ -FROM golang:1.21.1-bullseye +FROM golang:1.21.1 as builder WORKDIR /go/src/ + COPY . . -RUN go build ./cmd/server/ -EXPOSE 8081 +RUN CGO_ENABLED=1 GOOS=linux go build -o ./server --ldflags '-w -s -extldflags "-static"' ./cmd/server/ + +FROM alpine:3.18 as alpine + +RUN apk add -U --no-cache ca-certificates + +FROM scratch as runner + +WORKDIR /app + +COPY --from=builder /go/src/server . +COPY --from=builder /go/src/api/config/config.toml ./api/config/config.toml +COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +EXPOSE 8081 CMD ["./server"]