11# syntax=docker/dockerfile:1.4
22# Use BuildKit for cache mounts (faster CI: DOCKER_BUILDKIT=1)
3- FROM golang:1.24 -alpine3.23 as go-builder
3+ FROM golang:1.25 -alpine3.23 AS go-builder
44WORKDIR /authorizer
55
66ARG TARGETPLATFORM
@@ -24,14 +24,13 @@ COPY main.go ./
2424COPY cmd/ ./cmd/
2525COPY internal/ ./internal/
2626COPY gqlgen.yml ./
27- RUN apk add --no-cache build-base
2827RUN --mount=type=cache,target=/go/pkg/mod \
2928 --mount=type=cache,target=/root/.cache/go-build \
3029 mkdir -p build/${GOOS}/${GOARCH} && \
3130 go build -trimpath -mod=readonly -tags netgo -ldflags "-w -s -X main.VERSION=$VERSION" -o build/${GOOS}/${GOARCH}/authorizer . && \
3231 chmod 755 build/${GOOS}/${GOARCH}/authorizer
3332
34- FROM alpine:3.23.3 as node-builder
33+ FROM alpine:3.23.3 AS node-builder
3534WORKDIR /authorizer
3635COPY web/app/package*.json web/app/
3736COPY web/dashboard/package*.json web/dashboard/
@@ -45,24 +44,25 @@ COPY web/app web/app
4544COPY web/dashboard web/dashboard
4645RUN cd web/app && npm run build && cd ../dashboard && npm run build
4746
48- FROM alpine:3.23.3
47+ FROM scratch
4948
5049ARG TARGETARCH=amd64
5150
52- RUN apk update && apk upgrade --no-cache && \
53- adduser -D -h /home/authorizer -u 1000 -k /dev/null authorizer && \
54- mkdir -p web/app web/dashboard
51+ # CA certificates for TLS connections (OAuth, webhooks, etc.)
52+ COPY --from=go-builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
53+ # Timezone data
54+ COPY --from=go-builder /usr/share/zoneinfo /usr/share/zoneinfo
55+ # passwd entry for non-root user
56+ COPY --from=go-builder /etc/passwd /etc/passwd
57+
5558WORKDIR /authorizer
56- COPY --from=node-builder --chown=nobody:nobody /authorizer/web/app/build web/app/build
57- COPY --from=node-builder --chown=nobody:nobody /authorizer/web/app/favicon_io web/app/favicon_io
58- COPY --from=node-builder --chown=nobody:nobody /authorizer/web/dashboard/build web/dashboard/build
59- COPY --from=node-builder --chown=nobody:nobody /authorizer/web/dashboard/favicon_io web/dashboard/favicon_io
60- COPY --from=go-builder --chown=nobody:nobody /authorizer/build/linux/${TARGETARCH}/authorizer ./authorizer
59+ COPY --from=node-builder /authorizer/web/app/build web/app/build
60+ COPY --from=node-builder /authorizer/web/app/favicon_io web/app/favicon_io
61+ COPY --from=node-builder /authorizer/web/dashboard/build web/dashboard/build
62+ COPY --from=node-builder /authorizer/web/dashboard/favicon_io web/dashboard/favicon_io
63+ COPY --from=go-builder /authorizer/build/linux/${TARGETARCH}/authorizer ./authorizer
6164COPY web/templates web/templates
6265EXPOSE 8080 8081
63- USER authorizer
64- # ENTRYPOINT allows docker run args to be passed to the authorizer binary.
65- # When extending this image with a shell-form CMD (e.g. to expand env vars for Railway),
66- # override ENTRYPOINT in your Dockerfile: ENTRYPOINT ["/bin/sh", "-c"] so CMD runs in a shell.
66+ USER 65534
6767ENTRYPOINT [ "./authorizer" ]
6868CMD []
0 commit comments