88
99# ###############################################################################
1010# Create a stage for building the application.
11- ARG GO_VERSION=1.23.0
11+ ARG GO_VERSION=1.23.4
1212FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} AS build
1313WORKDIR /src
1414
@@ -17,9 +17,9 @@ WORKDIR /src
1717# Leverage bind mounts to go.sum and go.mod to avoid having to copy them into
1818# the container.
1919RUN --mount=type=cache,target=/go/pkg/mod/ \
20- --mount=type=bind,source=go.sum,target=go.sum \
21- --mount=type=bind,source=go.mod,target=go.mod \
22- go mod download -x
20+ --mount=type=bind,source=go.sum,target=go.sum \
21+ --mount=type=bind,source=go.mod,target=go.mod \
22+ go mod download -x
2323
2424# This is the architecture you're building for, which is passed in by the builder.
2525# Placing it here allows the previous steps to be cached across architectures.
@@ -30,8 +30,8 @@ ARG TARGETARCH
3030# Leverage a bind mount to the current directory to avoid having to copy the
3131# source code into the container.
3232RUN --mount=type=cache,target=/go/pkg/mod/ \
33- --mount=type=bind,target=. \
34- CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o /bin/server .
33+ --mount=type=bind,target=. \
34+ CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o /bin/server .
3535
3636# ###############################################################################
3737# Create a new stage for running the application that contains the minimal
@@ -49,23 +49,23 @@ FROM alpine:latest AS final
4949# Install any runtime dependencies that are needed to run your application.
5050# Leverage a cache mount to /var/cache/apk/ to speed up subsequent builds.
5151RUN --mount=type=cache,target=/var/cache/apk \
52- apk --update add \
53- ca-certificates \
54- tzdata \
55- && \
56- update-ca-certificates
52+ apk --update add \
53+ ca-certificates \
54+ tzdata \
55+ && \
56+ update-ca-certificates
5757
5858# Create a non-privileged user that the app will run under.
5959# See https://docs.docker.com/go/dockerfile-user-best-practices/
6060ARG UID=10001
6161RUN adduser \
62- --disabled-password \
63- --gecos "" \
64- --home "/nonexistent" \
65- --shell "/sbin/nologin" \
66- --no-create-home \
67- --uid "${UID}" \
68- appuser
62+ --disabled-password \
63+ --gecos "" \
64+ --home "/nonexistent" \
65+ --shell "/sbin/nologin" \
66+ --no-create-home \
67+ --uid "${UID}" \
68+ appuser
6969USER appuser
7070
7171# Copy the executable from the "build" stage.
0 commit comments