Skip to content

Commit

Permalink
Output files from Docker using the current user
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBiggerGuy committed Jul 9, 2018
1 parent 7f3742b commit 622c0a4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

0 comments on commit 622c0a4

Please sign in to comment.