Skip to content

Commit aab590e

Browse files
committed
refactor to only do docker build once
1 parent a95762e commit aab590e

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

scripts/build_layers.sh

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,12 @@ function search_wheel {
115115
fi
116116
}
117117

118-
function docker_build_zip {
119-
# Args: [python version] [zip destination] [wheel base name] [index]
118+
function find_and_spec_wheel {
119+
# Args: [python version] [wheel base name] [index]
120120

121-
destination=$(make_path_absolute $2)
122-
arch=$3
123-
wheel_basename=$4
124-
index=$5
121+
arch=$2
122+
wheel_basename=$3
123+
index=$4
125124

126125
# Restore pyproject.toml to a clean state for each build iteration
127126
cp pyproject.toml.bak pyproject.toml
@@ -147,6 +146,13 @@ function docker_build_zip {
147146
fi
148147
fi
149148

149+
}
150+
151+
function docker_build_zip {
152+
# Args: [python version] [zip destination]
153+
154+
destination=$(make_path_absolute $2)
155+
arch=$3
150156
# Install datadogpy in a docker container to avoid the mess from switching
151157
# between different python runtimes.
152158
temp_dir=$(mktemp -d)
@@ -172,11 +178,12 @@ do
172178
for architecture in "${ARCHS[@]}"
173179
do
174180
echo "Building layer for Python ${python_version} arch=${architecture}"
175-
docker_build_zip ${python_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-${architecture}-${python_version}.zip ${architecture} "ddtrace_serverless" "serverless" || true
181+
find_and_spec_wheel ${python_version} ${architecture} "ddtrace_serverless" "serverless"
176182
if [ $? != 0 ]; then
177183
echo "Attempting layer build again with package ddtrace"
178-
docker_build_zip ${python_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-${architecture}-${python_version}.zip ${architecture} "ddtrace" "manylinux2014"
184+
find_and_spec_wheel ${python_version} ${architecture} "ddtrace" "manylinux2014"
179185
fi
186+
docker_build_zip ${python_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-${architecture}-${python_version}.zip ${architecture}
180187
done
181188
done
182189

0 commit comments

Comments
 (0)