Skip to content

Commit f17ded2

Browse files
authored
fix: docker file compatibility for go 1.24 (#161)
* fix: docker file compatibility for go 1.24 * fix: remove git dep
1 parent f3595ce commit f17ded2

1 file changed

Lines changed: 12 additions & 19 deletions

File tree

builds/Dockerfile

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
1-
# Builder image
2-
FROM quay.io/centos/centos:stream8 AS builder
1+
# Builder image: Go 1.22 on Alpine
2+
FROM golang:1.24-alpine AS builder
33

4-
USER root
5-
6-
# Dependencies
7-
# change deprecated mirror to vault.centos.org
8-
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
9-
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
10-
11-
# install go and git
12-
RUN dnf install -y golang git
13-
RUN mkdir /build
4+
# Set working directory
145
WORKDIR /build
156

16-
# Golang build
7+
# Cache go modules
178
COPY go.mod .
189
COPY go.sum .
1910
RUN go mod download
11+
12+
# Copy source code
2013
COPY . .
21-
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -a -installsuffix cgo -ldflags '-w -s -extldflags "-static"' -o timelock-worker .
2214

23-
# Final image
24-
FROM quay.io/centos/centos:stream8
25-
COPY --from=builder /build/timelock-worker /app/
26-
WORKDIR /app
15+
# Build statically-linked binary
16+
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags='-w -s -extldflags "-static"' -o timelock-worker .
2717

28-
ENTRYPOINT ["./timelock-worker"]
18+
# Final image: minimal scratch with only the binary
19+
FROM scratch
20+
COPY --from=builder /build/timelock-worker /timelock-worker
21+
ENTRYPOINT ["/timelock-worker"]
2922
CMD ["start"]

0 commit comments

Comments
 (0)