From 8bc301f0d51c783be7278bf79fe2c239e012cd4b Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Fri, 5 May 2023 17:40:15 -0400 Subject: [PATCH] =?UTF-8?q?Impl=C3=A9menter=20multistage=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seulement passer fichiers source go à build phase Copier contenu/ et static/ à /app/. Copier exécutable et rouler le serveur avec les valeurs par défaut --- Dockerfile | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index ba95cc8..3528baa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,9 +7,24 @@ LABEL repo="https://git.agecem.com/agecem/babillard" WORKDIR /go/src/app -COPY . . +COPY go.mod go.sum main.go ./ -RUN go get -d -v . && \ - go install -v . +ADD cmd/ cmd/ -CMD babillard +RUN CGO_ENABLED=0 go build -a -installsuffix cgo -o babillard . + +# Alpine + +FROM alpine:3.17.2 + +RUN apk update && apk upgrade --no-cache + +WORKDIR /app + +ADD contenu/ contenu/ + +ADD static/ static/ + +COPY --from=build /go/src/app/babillard /usr/bin/babillard + +CMD ["babillard", "server"]