# oauth2-proxy from the official v7.15.5 release archive. Embedded sign-in, # error, robots, logo and /static assets ship in that tarball. No vendor/. ARG GO_IMAGE=docker.io/library/golang:1.27.2-alpine3.24@sha256:f92b6ef800e499660581efdabdf25d9d817a9d124eaf900924f0504e7e27e12d FROM ${GO_IMAGE} AS build LABEL io.thepeoples.hardened.build-owner="hardened-batch4" ARG SOURCE_URL=https://github.com/oauth2-proxy/oauth2-proxy/archive/refs/tags/v7.15.5.tar.gz ARG SOURCE_SHA256=cf8055fecef1f89bcc89834d3342009b4067e80b1994e6bb5c2456d8ff68995b ARG SOURCE_COMMIT=bea3f04bf87b93f5354f392fe2216a88e6031350 ARG VERSION=v7.15.5 ARG GO_BUMPS="golang.org/x/net@v0.60.0" ENV GOTOOLCHAIN=local CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOMAXPROCS=4 WORKDIR /src RUN wget -q -O /tmp/upstream.tar.gz "${SOURCE_URL}" \ && printf '%s %s\n' "${SOURCE_SHA256}" /tmp/upstream.tar.gz | sha256sum -c - \ && tar -xzf /tmp/upstream.tar.gz --strip-components=1 -C /src # Stable cache IDs share caches across builds, rather than retaining a cache per slice. RUN --mount=type=cache,id=hardened-go-build,target=/root/.cache/go-build \ --mount=type=cache,id=hardened-go-mod,target=/go/pkg/mod \ mkdir -p /out/records /out/source /out/rootfs/tmp /out/rootfs/etc/ssl/private \ && cp go.mod /out/records/upstream.go.mod \ && cp go.sum /out/records/upstream.go.sum \ && if [ -n "${GO_BUMPS}" ]; then \ GOFLAGS=-mod=mod go get ${GO_BUMPS} \ && go mod download && go mod verify && go mod vendor; \ else \ go mod download && go mod verify && go mod vendor; \ fi \ && go build -p 4 -mod=vendor -buildvcs=false -trimpath \ -tags 'netgo osusergo' \ -ldflags "-s -w -X github.com/oauth2-proxy/oauth2-proxy/v7/pkg/version.VERSION=${VERSION}" \ -o /out/oauth2-proxy . \ && go version -m /out/oauth2-proxy > /out/records/go-version-m.txt \ && cp vendor/modules.txt /out/records/vendor-modules.txt \ && cp go.mod /out/records/effective.go.mod \ && cp go.sum /out/records/effective.go.sum \ && cp LICENSE /out/records/ \ && printf '%s\n' "${SOURCE_COMMIT}" > /out/records/upstream-commit \ && printf '%s\n' "${GO_BUMPS}" > /out/records/bumps \ && : > /out/rootfs/etc/ssl/private/jwt_signing_key.pem \ && printf 'nonroot:x:65532:65532:nonroot:/:/sbin/nologin\n' > /out/rootfs/etc/passwd \ && printf 'nonroot:x:65532:\n' > /out/rootfs/etc/group \ && chmod 1777 /out/rootfs/tmp \ && chmod 0600 /out/rootfs/etc/ssl/private/jwt_signing_key.pem \ && cp /tmp/upstream.tar.gz /out/source/oauth2-proxy-${VERSION}.tar.gz \ && cp -R /out/records /out/source/records \ && tar -czf /out/source/vendor.tar.gz vendor \ && cd /out/source && sha256sum *.tar.gz records/* > SHA256SUMS FROM scratch AS source LABEL io.thepeoples.hardened.build-owner="hardened-batch4" COPY --from=build /out/source/ / FROM scratch ARG GO_IMAGE COPY --from=build --chown=65532:65532 /out/rootfs/ / COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt COPY --from=build --chmod=0755 /out/oauth2-proxy /bin/oauth2-proxy COPY --from=build /out/records/ /usr/share/tp-hardened/oauth2-proxy/ USER 65532:65532 WORKDIR / EXPOSE 4180 44180 ENTRYPOINT ["/bin/oauth2-proxy"] LABEL org.opencontainers.image.version="v7.15.5" \ org.opencontainers.image.source="https://github.com/oauth2-proxy/oauth2-proxy" \ org.opencontainers.image.revision="bea3f04bf87b93f5354f392fe2216a88e6031350" \ org.opencontainers.image.licenses="MIT" \ io.thepeoples.hardened.upstream="quay.io/oauth2-proxy/oauth2-proxy:v7.15.5@sha256:8498b0d0ef0a7b29686414000a08aee467f02d0299c9ed1e006a8f33fc017916" \ io.thepeoples.hardened.ladder="b+minimize" \ io.thepeoples.hardened.toolchain="${GO_IMAGE}" \ io.thepeoples.hardened.source-status="upstream release tarball plus this Containerfile and recorded module changes"