Skip to content

Commit 1ee2473

Browse files
authored
feat: Support OS-specific immutable image builds (#5041)
This PR enhances the immutable image build process to support generating Docker images for specific Ubuntu versions (20.04 and 24.04), alongside the existing legacy image. ## Key Changes ### 1. New Dockerfiles for Ubuntu Versions Created new Dockerfiles for `external`, `dev`, and `internal` immutable images: * `docker/base/immutable/external/`: * `ubuntu-20-04.Dockerfile` * `ubuntu-24-04.Dockerfile` * `docker/chromium/base/immutable/dev/`: * `ubuntu-20-04.Dockerfile` * `ubuntu-24-04.Dockerfile` * `docker/chromium/base/immutable/internal/`: * `ubuntu-20-04.Dockerfile` * `ubuntu-24-04.Dockerfile` These Dockerfiles ensure that immutable instances can be built upon newer, specific OS base images (extending `base` or `chromium/base` as appropriate). ### 2. Updated `docker/build-immutable.sh` The build script was refactored to accept an optional 4th argument, `OS_VERSION`: * **Default Behavior:** If no argument (or `legacy`) is provided, it behaves as before, using the standard `Dockerfile` and tagging the image with the revision hash. * **OS-Specific Build:** If `ubuntu-20-04` or `ubuntu-24-04` is passed, the script selects the corresponding `${OS_VERSION}.Dockerfile` and tags the output image as `${OS_VERSION}-${REVISION}`. ### 3. Parallelized Cloud Build Configuration Updated `docker/immutable-cloudbuild.yaml` to leverage the new script capabilities: * Added parallel build steps for `legacy`, `ubuntu-20-04`, and `ubuntu-24-04`. * This ensures that all variants of the immutable images are built and pushed simultaneously during the CI/CD process. ## Impact This change allows ClusterFuzz to maintain and deploy immutable environments for multiple operating system versions, facilitating testing, migration, and support for newer dependencies.
1 parent 85d91bf commit 1ee2473

File tree

8 files changed

+207
-6
lines changed

8 files changed

+207
-6
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
FROM gcr.io/clusterfuzz-images/base:ubuntu-20-04
15+
16+
ENV IMMUTABLE_IMAGE=true
17+
18+
ARG CLUSTERFUZZ_SOURCE_DIR
19+
20+
COPY ${CLUSTERFUZZ_SOURCE_DIR} /data/clusterfuzz
21+
22+
RUN cd /data/clusterfuzz && bash local/install_deps.bash
23+
24+
COPY ${CLUSTERFUZZ_SOURCE_DIR}/clusterfuzz-config/configs/external /data/clusterfuzz/src/appengine/config
25+
26+
RUN rm -rf /data/clusterfuzz/clusterfuzz-config
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
FROM gcr.io/clusterfuzz-images/base:ubuntu-24-04
15+
16+
ENV IMMUTABLE_IMAGE=true
17+
18+
ARG CLUSTERFUZZ_SOURCE_DIR
19+
20+
COPY ${CLUSTERFUZZ_SOURCE_DIR} /data/clusterfuzz
21+
22+
RUN cd /data/clusterfuzz && bash local/install_deps.bash
23+
24+
COPY ${CLUSTERFUZZ_SOURCE_DIR}/clusterfuzz-config/configs/external /data/clusterfuzz/src/appengine/config
25+
26+
RUN rm -rf /data/clusterfuzz/clusterfuzz-config

docker/build-immutable.sh

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ if [ -n "$1" ]; then
4444
cd /workspace/clusterfuzz
4545
fi
4646

47+
# Default OS version
48+
OS_VERSION="legacy"
49+
if [ -n "$4" ]; then
50+
OS_VERSION="$4"
51+
fi
52+
4753
# Deleting the current config that is used for testing purposes.
4854
# It will be replaced by the project config during the image build.
4955
rm -rf src/appengine/config
@@ -67,19 +73,32 @@ for image_name in "${IMAGES[@]}"; do
6773
# image reference.
6874
full_image_name="$image_name/$(basename "$image_dir")"
6975

76+
if [ "$OS_VERSION" == "legacy" ]; then
77+
dockerfile="$image_dir/Dockerfile"
78+
tag="${CURRENT_CLUSTERFUZZ_REVISION}"
79+
else
80+
dockerfile="$image_dir/${OS_VERSION}.Dockerfile"
81+
tag="${OS_VERSION}-${CURRENT_CLUSTERFUZZ_REVISION}"
82+
fi
83+
84+
if [ ! -f "$dockerfile" ]; then
85+
echo "Skipping $dockerfile as it does not exist."
86+
continue
87+
fi
88+
7089
# Build the Docker image.
7190
# --build-arg CLUSTERFUZZ_SOURCE_DIR=.: Passes the location of the
7291
# ClusterFuzz source directory as a build argument.
73-
# -t "$full_image_name":${CURRENT_CLUSTERFUZZ_REVISION}: Tags the image with
74-
# its name and the current ClusterFuzz revision.
75-
# -f "$image_dir/Dockerfile": Specifies the path to the Dockerfile.
92+
# -t "$full_image_name":${tag}: Tags the image with
93+
# its name and the current ClusterFuzz revision (prefixed with OS version if applicable).
94+
# -f "$dockerfile": Specifies the path to the Dockerfile.
7695
# .: Sets the build context to the current directory.
77-
docker build --build-arg CLUSTERFUZZ_SOURCE_DIR=. -t "$full_image_name":${CURRENT_CLUSTERFUZZ_REVISION} -f "$image_dir/Dockerfile" .
96+
docker build --build-arg CLUSTERFUZZ_SOURCE_DIR=. -t "$full_image_name":${tag} -f "$dockerfile" .
7897

7998
# If the second argument to the script is "true", push the newly built
8099
# image to the container registry.
81100
if [ "$2" == "true" ]; then
82-
docker push "$full_image_name":${CURRENT_CLUSTERFUZZ_REVISION}
101+
docker push "$full_image_name":${tag}
83102
fi
84103
done
85104
done
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
FROM gcr.io/clusterfuzz-images/chromium/base:ubuntu-20-04
15+
16+
ENV IMMUTABLE_IMAGE=true
17+
18+
ARG CLUSTERFUZZ_SOURCE_DIR
19+
20+
COPY ${CLUSTERFUZZ_SOURCE_DIR} /data/clusterfuzz
21+
22+
RUN cd /data/clusterfuzz && bash local/install_deps.bash
23+
24+
COPY ${CLUSTERFUZZ_SOURCE_DIR}/clusterfuzz-config/configs/chrome-development /data/clusterfuzz/src/appengine/config
25+
26+
RUN rm -rf /data/clusterfuzz/clusterfuzz-config
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
FROM gcr.io/clusterfuzz-images/chromium/base:ubuntu-24-04
15+
16+
ENV IMMUTABLE_IMAGE=true
17+
18+
ARG CLUSTERFUZZ_SOURCE_DIR
19+
20+
COPY ${CLUSTERFUZZ_SOURCE_DIR} /data/clusterfuzz
21+
22+
RUN cd /data/clusterfuzz && bash local/install_deps.bash
23+
24+
COPY ${CLUSTERFUZZ_SOURCE_DIR}/clusterfuzz-config/configs/chrome-development /data/clusterfuzz/src/appengine/config
25+
26+
RUN rm -rf /data/clusterfuzz/clusterfuzz-config
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
FROM gcr.io/clusterfuzz-images/chromium/base:ubuntu-20-04
15+
16+
ENV IMMUTABLE_IMAGE=true
17+
18+
ARG CLUSTERFUZZ_SOURCE_DIR
19+
20+
COPY ${CLUSTERFUZZ_SOURCE_DIR} /data/clusterfuzz
21+
22+
RUN cd /data/clusterfuzz && bash local/install_deps.bash
23+
24+
COPY ${CLUSTERFUZZ_SOURCE_DIR}/clusterfuzz-config/configs/internal /data/clusterfuzz/src/appengine/config
25+
26+
RUN rm -rf /data/clusterfuzz/clusterfuzz-config
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
FROM gcr.io/clusterfuzz-images/chromium/base:ubuntu-24-04
15+
16+
ENV IMMUTABLE_IMAGE=true
17+
18+
ARG CLUSTERFUZZ_SOURCE_DIR
19+
20+
COPY ${CLUSTERFUZZ_SOURCE_DIR} /data/clusterfuzz
21+
22+
RUN cd /data/clusterfuzz && bash local/install_deps.bash
23+
24+
COPY ${CLUSTERFUZZ_SOURCE_DIR}/clusterfuzz-config/configs/internal /data/clusterfuzz/src/appengine/config
25+
26+
RUN rm -rf /data/clusterfuzz/clusterfuzz-config

docker/immutable-cloudbuild.yaml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,41 @@ steps:
8080
echo "Computed revision: $${REVISION}"
8181
echo "$${REVISION}" > /workspace/revision.txt
8282
83-
- id: build immutable image
83+
- id: build immutable image legacy
8484
name: gcr.io/cloud-builders/docker
8585
entrypoint: bash
86+
waitFor: ['compute revision']
8687
args:
8788
- -ex
8889
- docker/build-immutable.sh
8990
- ${_CLUSTERFUZZ_REVISION}
9091
- ${_PUSH_IMAGES}
9192
- ${PROJECT_ID}
93+
- legacy
94+
95+
- id: build immutable image ubuntu-20-04
96+
name: gcr.io/cloud-builders/docker
97+
entrypoint: bash
98+
waitFor: ['compute revision']
99+
args:
100+
- -ex
101+
- docker/build-immutable.sh
102+
- ${_CLUSTERFUZZ_REVISION}
103+
- ${_PUSH_IMAGES}
104+
- ${PROJECT_ID}
105+
- ubuntu-20-04
106+
107+
- id: build immutable image ubuntu-24-04
108+
name: gcr.io/cloud-builders/docker
109+
entrypoint: bash
110+
waitFor: ['compute revision']
111+
args:
112+
- -ex
113+
- docker/build-immutable.sh
114+
- ${_CLUSTERFUZZ_REVISION}
115+
- ${_PUSH_IMAGES}
116+
- ${PROJECT_ID}
117+
- ubuntu-24-04
92118

93119
timeout: 14400s
94120
options:

0 commit comments

Comments
 (0)