From 97c30b696824c40ef8eee03731d7c96ac113ea0d Mon Sep 17 00:00:00 2001 From: Rafael Soares Date: Thu, 28 Nov 2024 16:05:14 -0300 Subject: [PATCH] update dockerefile for build with go 1.19 and use multistage build --- docker/Dockerfile | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 94b7505..c4f1fb2 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.17.3-alpine3.14 +FROM golang:1.19-alpine3.18 AS builder WORKDIR /app @@ -6,15 +6,16 @@ RUN apk update \ && apk add --virtual build-deps gcc git \ && rm -rf /var/cache/apk/* -RUN addgroup -S golang \ - && adduser -S -G golang golang - COPY . . -RUN go install -v ./cmd/... -RUN chown -R golang /app +RUN --mount=type=cache,target=/go/pkg/mod/ \ + go install -v ./cmd/... + +FROM alpine:3.18 -USER golang +COPY --from=builder /go/bin/ /app/ + +WORKDIR /app EXPOSE 8080 -ENTRYPOINT ["rp-archiver"] +ENTRYPOINT ["./rp-archiver"]