From 2896370880ea67a940c09e4c8fca2d5f71aa8ac5 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Thu, 4 Apr 2019 12:50:05 -0400 Subject: [PATCH] Factor some complexity out of the Dockerfile for easier reuse --- .circleci/Dockerfile.debian-8 | 5 +---- .circleci/prepare-image.sh | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100755 .circleci/prepare-image.sh diff --git a/.circleci/Dockerfile.debian-8 b/.circleci/Dockerfile.debian-8 index 11e6e93ec..ae6845d73 100644 --- a/.circleci/Dockerfile.debian-8 +++ b/.circleci/Dockerfile.debian-8 @@ -21,7 +21,4 @@ RUN apt-get --quiet update && \ # cache friendly but there's no Docker layer cache on CircleCI anyway! COPY . ${BUILD_SRC_ROOT} -RUN usermod --home /tmp/nobody nobody -RUN chown --recursive nobody:nogroup "${BUILD_SRC_ROOT}" -RUN sudo --set-home -u nobody "${BUILD_SRC_ROOT}"/.circleci/create-virtualenv.sh "${WHEELHOUSE_PATH}" "${VIRTUALENV_PATH}" -RUN sudo --set-home -u nobody "${BUILD_SRC_ROOT}"/.circleci/populate-wheelhouse.sh "${WHEELHOUSE_PATH}" "${VIRTUALENV_PATH}" "${BUILD_SRC_ROOT}" +RUN "${BUILD_SRC_ROOT}"/.circleci/prepare-image.sh "${WHEELHOUSE_PATH}" "${VIRTUALENV_PATH}" "${BUILD_SRC_ROOT}" diff --git a/.circleci/prepare-image.sh b/.circleci/prepare-image.sh new file mode 100755 index 000000000..6b85b251a --- /dev/null +++ b/.circleci/prepare-image.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +set -euxo pipefail + +# The filesystem location of the wheelhouse which we'll populate with wheels +# for all of our dependencies. +WHEELHOUSE_PATH="$1" +shift + +# The filesystem location of the root of a virtualenv we can use to get/build +# wheels. +BOOTSTRAP_VENV="$1" +shift + +# The filesystem location of the root of the project source. We need this to +# know what wheels to get/build, of course. +PROJECT_ROOT="$1" +shift + +usermod --home /tmp/nobody nobody +chown --recursive nobody:nogroup "${PROJECT_ROOT}" +sudo --set-home -u nobody "${PROJECT_ROOT}"/.circleci/create-virtualenv.sh "${WHEELHOUSE_PATH}" "${BOOTSTRAP_VENV}" +sudo --set-home -u nobody "${PROJECT_ROOT}"/.circleci/populate-wheelhouse.sh "${WHEELHOUSE_PATH}" "${BOOTSTRAP_VENV}" "${PROJECT_ROOT}"