From 622c0a46c98fab29aa9b0a88d9ddc3f2dc41bc86 Mon Sep 17 00:00:00 2001 From: Guy Taylor Date: Mon, 9 Jul 2018 17:46:04 +0100 Subject: [PATCH] Output files from Docker using the current user --- docker-build.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docker-build.sh b/docker-build.sh index 1748b44..a8259d4 100755 --- a/docker-build.sh +++ b/docker-build.sh @@ -9,21 +9,28 @@ set -o pipefail # Use last non-zero exit code in a pipeline DISTRIBUTION=${1} DOCKER_IMAGE_NANE="piaware-builder:${DISTRIBUTION}" -DOCKER_CONTINAER_NANE='piaware-builder' +DOCKER_CONTINAER_NANE="piaware-builder-${DISTRIBUTION}" # build builder image docker build --tag "${DOCKER_IMAGE_NANE}" --file "Dockerfile-${DISTRIBUTION}" . +# Setup the build env mkdir -p "package-${DISTRIBUTION}" docker run --rm -it --name "${DOCKER_CONTINAER_NANE}" \ + -u="${UID}:$(id -g ${USER})" -v '/etc/group:/etc/group:ro' -v '/etc/passwd:/etc/passwd:ro' \ -v "${PWD}:/build:ro" \ -v "${PWD}/package-${DISTRIBUTION}:/build/package-${DISTRIBUTION}:rw" \ --workdir="/build" "${DOCKER_IMAGE_NANE}" \ ./sensible-build.sh "${DISTRIBUTION}" +# build the deb packages mkdir -p "debs-${DISTRIBUTION}" docker run --rm -it --name "${DOCKER_CONTINAER_NANE}" \ + -u="${UID}:$(id -g ${USER})" -v '/etc/group:/etc/group:ro' -v '/etc/passwd:/etc/passwd:ro' \ -v "${PWD}/debs-${DISTRIBUTION}:/build:rw" \ -v "${PWD}/package-${DISTRIBUTION}:/build/package-${DISTRIBUTION}:rw" \ --workdir="/build/package-${DISTRIBUTION}" \ "${DOCKER_IMAGE_NANE}" dpkg-buildpackage -b + +rm -rf "package-${DISTRIBUTION}" +rm -rf "debs-${DISTRIBUTION}/package-${DISTRIBUTION}"