From 327da43928c711f56f5e4e9776c6ee64c7793cde Mon Sep 17 00:00:00 2001 From: Arnaud Delcasse Date: Wed, 8 Oct 2025 11:55:07 +0200 Subject: [PATCH] modif Dockerfile --- Dockerfile | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4f353e0..c80c207 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,27 @@ -FROM golang:1.22-alpine AS builder +FROM golang:alpine as builder -WORKDIR /app +ARG ACCESS_TOKEN_USR="nothing" +ARG ACCESS_TOKEN_PWD="nothing" -# Copy go mod files -COPY go.mod go.sum ./ +RUN apk add --no-cache ca-certificates tzdata git -# Download dependencies -RUN go mod download +WORKDIR / + +# Create a netrc file using the credentials specified using --build-arg +RUN printf "machine git.coopgo.io\n\ + login ${ACCESS_TOKEN_USR}\n\ + password ${ACCESS_TOKEN_PWD}\n"\ + >> ~/.netrc +RUN chmod 600 ~/.netrc -# Copy source code COPY . . -# Build the application -RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main . +RUN go mod download && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /server -FROM alpine:latest - -RUN apk --no-cache add ca-certificates - -WORKDIR /root/ - -# Copy the binary from builder -COPY --from=builder /app/main . +FROM scratch +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo +COPY --from=builder /server / EXPOSE 8080 - -CMD ["./main"] \ No newline at end of file +ENTRYPOINT ["/server"]