Skip to content

Commit 571d976

Browse files
committed
feat: switch to scratch-based Docker image with static binary
1 parent 7d7647a commit 571d976

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Dockerfile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM golang:1.26-alpine AS builder
22

3-
RUN apk add --no-cache gcc musl-dev sqlite-dev make
3+
RUN apk add --no-cache gcc musl-dev sqlite-dev make ca-certificates
44

55
WORKDIR /app
66

@@ -9,16 +9,15 @@ COPY go.mod go.sum ./
99
COPY . .
1010

1111
ARG COMMIT_HASH
12-
RUN CGO_ENABLED=1 go build -ldflags="-X github.com/lnliz/faucet.coinbin.org/service.CommitHash=${COMMIT_HASH}" -o app .
12+
RUN CGO_ENABLED=1 go build -ldflags="-X github.com/lnliz/faucet.coinbin.org/service.CommitHash=${COMMIT_HASH} -linkmode external -extldflags '-static'" -o app .
1313

14-
FROM alpine:3.23
14+
FROM scratch
1515

16-
RUN apk add --no-cache sqlite-libs
16+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
17+
COPY --from=builder /app/app /app/app
18+
COPY --from=builder /app/templates /app/templates
19+
COPY --from=builder /app/static /app/static
1720

1821
WORKDIR /app
1922

20-
COPY --from=builder /app/app .
21-
COPY --from=builder /app/templates ./templates
22-
COPY --from=builder /app/static ./static
23-
2423
ENTRYPOINT ["/app/app"]

0 commit comments

Comments
 (0)