Skip to content

Commit 1ae578e

Browse files
committed
release: do not install openssl in FIPS mode
Previously, our Dockerfile for deployment would install the `openssl` package when FIPS mode was enabled. However, this is unnecessary because the current implementation of FIPS mode does not rely on the system's OpenSSL library. This allows us to unify the Dockerfile for both variants. Additionally, install `ca-certificates` to ensure that TLS certificates can be properly validated, without implicitly using `x509.SetFallbackRoots`. Epic: none Release note: none
1 parent 0375f11 commit 1ae578e

File tree

4 files changed

+17
-38
lines changed

4 files changed

+17
-38
lines changed

build/deploy/Dockerfile

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
11
# We use a docker image mirror to avoid pulling from 3rd party repos, which sometimes have reliability issues.
22
# See https://cockroachlabs.atlassian.net/wiki/spaces/devinf/pages/3462594561/Docker+image+sync for the details.
33
FROM us-east1-docker.pkg.dev/crl-docker-sync/registry-access-redhat-com/ubi10/ubi-minimal
4-
ARG fips_enabled
54

6-
# For deployment, we need the following additionally installed:
7-
# tzdata - for time zone functions
5+
# For deployment, we need the following additional packages:
6+
# ca-certificates - to validate TLS certs
87
# hostname - used in cockroach k8s manifests
9-
# tar - used by kubectl cp
10-
RUN microdnf update -y \
11-
&& microdnf install tzdata hostname tar gzip xz -y \
8+
# tar, gzip, xz - used by kubectl cp
9+
# tzdata - for time zone functions
10+
RUN microdnf update -y && microdnf install -y \
11+
ca-certificates \
12+
tzdata \
13+
hostname \
14+
tar \
15+
gzip \
16+
xz \
1217
&& rm -rf /var/cache/yum
13-
# FIPS mode requires the `openssl` package installed. Also we need to temporarily
14-
# install the `crypto-policies-scripts` packege to tweak some configs. Because
15-
# `microdnf` doesn't support `autoremove`, we need to record the list of
16-
# packages before and after, and remove the installed ones afterward.
17-
RUN if [ "$fips_enabled" == "1" ]; then \
18-
microdnf install -y openssl && \
19-
rpm -qa | sort > /before.txt && \
20-
microdnf install -y crypto-policies-scripts && \
21-
update-crypto-policies --set FIPS && \
22-
rpm -qa | sort > /after.txt && \
23-
microdnf remove -y $(comm -13 /before.txt /after.txt) && \
24-
microdnf clean all && \
25-
rm -rf /var/cache/yum /before.txt /after.txt; \
26-
fi
27-
2818

2919
RUN mkdir /usr/local/lib/cockroach /cockroach /licenses /docker-entrypoint-initdb.d
3020
COPY cockroach.sh cockroach /cockroach/

build/release/teamcity-support.sh

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ verify_docker_image(){
7676
build_type=$(grep "^Build Type:" <<< "$output" | cut -d: -f2 | sed 's/ //g')
7777
sha=$(grep "^Build Commit ID:" <<< "$output" | cut -d: -f2 | sed 's/ //g')
7878
build_tag=$(grep "^Build Tag:" <<< "$output" | cut -d: -f2 | sed 's/ //g')
79-
go_version=$(grep "^Go Version:" <<< "$output" | cut -d: -f2 | sed 's/ //g')
79+
fips_enabled=$(grep '^FIPS enabled:\s*true' <<< "$output")
8080

8181
# Build Type should always be "release"
8282
if [ "$build_type" != "release" ]; then
@@ -97,16 +97,9 @@ verify_docker_image(){
9797
echo "ERROR: Build tag from 'cockroach version --build-tag' mismatch, expected '$expected_build_tag', got '$build_tag_output'"
9898
error=1
9999
fi
100-
if [[ $fips_build == true ]]; then
101-
if [[ "$go_version" != *"fips"* ]]; then
102-
echo "ERROR: Go version '$go_version' does not contain 'fips'"
103-
error=1
104-
fi
105-
openssl_version_output=$(docker run --platform="$docker_platform" "$img" shell -c "openssl version -f")
106-
if [[ $openssl_version_output != *"FIPS_VERSION"* ]]; then
107-
echo "ERROR: openssl version '$openssl_version_output' does not contain 'FIPS_VERSION'"
108-
error=1
109-
fi
100+
if [[ $fips_build == true && -z $fips_enabled ]]; then
101+
echo "ERROR: FIPS is not enabled"
102+
error=1
110103
fi
111104
if [[ $docker_platform == "linux/amd64" ]]; then
112105
# Running arm64 `cockroach demo` on amd64 times out.

build/teamcity/internal/release/process/build-cockroach-release-per-platform.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,8 @@ if [[ $platform == "linux-amd64" || $platform == "linux-arm64" || $platform == "
106106
build_docker_tag="${gcr_staged_repository}:${arch}-${version}"
107107
if [[ $platform == "linux-amd64-fips" ]]; then
108108
build_docker_tag="${gcr_staged_repository}:${version}-fips"
109-
docker build --label version="$version_label" --no-cache --pull --platform="linux/${arch}" --tag="${build_docker_tag}" --build-arg fips_enabled=1 "build/deploy-${platform}"
110-
else
111-
docker build --label version="$version_label" --no-cache --pull --platform="linux/${arch}" --tag="${build_docker_tag}" "build/deploy-${platform}"
112109
fi
110+
docker build --label version="$version_label" --no-cache --pull --platform="linux/${arch}" --tag="${build_docker_tag}" "build/deploy-${platform}"
113111
docker push "$build_docker_tag"
114112
tc_end_block "Make and push docker image"
115113
fi

build/teamcity/internal/release/process/make-and-publish-build-artifacts-per-platform.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,8 @@ if [[ $platform == "linux-amd64" || $platform == "linux-arm64" || $platform == "
133133
build_docker_tag="${gcr_repository}:${arch}-${build_name}"
134134
if [[ $platform == "linux-amd64-fips" ]]; then
135135
build_docker_tag="${gcr_repository}:${build_name}-fips"
136-
docker build --no-cache --pull --platform "linux/${arch}" --tag="${build_docker_tag}" --build-arg fips_enabled=1 "build/deploy-${platform}"
137-
else
138-
docker build --no-cache --pull --platform "linux/${arch}" --tag="${build_docker_tag}" "build/deploy-${platform}"
139136
fi
137+
docker build --no-cache --pull --platform "linux/${arch}" --tag="${build_docker_tag}" "build/deploy-${platform}"
140138
docker push "$build_docker_tag"
141139

142140
tc_end_block "Make and push docker images"

0 commit comments

Comments
 (0)