Skip to content

Commit

Permalink
Merge pull request #27 from alphagov/sengi/dockerfile
Browse files Browse the repository at this point in the history
Minor Dockerfile improvements.
  • Loading branch information
sengi authored May 15, 2024
2 parents 8c83ac7 + 9c45929 commit f222731
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@ ARG go_registry=""
ARG go_version=1.22
ARG go_tag_suffix=-alpine

FROM ${go_registry}golang:${go_version}${go_tag_suffix} AS builder
ARG TARGETARCH TARGETOS
ARG GOARCH=$TARGETARCH GOOS=$TARGETOS

FROM --platform=$TARGETPLATFORM ${go_registry}golang:${go_version}${go_tag_suffix} AS builder
ARG TARGETARCH
ARG TARGETOS
ARG GOARCH=$TARGETARCH
ARG GOOS=$TARGETOS
ARG CGO_ENABLED=0
ARG GOEXPERIMENT=loopvar
ARG GOFLAGS="-trimpath"
ARG go_ldflags="-s -w"

WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download

COPY . ./
RUN go build -o /bin/govuk-mirror cmd/main.go
RUN go build -o /bin/govuk-mirror -ldflags="$go_ldflags" cmd/main.go


FROM scratch
FROM --platform=$TARGETPLATFORM scratch
COPY --from=builder /bin/govuk-mirror /bin/govuk-mirror
COPY --from=builder /usr/share/ca-certificates /usr/share/ca-certificates
COPY --from=builder /etc/ssl /etc/ssl
Expand Down

0 comments on commit f222731

Please sign in to comment.