Skip to content

Commit b0c1c0f

Browse files
authored
style: Various improvements to Dockerfiles (#10088)
* Use latest Alpine version (3.21) for Dockerfiles * Use consistent casing for FROM/AS in Dockerfiles * Use major-only tag for Node in web Dockerfile
1 parent 3226f71 commit b0c1c0f

File tree

9 files changed

+22
-22
lines changed

9 files changed

+22
-22
lines changed

modules/api/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM alpine:3.19 as user
15+
FROM alpine:3.21 AS user
1616

1717
ENV USER=nonroot
1818
ENV UID=10001
@@ -27,7 +27,7 @@ RUN adduser \
2727
--uid "${UID}" \
2828
"${USER}"
2929

30-
FROM golang:1.23-alpine3.19 as builder
30+
FROM golang:1.23-alpine3.21 AS builder
3131

3232
ARG TARGETARCH
3333
ARG TARGETOS
@@ -58,7 +58,7 @@ RUN echo ${VERSION}
5858
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -ldflags="-s -w -X k8s.io/dashboard/api/pkg/environment.Version=${VERSION}" -o dashboard-api .
5959

6060
# Scratch can be used as the base image because the binary is compiled to include all dependencies.
61-
FROM scratch as final
61+
FROM scratch AS final
6262

6363
COPY --from=builder /workspace/api/dashboard-api /dashboard-api
6464

modules/api/dev.Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414

1515
# ! Context expected to be set to "modules" dir !
1616

17-
FROM golang:1.23-alpine3.19 as AIR
17+
FROM golang:1.23-alpine3.21 AS AIR
1818

1919
RUN go install github.com/air-verse/air@latest
2020

21-
FROM golang:1.23-alpine3.19
21+
FROM golang:1.23-alpine3.21
2222

2323
# Copy air binary
2424
COPY --from=AIR $GOPATH/bin/air $GOPATH/bin/air

modules/auth/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM alpine:3.19 as user
15+
FROM alpine:3.21 AS user
1616

1717
ENV USER=nonroot
1818
ENV UID=10001
@@ -27,7 +27,7 @@ RUN adduser \
2727
--uid "${UID}" \
2828
"${USER}"
2929

30-
FROM golang:1.23-alpine3.19 as builder
30+
FROM golang:1.23-alpine3.21 AS builder
3131

3232
ARG TARGETARCH
3333
ARG TARGETOS
@@ -58,7 +58,7 @@ RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -ldfl
5858

5959
# Scratch can be used as the base image because the backend is compiled to include all
6060
# its dependencies.
61-
FROM scratch as final
61+
FROM scratch AS final
6262
ARG TARGETARCH
6363
ARG TARGETOS
6464

modules/auth/dev.Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414

1515
# ! Context expected to be set to "modules" dir !
1616

17-
FROM golang:1.23-alpine3.19 as AIR
17+
FROM golang:1.23-alpine3.21 AS AIR
1818

1919
RUN go install github.com/air-verse/air@latest
2020

21-
FROM golang:1.23-alpine3.19
21+
FROM golang:1.23-alpine3.21
2222

2323
# Copy air binary
2424
COPY --from=AIR $GOPATH/bin/air $GOPATH/bin/air

modules/metrics-scraper/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM alpine:3.19 as user
15+
FROM alpine:3.21 AS user
1616

1717
ENV USER=nonroot
1818
ENV UID=10001
@@ -27,7 +27,7 @@ RUN adduser \
2727
--uid "${UID}" \
2828
"${USER}"
2929

30-
FROM golang:1.23-alpine3.19 as builder
30+
FROM golang:1.23-alpine3.21 AS builder
3131

3232
ARG TARGETARCH
3333
ARG TARGETOS
@@ -52,7 +52,7 @@ COPY metrics-scraper/main.go ./
5252
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -ldflags="-s -w -X k8s.io/dashboard/metrics-scraper/pkg/environment.Version=${VERSION}" -o dashboard-metrics-scraper .
5353

5454
# Scratch can be used as the base image because the binary is compiled to include all dependencies.
55-
FROM scratch as final
55+
FROM scratch AS final
5656

5757
COPY --from=builder /workspace/metrics-scraper/dashboard-metrics-scraper /dashboard-metrics-scraper
5858

modules/metrics-scraper/dev.Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM golang:1.23-alpine3.19 as AIR
15+
FROM golang:1.23-alpine3.21 AS AIR
1616

1717
RUN go install github.com/air-verse/air@latest
1818

19-
FROM golang:1.23-alpine3.19
19+
FROM golang:1.23-alpine3.21
2020

2121
# Copy air binary
2222
COPY --from=AIR $GOPATH/bin/air $GOPATH/bin/air

modules/web/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
ARG WEB_BUILDER_ARCH=amd64
1616

17-
FROM alpine:3.19 as user
17+
FROM alpine:3.21 AS user
1818

1919
ENV USER=nonroot
2020
ENV UID=10001
@@ -29,7 +29,7 @@ RUN adduser \
2929
--uid "${UID}" \
3030
"${USER}"
3131

32-
FROM --platform=linux/${WEB_BUILDER_ARCH} node:20.11.1-alpine3.19 as web-builder
32+
FROM --platform=linux/${WEB_BUILDER_ARCH} node:20-alpine3.21 AS web-builder
3333

3434
RUN apk add --no-cache \
3535
make \
@@ -53,7 +53,7 @@ RUN SKIP_POSTINSTALL=true yarn workspaces focus
5353
# Build prod version of web app
5454
RUN make build-frontend
5555

56-
FROM golang:1.23-alpine3.19 as go-builder
56+
FROM golang:1.23-alpine3.21 AS go-builder
5757

5858
ARG TARGETARCH
5959
ARG TARGETOS
@@ -82,7 +82,7 @@ COPY /modules/web/main.go ./
8282
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -ldflags="-s -w -X k8s.io/dashboard/web/pkg/environment.Version=${VERSION}" -o dashboard-web .
8383

8484
# Scratch can be used as the base image because the binary is compiled to include all dependencies.
85-
FROM scratch as final
85+
FROM scratch AS final
8686

8787
WORKDIR /web
8888

modules/web/dev.go.Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414

1515
# ! Context expected to be set to "modules" dir !
1616

17-
FROM golang:1.23-alpine3.19 as AIR
17+
FROM golang:1.23-alpine3.21 AS AIR
1818

1919
RUN go install github.com/air-verse/air@latest
2020

21-
FROM golang:1.23-alpine3.19
21+
FROM golang:1.23-alpine3.21
2222

2323
# Copy air binary
2424
COPY --from=AIR $GOPATH/bin/air $GOPATH/bin/air

modules/web/dev.web.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM node:20-alpine3.19
15+
FROM node:20-alpine3.21
1616

1717
WORKDIR /workspace
1818

0 commit comments

Comments
 (0)