Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FIPS build. #1076

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,17 @@ download:
build: $(PREFIX)bin/$(BINNAME)
@echo "Build Complete!"

build-fips: $(PREFIX)bin/$(BINNAME).fips
@echo "Build Complete!"

$(PREFIX)bin/$(BINNAME): download $(call rwildcard,*.go)
$Q mkdir -p $(@D)
$Q $(GOOS_OVERRIDE) $(CGO_OVERRIDE) go build -v -o $@ $(GCFLAGS) $(LDFLAGS) $(PKG)

$(PREFIX)bin/$(BINNAME).fips: download $(call rwildcard,*.go)
$Q mkdir -p $(@D)
$Q $(GOOS_OVERRIDE) $(CGO_OVERRIDE) GOEXPERIMENT="boringcrypto" go build -v -o $@ $(GCFLAGS) $(LDFLAGS) $(PKG)

.PHONY: build simple

#########################################
Expand Down
43 changes: 43 additions & 0 deletions docker/Dockerfile.fips
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM --platform=$BUILDPLATFORM golang:alpine AS builder

WORKDIR /src
COPY go.mod go.sum .
RUN go mod download
COPY . .
RUN apk add --no-cache make git curl

ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
GOOS="${TARGETOS}"; \
GOARCH="${TARGETARCH}"; \
if [ "${TARGETARCH}" = "arm" ] && [ "${TARGETVARIANT}" ]; then \
GOARM="${TARGETVARIANT#v}"; \
fi; \
CGO_ENABLED=0 GOOS_OVERRIDE="GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM}" \
make V=1 build-fips

FROM smallstep/alpine-fips

ENV STEP="/home/step"
ENV STEPPATH="/home/step"
ARG STEPUID=1000
ARG STEPGID=1000

RUN apk update \
&& apk upgrade \
&& apk add --no-cache bash curl tzdata \
&& addgroup -g ${STEPGID} step \
&& adduser -D -u ${STEPUID} -G step step \
&& chown step:step /home/step

COPY --from=builder /src/bin/step.fips "/usr/local/bin/step"

USER step
WORKDIR /home/step

STOPSIGNAL SIGTERM

CMD /bin/bash