run-builder: support background execution

The run-builder script now takes a command line argument, which is
either
  start - run the container in the background
  stop  - stop the running container
  fg    - run the container in the foreground (old behavior)

This should prove useful in CI.
This commit is contained in:
Christian Kellner 2020-09-10 12:13:00 +02:00 committed by Tom Gundersen
parent 1effdc7a2c
commit 10e691d8c3

View file

@ -19,13 +19,32 @@ else
exit 2
fi
GATEWAY_IP=$(podman network inspect org.osbuild.koji --format '{{ (index (index (index .plugins 0).ipam.ranges 0) 0).gateway }}')
echo "Gateway IP is $GATEWAY_IP"
builder_start() {
GATEWAY_IP=$(podman network inspect org.osbuild.koji --format '{{ (index (index (index .plugins 0).ipam.ranges 0) 0).gateway }}')
echo "Gateway IP is $GATEWAY_IP"
${CONTAINER_RUNTIME} run --rm -i -t --name org.osbuild.koji.builder --network org.osbuild.koji \
-v "${SHARE_DIR}:/share:z" \
-v "${DATA_DIR}:/mnt:z" \
-v "${PWD}/container/builder/osbuild-koji.conf:/etc/koji-osbuild/builder.conf:z" \
--hostname org.osbuild.koji.kojid \
--add-host=composer:${GATEWAY_IP} \
koji.builder
${CONTAINER_RUNTIME} run --rm ${CONTAINER_FLAGS} \
--name org.osbuild.koji.builder --network org.osbuild.koji \
-v "${SHARE_DIR}:/share:z" \
-v "${DATA_DIR}:/mnt:z" \
-v "${PWD}/container/builder/osbuild-koji.conf:/etc/koji-osbuild/builder.conf:z" \
--hostname org.osbuild.koji.kojid \
--add-host=composer:${GATEWAY_IP} \
koji.builder
}
builder_stop() {
${CONTAINER_RUNTIME} stop org.osbuild.koji.builder || true
}
# default to running in the background
CONTAINER_FLAGS=-d
if [ $1 == "start" ]; then
builder_start
elif [ $1 == "fg" ]; then
CONTAINER_FLAGS=-it
builder_start
elif [ $1 == "stop" ]; then
builder_stop
fi