2022-03-31 18:48:52 +00:00
|
|
|
# syntax=docker/dockerfile:1
|
2022-03-29 23:58:41 +00:00
|
|
|
|
2023-01-19 00:00:16 +00:00
|
|
|
# Copyright 2022-2023 the Pinniped contributors. All Rights Reserved.
|
2022-03-29 23:58:41 +00:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2023-03-09 04:32:03 +00:00
|
|
|
# This dockerfile is used to produce a binary of Pinniped that uses
|
|
|
|
# only FIPS-allowable ciphers. Note that this is provided only as
|
|
|
|
# an example. Pinniped has no official support for FIPS and using
|
2022-03-31 18:48:52 +00:00
|
|
|
# a version built from this dockerfile may have unforseen consquences.
|
|
|
|
# Please do not create issues in regards to problems encountered by
|
|
|
|
# using this dockerfile. Using this dockerfile does not convey
|
2023-03-09 04:32:03 +00:00
|
|
|
# any type of FIPS certification.
|
2022-03-29 23:58:41 +00:00
|
|
|
|
2023-01-19 00:00:16 +00:00
|
|
|
# Starting in 1.19, go-boringcrypto has been added to the main Go toolchain,
|
|
|
|
# hidden behind a `GOEXPERIMENT=boringcrypto` env var.
|
|
|
|
# See https://go.googlesource.com/go/+/dev.boringcrypto/README.boringcrypto.md
|
|
|
|
# and https://kupczynski.info/posts/fips-golang/ for details.
|
2023-09-11 00:35:31 +00:00
|
|
|
FROM golang:1.21.1 as build-env
|
2022-03-29 23:58:41 +00:00
|
|
|
|
|
|
|
WORKDIR /work
|
|
|
|
COPY . .
|
|
|
|
ARG GOPROXY
|
|
|
|
|
2023-03-09 04:32:03 +00:00
|
|
|
# GOEXPERIMENT=boringcrypto will tell both Pinniped source code and Golang to use boringcrypto
|
2022-03-29 23:58:41 +00:00
|
|
|
RUN \
|
|
|
|
mkdir out && \
|
2023-03-09 04:32:03 +00:00
|
|
|
export CGO_ENABLED=1 && \
|
|
|
|
export GOOS=linux && \
|
|
|
|
export GOARCH=amd64 && \
|
|
|
|
export GOEXPERIMENT=boringcrypto && \
|
|
|
|
go build -tags osusergo,netgo -v -trimpath -ldflags "$(hack/get-ldflags.sh) -w -linkmode=external -extldflags -static" -o /usr/local/bin/pinniped-concierge-kube-cert-agent ./cmd/pinniped-concierge-kube-cert-agent/... && \
|
|
|
|
go build -tags osusergo,netgo -v -trimpath -ldflags "$(hack/get-ldflags.sh) -w -linkmode=external -extldflags -static" -o /usr/local/bin/pinniped-server ./cmd/pinniped-server/... && \
|
2022-03-29 23:58:41 +00:00
|
|
|
ln -s /usr/local/bin/pinniped-server /usr/local/bin/pinniped-concierge && \
|
|
|
|
ln -s /usr/local/bin/pinniped-server /usr/local/bin/pinniped-supervisor && \
|
|
|
|
ln -s /usr/local/bin/pinniped-server /usr/local/bin/local-user-authenticator
|
|
|
|
|
|
|
|
# Use a distroless runtime image with CA certificates, timezone data, and not much else.
|
2022-09-23 21:41:54 +00:00
|
|
|
FROM gcr.io/distroless/static:nonroot@sha256:2a9e2b4fa771d31fe3346a873be845bfc2159695b9f90ca08e950497006ccc2e
|
2022-03-29 23:58:41 +00:00
|
|
|
|
|
|
|
# Copy the server binary from the build-env stage.
|
|
|
|
COPY --from=build-env /usr/local/bin /usr/local/bin
|
|
|
|
|
|
|
|
# Document the default server ports for the various server apps
|
|
|
|
EXPOSE 8443 8444 10250
|
|
|
|
|
|
|
|
# Run as non-root for security posture
|
|
|
|
# Use the same non-root user as https://github.com/GoogleContainerTools/distroless/blob/fc3c4eaceb0518900f886aae90407c43be0a42d9/base/base.bzl#L9
|
|
|
|
# This is a workaround for https://github.com/GoogleContainerTools/distroless/issues/718
|
|
|
|
USER 65532:65532
|
|
|
|
|
|
|
|
# Set the entrypoint
|
|
|
|
ENTRYPOINT ["/usr/local/bin/pinniped-server"]
|