Skip to content

Commit 49239e8

Browse files
authored
Create utask-main-schedule immutable image (#4977)
Implement b/450233060 It implements the utask-main-scheduler immutable images. During this implementation, I noticed there are some images the are used in different projects, then I refactored the script to build an version of the same image for each project, for each image be built with the right configuration. --------- Signed-off-by: Javan Lacerda <javanlacerda@google.com>
1 parent 893e97e commit 49239e8

File tree

7 files changed

+139
-8
lines changed

7 files changed

+139
-8
lines changed

docker/build-immutable.sh

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,50 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
# This script builds immutable Docker images for ClusterFuzz.
17+
# It iterates through a predefined list of images, builds them using the
18+
# Dockerfiles found in subdirectories, and optionally pushes them to a container
19+
# registry.
20+
21+
# An array of Docker image names to be built.
1622
IMAGES=(
1723
gcr.io/clusterfuzz-images/chromium/base/immutable
18-
gcr.io/clusterfuzz-images/chromium/base/immutable/dev
19-
gcr.io/clusterfuzz-images/chromium/base/immutable/staging
2024
gcr.io/clusterfuzz-images/base/immutable
25+
gcr.io/clusterfuzz-images/utask-main-scheduler/immutable
2126
)
2227

28+
# If an argument is provided, change the current directory to
29+
# /workspace/clusterfuzz. This is typically used in CI/CD environments where the
30+
# script is executed from a different context.
2331
if [ -n "$1" ]; then
2432
cd /workspace/clusterfuzz
2533
fi
2634

35+
# Loop through each image name in the IMAGES array.
2736
for image_name in "${IMAGES[@]}"; do
28-
echo $PWD
37+
# Read the ClusterFuzz revision from the revision.txt file. This is used to
38+
# tag the Docker images.
2939
CURRENT_CLUSTERFUZZ_REVISION="$(cat /workspace/revision.txt)"
30-
image_dir=docker/${image_name#gcr.io/clusterfuzz-images/}
31-
docker build --build-arg CLUSTERFUZZ_SOURCE_DIR=. -t "$image_name":${CURRENT_CLUSTERFUZZ_REVISION} -f "$image_dir/Dockerfile" .
32-
if [ "$2" == "true" ]; then
33-
docker push "$image_name":${CURRENT_CLUSTERFUZZ_REVISION}
34-
fi
40+
41+
# Determine the directory containing the Dockerfile and related build context.
42+
project_dir=docker/${image_name#gcr.io/clusterfuzz-images/}
43+
44+
# Loop through each subdirectory in the project directory. This allows for
45+
# building multiple image variants from the same base project directory.
46+
for image_dir in ${project_dir}/*; do
47+
# Build the Docker image.
48+
# --build-arg CLUSTERFUZZ_SOURCE_DIR=.: Passes the location of the
49+
# ClusterFuzz source directory as a build argument.
50+
# -t "$image_name":${CURRENT_CLUSTERFUZZ_REVISION}: Tags the image with its
51+
# name and the current ClusterFuzz revision.
52+
# -f "$image_dir/Dockerfile": Specifies the path to the Dockerfile.
53+
# .: Sets the build context to the current directory.
54+
docker build --build-arg CLUSTERFUZZ_SOURCE_DIR=. -t "$image_dir":${CURRENT_CLUSTERFUZZ_REVISION} -f "$image_dir/Dockerfile" .
55+
56+
# If the second argument to the script is "true", push the newly built
57+
# image to the container registry.
58+
if [ "$2" == "true" ]; then
59+
docker push "$image_name":${CURRENT_CLUSTERFUZZ_REVISION}
60+
fi
61+
done
3562
done
File renamed without changes.
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/utask-main-scheduler
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+
RUN cp -r /data/clusterfuzz/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/utask-main-scheduler
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+
RUN cp -r /data/clusterfuzz/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/utask-main-scheduler
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+
RUN cp -r /data/clusterfuzz/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/utask-main-scheduler
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+
RUN cp -r /data/clusterfuzz/clusterfuzz-config/configs/chrome-staging /data/clusterfuzz/src/appengine/config
25+
26+
RUN rm -rf /data/clusterfuzz/clusterfuzz-config

0 commit comments

Comments
 (0)