DRY removal for docker run command line (#686)
Factor out the differences into variables so that there is only one implementation of the "docker run" command line to maintain.
This commit is contained in:
parent
0db41e35ef
commit
b8437a77ba
@ -92,40 +92,43 @@ esac
|
||||
${DOCKER} build --build-arg BASE_IMAGE=${BASE_IMAGE} -t pi-gen "${DIR}"
|
||||
|
||||
if [ "${CONTAINER_EXISTS}" != "" ]; then
|
||||
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}_cont' SIGINT SIGTERM
|
||||
time ${DOCKER} run --rm --privileged \
|
||||
--cap-add=ALL \
|
||||
-v /dev:/dev \
|
||||
-v /lib/modules:/lib/modules \
|
||||
${PIGEN_DOCKER_OPTS} \
|
||||
--volume "${CONFIG_FILE}":/config:ro \
|
||||
-e "GIT_HASH=${GIT_HASH}" \
|
||||
--volumes-from="${CONTAINER_NAME}" --name "${CONTAINER_NAME}_cont" \
|
||||
pi-gen \
|
||||
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static &&
|
||||
# binfmt_misc is sometimes not mounted with debian bullseye image
|
||||
(mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc || true) &&
|
||||
cd /pi-gen; ./build.sh ${BUILD_OPTS} &&
|
||||
rsync -av work/*/build.log deploy/" &
|
||||
wait "$!"
|
||||
DOCKER_CMDLINE_NAME="${CONTAINER_NAME}_cont"
|
||||
DOCKER_CMDLINE_PRE=( \
|
||||
--rm \
|
||||
)
|
||||
DOCKER_CMDLINE_POST=( \
|
||||
--volumes-from="${CONTAINER_NAME}" \
|
||||
)
|
||||
else
|
||||
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}' SIGINT SIGTERM
|
||||
time ${DOCKER} run --name "${CONTAINER_NAME}" --privileged \
|
||||
--cap-add=ALL \
|
||||
-v /dev:/dev \
|
||||
-v /lib/modules:/lib/modules \
|
||||
${PIGEN_DOCKER_OPTS} \
|
||||
--volume "${CONFIG_FILE}":/config:ro \
|
||||
-e "GIT_HASH=${GIT_HASH}" \
|
||||
pi-gen \
|
||||
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static &&
|
||||
# binfmt_misc is sometimes not mounted with debian bullseye image
|
||||
(mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc || true) &&
|
||||
cd /pi-gen; ./build.sh ${BUILD_OPTS} &&
|
||||
rsync -av work/*/build.log deploy/" &
|
||||
wait "$!"
|
||||
DOCKER_CMDLINE_NAME="${CONTAINER_NAME}"
|
||||
DOCKER_CMDLINE_PRE=( \
|
||||
)
|
||||
DOCKER_CMDLINE_POST=( \
|
||||
)
|
||||
fi
|
||||
|
||||
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${DOCKER_CMDLINE_NAME}' SIGINT SIGTERM
|
||||
time ${DOCKER} run \
|
||||
"${DOCKER_CMDLINE_PRE[@]}" \
|
||||
--name "${DOCKER_CMDLINE_NAME}" \
|
||||
--privileged \
|
||||
--cap-add=ALL \
|
||||
-v /dev:/dev \
|
||||
-v /lib/modules:/lib/modules \
|
||||
${PIGEN_DOCKER_OPTS} \
|
||||
--volume "${CONFIG_FILE}":/config:ro \
|
||||
-e "GIT_HASH=${GIT_HASH}" \
|
||||
"${DOCKER_CMDLINE_POST[@]}" \
|
||||
pi-gen \
|
||||
bash -e -o pipefail -c "
|
||||
dpkg-reconfigure qemu-user-static &&
|
||||
# binfmt_misc is sometimes not mounted with debian bullseye image
|
||||
(mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc || true) &&
|
||||
cd /pi-gen; ./build.sh ${BUILD_OPTS} &&
|
||||
rsync -av work/*/build.log deploy/
|
||||
" &
|
||||
wait "$!"
|
||||
|
||||
# Ensure that deploy/ is always owned by calling user
|
||||
echo "copying results from deploy/"
|
||||
${DOCKER} cp "${CONTAINER_NAME}":/pi-gen/deploy - | tar -xf -
|
||||
|
Loading…
x
Reference in New Issue
Block a user