Skip to content

Commit bcc6aad

Browse files
committed
Only run domain proxy during hermetic mode. Configure domain proxy in AbstractPreprocessor.
1 parent 8acbc18 commit bcc6aad

File tree

2 files changed

+53
-38
lines changed

2 files changed

+53
-38
lines changed

deploy/tasks/buildah-oci-ta.yaml

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,9 @@ spec:
291291
cp "$dockerfile_path" "$dockerfile_copy"
292292
293293
if [ -n "$JVM_BUILD_WORKSPACE_ARTIFACT_CACHE_PORT_80_TCP_ADDR" ] && grep -q '^\s*RUN \(./\)\?mvn' "$dockerfile_copy"; then
294-
settings="<settings><proxies><proxy><id>domain-proxy</id><active>true</active><protocol>http</protocol><host>localhost</host><port>8080</port></proxy></proxies><mirrors><mirror><id>mirror.default</id><url>http://$JVM_BUILD_WORKSPACE_ARTIFACT_CACHE_PORT_80_TCP_ADDR/v1/cache/default/0/</url><mirrorOf>*</mirrorOf></mirror></mirrors></settings>"
295-
else
296-
settings="<settings><proxies><proxy><id>domain-proxy</id><active>true</active><protocol>http</protocol><host>localhost</host><port>8080</port></proxy></proxies></settings>"
294+
sed -i -e "s|^\s*RUN \(\(./\)\?mvn\)\(.*\)|RUN echo \"<settings><mirrors><mirror><id>mirror.default</id><url>http://$JVM_BUILD_WORKSPACE_ARTIFACT_CACHE_PORT_80_TCP_ADDR/v1/cache/default/0/</url><mirrorOf>*</mirrorOf></mirror></mirrors></settings>\" > /tmp/settings.yaml; \1 -s /tmp/settings.yaml \3|g" "$dockerfile_copy"
295+
touch /var/lib/containers/java
297296
fi
298-
sed -i -e "s|^\s*RUN \(\(./\)\?mvn\)\(.*\)|RUN echo \"$settings\" > /tmp/settings.yaml; \1 -s /tmp/settings.yaml \3|g" "$dockerfile_copy"
299-
touch /var/lib/containers/java
300297
301298
# Fixing group permission on /var/lib/containers
302299
chown root:root /var/lib/containers
@@ -365,6 +362,8 @@ spec:
365362
unshare -Ufp --keep-caps -r --map-users 1,1,65536 --map-groups 1,1,65536 -- buildah pull $image
366363
done
367364
echo "Build will be executed with network isolation"
365+
/app/domain-proxy-server-runner &
366+
server_pid=$!
368367
fi
369368
370369
if [ -n "${TARGET_STAGE}" ]; then
@@ -418,9 +417,6 @@ spec:
418417
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume ${mount_point}:${YUM_REPOS_D_TARGET}"
419418
fi
420419
421-
/app/domain-proxy-server-runner &
422-
server_pid=$!
423-
424420
DEFAULT_LABELS=(
425421
"--label" "build-date=$(date -u +'%Y-%m-%dT%H:%M:%S')"
426422
"--label" "architecture=$(uname -m)"
@@ -464,36 +460,46 @@ spec:
464460
# Prevent ShellCheck from giving a warning because 'image' is defined and 'IMAGE' is not.
465461
declare IMAGE
466462
467-
# Without expansion
468-
cat > /app/build-script.sh << 'EOF'
469-
#!/bin/sh
470-
ip link set lo up
471-
/app/domain-proxy-client-runner &
472-
client_pid=$!
473-
EOF
474-
475-
# With expansion
476-
cat >> /app/build-script.sh << EOF
477-
buildah build $VOLUME_MOUNTS ${BUILDAH_ARGS[@]} ${LABELS[@]} --tls-verify=$TLSVERIFY --no-cache --ulimit nofile=4096:4096 -f "$dockerfile_copy" -t $IMAGE .
478-
EOF
479-
480-
# Without expansion
481-
cat >> /app/build-script.sh << 'EOF'
482-
set +e
483-
kill $client_pid
484-
wait $client_pid
485-
set -e
486-
EOF
487-
488-
cat /app/build-script.sh
489-
chmod +x /app/build-script.sh
490-
491-
unshare -Uf $UNSHARE_ARGS --keep-caps -r --map-users 1,1,65536 --map-groups 1,1,65536 -w ${SOURCE_CODE_DIR}/$CONTEXT -- /app/build-script.sh
492-
493-
set +e
494-
kill $server_pid
495-
wait $server_pid
496-
set -e
463+
if [ "${HERMETIC}" == "true" ]; then
464+
# Without expansion
465+
cat > /app/build-script.sh << 'EOF'
466+
#!/bin/sh
467+
ip link set lo up
468+
/app/domain-proxy-client-runner &
469+
client_pid=$!
470+
EOF
471+
472+
# With expansion
473+
cat >> /app/build-script.sh << EOF
474+
buildah build $VOLUME_MOUNTS ${BUILDAH_ARGS[@]} ${LABELS[@]} --tls-verify=$TLSVERIFY --no-cache --ulimit nofile=4096:4096 -f "$dockerfile_copy" -t $IMAGE .
475+
EOF
476+
477+
# Without expansion
478+
cat >> /app/build-script.sh << 'EOF'
479+
set +e
480+
kill $client_pid
481+
wait $client_pid
482+
set -e
483+
EOF
484+
485+
cat /app/build-script.sh
486+
chmod +x /app/build-script.sh
487+
488+
unshare -Uf $UNSHARE_ARGS --keep-caps -r --map-users 1,1,65536 --map-groups 1,1,65536 -w ${SOURCE_CODE_DIR}/$CONTEXT -- /app/build-script.sh
489+
490+
set +e
491+
kill $server_pid
492+
wait $server_pid
493+
set -e
494+
else
495+
unshare -Uf $UNSHARE_ARGS --keep-caps -r --map-users 1,1,65536 --map-groups 1,1,65536 -w ${SOURCE_CODE_DIR}/$CONTEXT -- buildah build \
496+
$VOLUME_MOUNTS \
497+
"${BUILDAH_ARGS[@]}" \
498+
"${LABELS[@]}" \
499+
--tls-verify=$TLSVERIFY --no-cache \
500+
--ulimit nofile=4096:4096 \
501+
-f "$dockerfile_copy" -t "$IMAGE" .
502+
fi
497503
498504
container=$(buildah from --pull-never "$IMAGE")
499505
buildah mount $container | tee /shared/container_path

java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/build/preprocessor/AbstractPreprocessor.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,15 @@ private String getMavenSetup() {
227227
<mirrorOf>*</mirrorOf>
228228
</mirror>
229229
</mirrors>
230+
<proxies>
231+
<proxy>
232+
<id>domain-proxy</id>
233+
<active>true</active>
234+
<protocol>http</protocol>
235+
<host>localhost</host>
236+
<port>8080</port>
237+
</proxy>
238+
</proxies>
230239
EOF
231240
else
232241
cat >${HOME}/.m2/settings.xml <<EOF

0 commit comments

Comments
 (0)