Skip to content

Commit b52dc0e

Browse files
committed
fix: use bash array for docker args to preserve spaces in label/tag values
The flat string approach caused word splitting on label values that contain spaces (e.g. description labels), which made docker interpret split words as the PATH argument. Using a bash array with proper quoting via "${args[@]}" prevents this.
1 parent c819c26 commit b52dc0e

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

.github/workflows/build_wheel.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,25 +148,24 @@ jobs:
148148
should_push="${{ github.repository_owner == 'deepmodeling' && github.event_name == 'push' && github.actor != 'dependabot[bot]' }}"
149149
echo "${{ steps.meta.outputs.tags }}${{ matrix.variant }}" > /tmp/docker_tags.txt
150150
echo "${{ steps.meta.outputs.labels }}" > /tmp/docker_labels.txt
151-
echo "=== TAGS ===" && cat -n /tmp/docker_tags.txt
152-
echo "=== LABELS ===" && cat -n /tmp/docker_labels.txt
153-
# Build docker CLI args as a flat string, appending -t / --label flags.
154-
args="--file source/install/docker/Dockerfile"
155-
args="$args --build-arg VARIANT=${{ matrix.variant }}"
156-
args="$args --build-arg CUDA_VERSION=${{ matrix.cuda_version }}"
151+
# Build args as a bash array so values with spaces survive word splitting.
152+
args=(
153+
--file source/install/docker/Dockerfile
154+
--build-arg "VARIANT=${{ matrix.variant }}"
155+
--build-arg "CUDA_VERSION=${{ matrix.cuda_version }}"
156+
)
157157
while IFS= read -r t; do
158-
[ -n "$t" ] && args="$args -t $t"
158+
[ -n "$t" ] && args+=(-t "$t")
159159
done < /tmp/docker_tags.txt
160160
while IFS= read -r l; do
161-
[ -n "$l" ] && args="$args --label $l"
161+
[ -n "$l" ] && args+=(--label "$l")
162162
done < /tmp/docker_labels.txt
163-
[ "$should_push" = "true" ] && args="$args --push"
164-
echo "=== DOCKER ARGS ===" && echo "$args source/install/docker"
163+
[ "$should_push" = "true" ] && args+=(--push)
165164
max_retry=3
166165
for i in $(seq 1 $max_retry); do
167166
echo "Docker build attempt $i/$max_retry ..."
168167
set +e
169-
docker buildx build $args source/install/docker
168+
docker buildx build "${args[@]}" source/install/docker
170169
ec=$?
171170
set -e
172171
[ $ec -eq 0 ] && exit 0

0 commit comments

Comments
 (0)