Support stages outside of pi-gen dir in docker build
For each stage check if the path is absolute or starts with a `..` If so add a it to the docker instance as a volume. Also modify the STAGE_LIST variable with the paths that will be seen from within the docker container.
This commit is contained in:
parent
f8f3d6fe93
commit
d1e067007a
|
@ -73,11 +73,26 @@ fi
|
||||||
# Modify original build-options to allow config file to be mounted in the docker container
|
# Modify original build-options to allow config file to be mounted in the docker container
|
||||||
BUILD_OPTS="$(echo "${BUILD_OPTS:-}" | sed -E 's@\-c\s?([^ ]+)@-c /config@')"
|
BUILD_OPTS="$(echo "${BUILD_OPTS:-}" | sed -E 's@\-c\s?([^ ]+)@-c /config@')"
|
||||||
|
|
||||||
|
STAGE_LIST_VOLUMES=""
|
||||||
|
STAGE_LIST_DOCKER=""
|
||||||
|
for STAGE in $STAGE_LIST
|
||||||
|
do
|
||||||
|
echo stage: $STAGE
|
||||||
|
if [[ $STAGE = /* || $STAGE = ../* ]] ; then
|
||||||
|
STAGE_LIST_VOLUMES="${STAGE_LIST_VOLUMES} --volume `realpath $STAGE`:/ext-stages/`basename $STAGE`:ro"
|
||||||
|
STAGE_LIST_DOCKER="${STAGE_LIST_DOCKER} /ext-stages/`basename $STAGE`"
|
||||||
|
else
|
||||||
|
STAGE_LIST_DOCKER="${STAGE_LIST_DOCKER} $STAGE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
${DOCKER} build -t pi-gen "${DIR}"
|
${DOCKER} build -t pi-gen "${DIR}"
|
||||||
if [ "${CONTAINER_EXISTS}" != "" ]; then
|
if [ "${CONTAINER_EXISTS}" != "" ]; then
|
||||||
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}_cont' SIGINT SIGTERM
|
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}_cont' SIGINT SIGTERM
|
||||||
time ${DOCKER} run --rm --privileged \
|
time ${DOCKER} run --rm --privileged \
|
||||||
--volume "${CONFIG_FILE}":/config:ro \
|
--volume "${CONFIG_FILE}":/config:ro \
|
||||||
|
${STAGE_LIST_VOLUMES} \
|
||||||
|
-e "STAGE_LIST_DOCKER=${STAGE_LIST_DOCKER}" \
|
||||||
-e "GIT_HASH=${GIT_HASH}" \
|
-e "GIT_HASH=${GIT_HASH}" \
|
||||||
--volumes-from="${CONTAINER_NAME}" --name "${CONTAINER_NAME}_cont" \
|
--volumes-from="${CONTAINER_NAME}" --name "${CONTAINER_NAME}_cont" \
|
||||||
pi-gen \
|
pi-gen \
|
||||||
|
@ -89,6 +104,8 @@ else
|
||||||
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}' SIGINT SIGTERM
|
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}' SIGINT SIGTERM
|
||||||
time ${DOCKER} run --name "${CONTAINER_NAME}" --privileged \
|
time ${DOCKER} run --name "${CONTAINER_NAME}" --privileged \
|
||||||
--volume "${CONFIG_FILE}":/config:ro \
|
--volume "${CONFIG_FILE}":/config:ro \
|
||||||
|
${STAGE_LIST_VOLUMES} \
|
||||||
|
-e "STAGE_LIST_DOCKER=${STAGE_LIST_DOCKER}" \
|
||||||
-e "GIT_HASH=${GIT_HASH}" \
|
-e "GIT_HASH=${GIT_HASH}" \
|
||||||
pi-gen \
|
pi-gen \
|
||||||
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static &&
|
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static &&
|
||||||
|
|
4
build.sh
4
build.sh
|
@ -228,6 +228,10 @@ fi
|
||||||
mkdir -p "${WORK_DIR}"
|
mkdir -p "${WORK_DIR}"
|
||||||
log "Begin ${BASE_DIR}"
|
log "Begin ${BASE_DIR}"
|
||||||
|
|
||||||
|
if [ -v STAGE_LIST_DOCKER ]; then
|
||||||
|
STAGE_LIST=${STAGE_LIST_DOCKER}
|
||||||
|
fi
|
||||||
|
|
||||||
STAGE_LIST=${STAGE_LIST:-${BASE_DIR}/stage*}
|
STAGE_LIST=${STAGE_LIST:-${BASE_DIR}/stage*}
|
||||||
|
|
||||||
for STAGE_DIR in $STAGE_LIST; do
|
for STAGE_DIR in $STAGE_LIST; do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user