From 18bdd9404bf5d339bdcf02d1a190ce3b03015897 Mon Sep 17 00:00:00 2001 From: Dmitry Rubtsov Date: Sun, 15 Dec 2024 17:23:21 +0600 Subject: [PATCH] docker: build improvements --- Dockerfile | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 82b6376..3b0412e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,13 @@ -FROM golang:1.23-alpine as builder +FROM golang:1.23-alpine AS builder -# Setup -RUN mkdir -p /go/src/github.com/mesosphere/traefik-forward-auth -WORKDIR /go/src/github.com/mesosphere/traefik-forward-auth - -# Add libraries RUN apk add --no-cache git -# Copy & build -ADD . /go/src/github.com/mesosphere/traefik-forward-auth/ -RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -installsuffix nocgo -o /traefik-forward-auth github.com/mesosphere/traefik-forward-auth/cmd +COPY . /src +RUN \ + cd /src && \ + CGO_ENABLED=0 go build -ldflags="-s -w" -trimpath -o /traefik-forward-auth ./cmd -# Copy into scratch container FROM scratch COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ -COPY --from=builder /traefik-forward-auth ./ -ENTRYPOINT ["./traefik-forward-auth"] +COPY --from=builder /traefik-forward-auth / +ENTRYPOINT ["/traefik-forward-auth"]