1# This ARG has to be at the top, otherwise the docker daemon does not known what to do with FROM ${RUNTIME_IMAGE}
2ARG RUNTIME_IMAGE=gcr.io/distroless/static:nonroot
4# All builds should be done using the platform native to the build node to allow
5# cache sharing of the go mod download step.
6# Go cross compilation is also faster than emulation the go compilation across
8FROM --platform=${BUILDPLATFORM} docker.io/library/golang:1.22-bookworm AS builder
11WORKDIR $GOPATH/src/github.com/oauth2-proxy/oauth2-proxy
20# Arguments go here so that the previous steps can be cached if no external
21# sources have changed.
26# Build binary and make sure there is at least an empty key file.
27# This is useful for GCP App Engine custom runtime builds, because
28# you cannot use multiline variables in their app.yaml, so you have to
29# build the key into the container and then tell it where it is
30# by setting OAUTH2_PROXY_JWT_KEY_FILE=/etc/ssl/private/jwt_signing_key.pem
32# Set the cross compilation arguments based on the TARGETPLATFORM which is
33# automatically set by the docker engine.
34RUN case ${TARGETPLATFORM} in \
35 "linux/amd64") GOARCH=amd64 ;; \
36 # arm64 and arm64v8 are equivilant in go and do not require a goarm
37 # https://github.com/golang/go/wiki/GoArm
38 "linux/arm64" | "linux/arm/v8") GOARCH=arm64 ;; \
39 "linux/ppc64le") GOARCH=ppc64le ;; \
40 "linux/arm/v6") GOARCH=arm GOARM=6 ;; \
41 "linux/arm/v7") GOARCH=arm GOARM=7 ;; \
43 printf "Building OAuth2 Proxy for arch ${GOARCH}\n" && \
44 GOARCH=${GOARCH} VERSION=${VERSION} make build && touch jwt_signing_key.pem
46# Copy binary to runtime image
48COPY --from=builder /go/src/github.com/oauth2-proxy/oauth2-proxy/oauth2-proxy /bin/oauth2-proxy
49COPY --from=builder /go/src/github.com/oauth2-proxy/oauth2-proxy/jwt_signing_key.pem /etc/ssl/private/jwt_signing_key.pem
51ENTRYPOINT ["/bin/oauth2-proxy"]
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list