Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various improvements to Dockerfiles #10088

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions modules/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM alpine:3.19 as user
FROM alpine:3.21 AS user

ENV USER=nonroot
ENV UID=10001
Expand All @@ -27,7 +27,7 @@ RUN adduser \
--uid "${UID}" \
"${USER}"

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

ARG TARGETARCH
ARG TARGETOS
Expand Down Expand Up @@ -58,7 +58,7 @@ RUN echo ${VERSION}
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 .

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

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

Expand Down
4 changes: 2 additions & 2 deletions modules/api/dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

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

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

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

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

# Copy air binary
COPY --from=AIR $GOPATH/bin/air $GOPATH/bin/air
Expand Down
6 changes: 3 additions & 3 deletions modules/auth/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM alpine:3.19 as user
FROM alpine:3.21 AS user

ENV USER=nonroot
ENV UID=10001
Expand All @@ -27,7 +27,7 @@ RUN adduser \
--uid "${UID}" \
"${USER}"

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

ARG TARGETARCH
ARG TARGETOS
Expand Down Expand Up @@ -58,7 +58,7 @@ RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -ldfl

# Scratch can be used as the base image because the backend is compiled to include all
# its dependencies.
FROM scratch as final
FROM scratch AS final
ARG TARGETARCH
ARG TARGETOS

Expand Down
4 changes: 2 additions & 2 deletions modules/auth/dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

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

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

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

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

# Copy air binary
COPY --from=AIR $GOPATH/bin/air $GOPATH/bin/air
Expand Down
6 changes: 3 additions & 3 deletions modules/metrics-scraper/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM alpine:3.19 as user
FROM alpine:3.21 AS user

ENV USER=nonroot
ENV UID=10001
Expand All @@ -27,7 +27,7 @@ RUN adduser \
--uid "${UID}" \
"${USER}"

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

ARG TARGETARCH
ARG TARGETOS
Expand All @@ -52,7 +52,7 @@ COPY metrics-scraper/main.go ./
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 .

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

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

Expand Down
4 changes: 2 additions & 2 deletions modules/metrics-scraper/dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

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

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

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

# Copy air binary
COPY --from=AIR $GOPATH/bin/air $GOPATH/bin/air
Expand Down
8 changes: 4 additions & 4 deletions modules/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

ARG WEB_BUILDER_ARCH=amd64

FROM alpine:3.19 as user
FROM alpine:3.21 AS user

ENV USER=nonroot
ENV UID=10001
Expand All @@ -29,7 +29,7 @@ RUN adduser \
--uid "${UID}" \
"${USER}"

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

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

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

ARG TARGETARCH
ARG TARGETOS
Expand Down Expand Up @@ -82,7 +82,7 @@ COPY /modules/web/main.go ./
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 .

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

WORKDIR /web

Expand Down
4 changes: 2 additions & 2 deletions modules/web/dev.go.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

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

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

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

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

# Copy air binary
COPY --from=AIR $GOPATH/bin/air $GOPATH/bin/air
Expand Down
2 changes: 1 addition & 1 deletion modules/web/dev.web.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM node:20-alpine3.19
FROM node:20-alpine3.21

WORKDIR /workspace

Expand Down