@@ -7,15 +7,17 @@ org_name=""
7
7
push=0
8
8
load=0
9
9
tag_suffix=" "
10
+ dry_run=0
10
11
11
12
# Function to display usage information
12
13
usage () {
13
- echo " Usage: $0 -i <image_name> [-o <org_name>] [--push] [--load] [-t <tag_suffix>]"
14
+ echo " Usage: $0 -i <image_name> [-o <org_name>] [--push] [--load] [-t <tag_suffix>] [--dry] "
14
15
echo " -i: Image name (required)"
15
16
echo " -o: Organization name"
16
17
echo " --push: Push the image"
17
18
echo " --load: Load the image"
18
19
echo " -t: Tag suffix"
20
+ echo " --dry: Don't build, only create build-args.json"
19
21
exit 1
20
22
}
21
23
@@ -27,6 +29,7 @@ while [[ $# -gt 0 ]]; do
27
29
--push) push=1; shift ;;
28
30
--load) load=1; shift ;;
29
31
-t) tag_suffix=" $2 " ; shift 2 ;;
32
+ --dry) dry_run=1; shift ;;
30
33
* ) usage ;;
31
34
esac
32
35
done
@@ -113,10 +116,13 @@ echo "Repo: $DOCKER_REPOSITORY"
113
116
echo " Base dir: $DOCKER_BASE_DIR "
114
117
115
118
args=" "
119
+ full_tags=()
116
120
for tag in " ${tags[@]} " ; do
117
121
args+=" -t $DOCKER_REPOSITORY :$tag "
122
+ full_tags+=(" $DOCKER_REPOSITORY :$tag " )
118
123
done
119
124
125
+
120
126
if [[ $push -eq 1 ]]; then
121
127
args+=" --push"
122
128
args+=" --cache-to=type=registry,ref=$DOCKER_REPOSITORY :$cache_tag ,mode=max"
@@ -136,6 +142,26 @@ else
136
142
# For push or without load, build for multiple platforms
137
143
platform=" linux/amd64,linux/arm64"
138
144
fi
145
+ if [[ $dry_run -eq 1 ]]; then
146
+ echo " Dry Run is enabled. Writing build config to docker-build-dry.json"
147
+ jq -n \
148
+ --argjson tags " $( printf ' %s\n' " ${full_tags[@]} " | jq -R . | jq -s .) " \
149
+ --arg platform " $platform " \
150
+ --arg openhands_build_version " $OPENHANDS_BUILD_VERSION " \
151
+ --arg dockerfile " $dir /Dockerfile" \
152
+ ' {
153
+ tags: $tags,
154
+ platform: $platform,
155
+ build_args: [
156
+ "OPENHANDS_BUILD_VERSION=" + $openhands_build_version
157
+ ],
158
+ dockerfile: $dockerfile
159
+ }' > docker-build-dry.json
160
+
161
+ exit 0
162
+ fi
163
+
164
+
139
165
140
166
echo " Building for platform(s): $platform "
141
167
0 commit comments