File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
145WORKDIR /build
156
16- # Golang build
7+ # Cache go modules
178COPY go.mod .
189COPY go.sum .
1910RUN go mod download
11+
12+ # Copy source code
2013COPY . .
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" ]
2922CMD ["start" ]
You can’t perform that action at this time.
0 commit comments