Skip to content

Commit cc4a847

Browse files
Refactor Dockerfile to use ARG for versions
1 parent 3604966 commit cc4a847

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

Dockerfile

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
# Builder-Stage
2-
FROM golang:1.25.1-alpine3.22 AS builder
1+
# Variables
2+
ARG ALPINE_VERSION=3.22
3+
ARG GOLANG_VERSION=1.25.1
4+
5+
FROM alpine:${ALPINE_VERSION} AS builder
6+
7+
#
8+
# Builder-Stage ++++++++++++++++++++++++++++++++++++++++
9+
#
10+
FROM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} AS builder
311
WORKDIR /app
412

513
COPY go.mod go.sum ./
@@ -8,14 +16,16 @@ RUN go mod download
816
COPY . .
917
RUN go build -o waitfor
1018

11-
# Runner
12-
FROM alpine:3.22.1
19+
#
20+
# Final-Stage ++++++++++++++++++++++++++++++++++++++++
21+
#
22+
FROM alpine:${ALPINE_VERSION}
1323

1424
# Create a non-root user "app" to run the application
15-
RUN addgroup -g 1000 app && adduser -u 1000 -G app -S app
25+
RUN addgroup -g 65532 app && adduser -u 65532 -G app -S app
1626

1727
COPY --from=builder /app/waitfor /usr/local/bin/waitfor
1828

19-
USER 1000:1000
29+
USER 65532:65532
2030

21-
ENTRYPOINT ["waitfor"]
31+
ENTRYPOINT ["waitfor"]

0 commit comments

Comments
 (0)