Factor some complexity out of the Dockerfile for easier reuse

This commit is contained in:
Jean-Paul Calderone 2019-04-04 12:50:05 -04:00
parent 99f0dad02b
commit 2896370880
2 changed files with 25 additions and 4 deletions

@ -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}"

24
.circleci/prepare-image.sh Executable file

@ -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}"