Skip to content

Commit 13d4a41

Browse files
committed
Build a FIPS compatible glance-operator image
This change is aligned with the work already done for other operators, and the goal is to build a FIPS compatible glance-operator image. For this reason, the BASE_IMAGE has been moved to ubi-minimal and the toolchain uses go-toolset. Both CGO and GO111MODULE are enabled and passed as extra args to go build. Signed-off-by: Francesco Pantano <[email protected]>
1 parent 007aeec commit 13d4a41

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

.prow_ci.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export USE_IMAGE_DIGESTS=true
2+
export FAIL_FIPS_CHECK=true

Dockerfile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
ARG GOLANG_BUILDER=golang:1.19
2-
ARG OPERATOR_BASE_IMAGE=gcr.io/distroless/static:nonroot
1+
ARG GOLANG_BUILDER=registry.access.redhat.com/ubi9/go-toolset:1.19
2+
ARG OPERATOR_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi-minimal:latest
33

44
# Build the manager binary
55
FROM $GOLANG_BUILDER AS builder
@@ -12,19 +12,23 @@ ARG REMOTE_SOURCE_DIR=/remote-source
1212
ARG REMOTE_SOURCE_SUBDIR=
1313
ARG DEST_ROOT=/dest-root
1414

15-
ARG GO_BUILD_EXTRA_ARGS=
15+
ARG GO_BUILD_EXTRA_ARGS="-tags strictfipsruntime"
16+
# note we set CGO_ENABLED=0 to force a static build so that we can use
17+
# distroless/static as our base image
18+
ARG GO_BUILD_EXTRA_ENV_ARGS="CGO_ENABLED=1 GO111MODULE=on"
1619

1720
COPY $REMOTE_SOURCE $REMOTE_SOURCE_DIR
1821
WORKDIR $REMOTE_SOURCE_DIR/$REMOTE_SOURCE_SUBDIR
1922

23+
USER root
2024
RUN mkdir -p ${DEST_ROOT}/usr/local/bin/
2125

2226
# cache deps before building and copying source so that we don't need to re-download as much
2327
# and so that source changes don't invalidate our downloaded layer
2428
RUN if [ ! -f $CACHITO_ENV_FILE ]; then go mod download ; fi
2529

2630
# Build manager
27-
RUN if [ -f $CACHITO_ENV_FILE ] ; then source $CACHITO_ENV_FILE ; fi ; CGO_ENABLED=0 GO111MODULE=on go build ${GO_BUILD_EXTRA_ARGS} -a -o ${DEST_ROOT}/manager main.go
31+
RUN if [ -f $CACHITO_ENV_FILE ] ; then source $CACHITO_ENV_FILE ; fi ; env ${GO_BUILD_EXTRA_ENV_ARGS} go build ${GO_BUILD_EXTRA_ARGS} -a -o ${DEST_ROOT}/manager main.go
2832

2933
RUN cp -r templates ${DEST_ROOT}/templates
3034

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ endif
8686
SHELL = /usr/bin/env bash -o pipefail
8787
.SHELLFLAGS = -ec
8888

89+
# Extra vars which will be passed to the Docker-build
90+
DOCKER_BUILD_ARGS ?=
91+
8992
.PHONY: all
9093
all: build
9194

@@ -161,7 +164,7 @@ run: manifests generate fmt vet ## Run a controller from your host.
161164

162165
.PHONY: docker-build
163166
docker-build: test ## Build docker image with the manager.
164-
podman build -t ${IMG} .
167+
podman build -t ${IMG} . ${DOCKER_BUILD_ARGS}
165168

166169
.PHONY: docker-push
167170
docker-push: ## Push docker image with the manager.

0 commit comments

Comments
 (0)