diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2025-02-22 14:06:20 -0500 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2025-02-22 14:06:20 -0500 |
commit | 4221780ce53ff7484f6f1958173373dc963e7967 (patch) | |
tree | a9295bcc6161b97d33256b069ea3a5c8fe35e5ff /resources/Dockerfile | |
parent | f36f77472a82d6ebfac153aed6d17f154ae239a6 (diff) |
functional scratch dockerfile
Diffstat (limited to 'resources/Dockerfile')
-rw-r--r-- | resources/Dockerfile | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/resources/Dockerfile b/resources/Dockerfile index 89c1ac3..4a460c3 100644 --- a/resources/Dockerfile +++ b/resources/Dockerfile @@ -1,23 +1,21 @@ -FROM golang:latest AS setup -WORKDIR /app - -COPY go.* ./ -COPY cmd cmd -COPY internal internal +FROM golang:latest AS compile +WORKDIR /build +COPY . . RUN go mod download && go mod verify -RUN CGO_ENABLED=0 GOOS=linux go build -o /application cmd/songlinkr/main.go +# Enable static linking for scratch +RUN CGO_ENABLED=0 GOOS=linux go build -o /application -ldflags="-s -w" main.go FROM alpine:latest AS compressor - RUN apk add --no-cache upx - -COPY --from=setup +COPY --from=compile /application /application +RUN upx --best /application FROM scratch AS package -COPY --from=setup /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ -COPY --from=setup /application /application +# Copy CA certificates +COPY --from=alpine:latest /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=compressor /application /application -CMD ["/application"] +ENTRYPOINT ["/application"] |