diff --git a/.dockerignore b/.dockerignore index 1bc5bbc67f..dc32300f98 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,5 @@ Dockerfile.dev +Dockerfile docs vendor .git diff --git a/CHANGELOG.md b/CHANGELOG.md index 9270443ab6..1971965ed6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,14 @@ ## Important Notes +- [#1478](https://github.com/oauth2-proxy/oauth2-proxy/pull/1478) Changes the UID and GID of the runtime user to `65532`. + Which also is known as `nonroot` user in [distroless images](https://github.com/GoogleContainerTools/distroless). + ## Breaking Changes ## Changes since v7.2.1 +- [#1478](https://github.com/oauth2-proxy/oauth2-proxy/pull/1478) Parameterise the runtime image (@omBratteng) - [#1583](https://github.com/oauth2-proxy/oauth2-proxy/pull/1583) Add groups to session too when creating session from bearer token (@adriananeci) - [#1418](https://github.com/oauth2-proxy/oauth2-proxy/pull/1418) Support for passing arbitrary query parameters through from `/oauth2/start` to the identity provider's login URL. Configuration settings control which parameters are passed by default and precisely which values can be overridden per-request (@ianroberts) - [#1559](https://github.com/oauth2-proxy/oauth2-proxy/pull/1559) Introduce ProviderVerifier to clean up OIDC discovery code (@JoelSpeed) diff --git a/Dockerfile b/Dockerfile index e6963e32c5..1615b9a8d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,6 @@ +# This ARG has to be at the top, otherwise the docker daemon does not known what to do with FROM ${RUNTIME_IMAGE} +ARG RUNTIME_IMAGE=alpine:3.15 + # All builds should be done using the platform native to the build node to allow # cache sharing of the go mod download step. # Go cross compilation is also faster than emulation the go compilation across @@ -38,12 +41,12 @@ RUN case ${TARGETPLATFORM} in \ GOARCH=${GOARCH} VERSION=${VERSION} make build && touch jwt_signing_key.pem # Copy binary to alpine -FROM alpine:3.15 +FROM ${RUNTIME_IMAGE} COPY nsswitch.conf /etc/nsswitch.conf -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt COPY --from=builder /go/src/github.com/oauth2-proxy/oauth2-proxy/oauth2-proxy /bin/oauth2-proxy COPY --from=builder /go/src/github.com/oauth2-proxy/oauth2-proxy/jwt_signing_key.pem /etc/ssl/private/jwt_signing_key.pem -USER 2000:2000 +# UID/GID 65532 is also known as nonroot user in distroless image +USER 65532:65532 ENTRYPOINT ["/bin/oauth2-proxy"] diff --git a/Makefile b/Makefile index a0ff29d9ac..965d00a2b1 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,8 @@ $(BINARY): CGO_ENABLED=0 $(GO) build -a -installsuffix cgo -ldflags="-X main.VERSION=${VERSION}" -o $@ github.com/oauth2-proxy/oauth2-proxy/v7 DOCKER_BUILD_PLATFORM ?= linux/amd64,linux/arm64,linux/ppc64le,linux/arm/v6 -DOCKER_BUILDX_ARGS ?= +DOCKER_BUILD_RUNTIME_IMAGE ?= alpine:3.15 +DOCKER_BUILDX_ARGS ?= --build-arg RUNTIME_IMAGE=${DOCKER_BUILD_RUNTIME_IMAGE} DOCKER_BUILDX := docker buildx build ${DOCKER_BUILDX_ARGS} --build-arg VERSION=${VERSION} DOCKER_BUILDX_X_PLATFORM := $(DOCKER_BUILDX) --platform ${DOCKER_BUILD_PLATFORM} DOCKER_BUILDX_PUSH := docker buildx build --push ${DOCKER_BUILDX_ARGS} --build-arg VERSION=${VERSION}