forked from conda-forge/griddataformats-feedstock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_docker_build.sh
More file actions
executable file
·135 lines (109 loc) · 4.48 KB
/
Copy pathrun_docker_build.sh
File metadata and controls
executable file
·135 lines (109 loc) · 4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env bash
# PLEASE NOTE: This script has been automatically generated by conda-smithy. Any changes here
# will be lost next time ``conda smithy rerender`` is run. If you would like to make permanent
# changes to this script, consider a proposal to conda-smithy so that other feedstocks can also
# benefit from the improvement.
source .scripts/logging_utils.sh
( startgroup "Configure Docker" ) 2> /dev/null
set -xeo pipefail
DOCKER_EXECUTABLE="${DOCKER_EXECUTABLE:-docker}"
THISDIR="$( cd "$( dirname "$0" )" >/dev/null && pwd )"
PROVIDER_DIR="$(basename "$THISDIR")"
FEEDSTOCK_ROOT="$( cd "$( dirname "$0" )/.." >/dev/null && pwd )"
RECIPE_ROOT="${FEEDSTOCK_ROOT}/recipe"
if [ -z ${FEEDSTOCK_NAME} ]; then
export FEEDSTOCK_NAME=$(basename ${FEEDSTOCK_ROOT})
fi
if [[ "${sha:-}" == "" ]]; then
pushd "${FEEDSTOCK_ROOT}"
sha=$(git rev-parse HEAD)
popd
fi
${DOCKER_EXECUTABLE} info
# 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
export HOST_USER_ID=$(id -u)
# Check if docker-machine is being used (normally on OSX) and get the uid from
# the VM
if hash docker-machine 2> /dev/null && docker-machine active > /dev/null; then
export HOST_USER_ID=$(docker-machine ssh $(docker-machine active) id -u)
fi
ARTIFACTS="$FEEDSTOCK_ROOT/build_artifacts"
if [ -z "$CONFIG" ]; then
set +x
FILES=`ls .ci_support/linux_*`
CONFIGS=""
for file in $FILES; do
CONFIGS="${CONFIGS}'${file:12:-5}' or ";
done
echo "Need to set CONFIG env variable. Value can be one of ${CONFIGS:0:-4}"
exit 1
fi
if [ -z "${DOCKER_IMAGE}" ]; then
SHYAML_INSTALLED="$(shyaml -h || echo NO)"
if [ "${SHYAML_INSTALLED}" == "NO" ]; then
echo "WARNING: DOCKER_IMAGE variable not set and shyaml not installed. Trying to parse with coreutils"
DOCKER_IMAGE=$(cat .ci_support/${CONFIG}.yaml | grep '^docker_image:$' -A 1 | tail -n 1 | cut -b 3-)
if [ "${DOCKER_IMAGE}" = "" ]; then
echo "No docker_image entry found in ${CONFIG}. Falling back to quay.io/condaforge/linux-anvil-comp7"
DOCKER_IMAGE="quay.io/condaforge/linux-anvil-comp7"
fi
else
DOCKER_IMAGE="$(cat "${FEEDSTOCK_ROOT}/.ci_support/${CONFIG}.yaml" | shyaml get-value docker_image.0 quay.io/condaforge/linux-anvil-comp7 )"
fi
fi
mkdir -p "$ARTIFACTS"
DONE_CANARY="$ARTIFACTS/conda-forge-build-done-${CONFIG}"
rm -f "$DONE_CANARY"
# Allow people to specify extra default arguments to `docker run` (e.g. `--rm`)
DOCKER_RUN_ARGS="${CONDA_FORGE_DOCKER_RUN_ARGS}"
if [ -z "${CI}" ]; then
DOCKER_RUN_ARGS="-it ${DOCKER_RUN_ARGS}"
fi
# Default volume suffix for Docker (preserve original behavior)
VOLUME_SUFFIX=",z"
# Podman-specific handling
if [ "${DOCKER_EXECUTABLE}" = "podman" ]; then
# Fix file permissions for rootless podman builds
podman unshare chown -R ${HOST_USER_ID}:${HOST_USER_ID} "${ARTIFACTS}"
podman unshare chown -R ${HOST_USER_ID}:${HOST_USER_ID} "${RECIPE_ROOT}"
# Add SELinux label only if enforcing
if command -v getenforce &>/dev/null && [ "$(getenforce)" = "Enforcing" ]; then
VOLUME_SUFFIX=",z"
else
VOLUME_SUFFIX=""
fi
fi
( endgroup "Configure Docker" ) 2> /dev/null
( startgroup "Start Docker" ) 2> /dev/null
export UPLOAD_PACKAGES="${UPLOAD_PACKAGES:-True}"
export IS_PR_BUILD="${IS_PR_BUILD:-False}"
${DOCKER_EXECUTABLE} pull "${DOCKER_IMAGE}"
${DOCKER_EXECUTABLE} run ${DOCKER_RUN_ARGS} \
-v "${RECIPE_ROOT}":/home/conda/recipe_root:rw${VOLUME_SUFFIX},delegated \
-v "${FEEDSTOCK_ROOT}":/home/conda/feedstock_root:rw${VOLUME_SUFFIX},delegated \
-e CONFIG \
-e HOST_USER_ID \
-e UPLOAD_PACKAGES \
-e IS_PR_BUILD \
-e GIT_BRANCH \
-e UPLOAD_ON_BRANCH \
-e CI \
-e FEEDSTOCK_NAME \
-e CPU_COUNT \
-e BUILD_WITH_CONDA_DEBUG \
-e BUILD_OUTPUT_ID \
-e flow_run_id \
-e remote_url \
-e sha \
-e BINSTAR_TOKEN \
-e FEEDSTOCK_TOKEN \
-e STAGING_BINSTAR_TOKEN \
"${DOCKER_IMAGE}" \
bash \
"/home/conda/feedstock_root/${PROVIDER_DIR}/build_steps.sh"
# verify that the end of the script was reached
test -f "$DONE_CANARY"
# This closes the last group opened in `build_steps.sh`
( endgroup "Final checks" ) 2> /dev/null