Skip to content

Commit

Permalink
Merge pull request #337 from minrk/docker-build-script
Browse files Browse the repository at this point in the history
use a script instead of piping to stdin in run_docker_build
  • Loading branch information
ocefpaf authored Mar 2, 2018
2 parents 53c2671 + bef0f87 commit 6d479f9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 17 deletions.
1 change: 1 addition & 0 deletions conda_smithy/feedstock_content/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.pyc

build_artifacts
.circleci/build.sh
48 changes: 31 additions & 17 deletions conda_smithy/templates/run_docker_build.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# changes to this script, consider a proposal to conda-smithy so that other feedstocks can also
# benefit from the improvement.

set -e
FEEDSTOCK_ROOT=$(cd "$(dirname "$0")/.."; pwd;)
RECIPE_ROOT=$FEEDSTOCK_ROOT/{{ recipe_dir }}

Expand All @@ -25,6 +26,7 @@ show_channel_urls: true
CONDARC
)


# In order for the conda-build process in the container to write to the mounted
# volumes, we need to run with the same id as the host machine, which is
# normally the owner of the mounted volumes, or at least has write permission
Expand All @@ -37,19 +39,15 @@ fi

rm -f "$FEEDSTOCK_ROOT/build_artifacts/conda-forge-build-done"

cat << EOF | {{ docker.executable }} run -i \
-v "${RECIPE_ROOT}":/home/conda/recipe_root \
-v "${FEEDSTOCK_ROOT}":/home/conda/feedstock_root \
-e CONFIG="$CONFIG" \
-e HOST_USER_ID="${HOST_USER_ID}" \
-a stdin -a stdout -a stderr \
{{ docker.image }} \
{{ docker.command }} || exit 1
ARTIFACTS="$FEEDSTOCK_ROOT/build_artifacts"

test -d "$ARTIFACTS" || mkdir "$ARTIFACTS"
DONE_CANARY="$ARTIFACTS/conda-forge-build-done"
rm -f "$DONE_CANARY"

cat << EOF > "$FEEDSTOCK_ROOT/.circleci/build.sh"
set -e
set +x
export BINSTAR_TOKEN=${BINSTAR_TOKEN}
set -x
export PYTHONUNBUFFERED=1
echo "$config" > ~/.condarc
Expand All @@ -60,17 +58,33 @@ conda install --yes --quiet conda-forge-ci-setup=1
{% if build_setup -%}
{{ build_setup }}{% endif -%}
conda build /home/conda/recipe_root -m /home/conda/feedstock_root/.ci_support/${CONFIG}.yaml --quiet || exit 1
conda build /home/conda/recipe_root -m /home/conda/feedstock_root/.ci_support/${CONFIG}.yaml --quiet
{%- for owner, channel in channels['targets'] %}
{{ upload_script }} /home/conda/recipe_root {{ owner }} --channel={{ channel }} -m /home/conda/feedstock_root/.ci_support/${CONFIG}.yaml || exit 1
{{ upload_script }} /home/conda/recipe_root {{ owner }} --channel={{ channel }} -m /home/conda/feedstock_root/.ci_support/${CONFIG}.yaml
{%- endfor %}
touch /home/conda/feedstock_root/build_artifacts/conda-forge-build-done
EOF

# double-check that the build got to the end
# see https://github.com/conda-forge/conda-smithy/pull/337
# for a possible fix
set +x
echo "BINSTAR_TOKEN=${BINSTAR_TOKEN}" > "${FEEDSTOCK_ROOT}/env"
set -x
test -f "$FEEDSTOCK_ROOT/build_artifacts/conda-forge-build-done" || exit 1

# Create and run the container in two commands,
# so the token env isn't on disk too long

CONTAINER=$(docker create -t \
-v "${RECIPE_ROOT}":/home/conda/recipe_root \
-v "${FEEDSTOCK_ROOT}":/home/conda/feedstock_root \
--env-file ${FEEDSTOCK_ROOT}/env \
-e HOST_USER_ID="${HOST_USER_ID}" \
{{ docker.image }} \
{{ docker.command }} \
/home/conda/feedstock_root/.circleci/build.sh || exit $?)

rm "${FEEDSTOCK_ROOT}/env"
# do it
docker start -i $CONTAINER

# verify that the end of the script was reached
test -f "$DONE_CANARY"

0 comments on commit 6d479f9

Please sign in to comment.