Skip to content

Commit 459d11d

Browse files
authored
allow script to build for specific architecture (#413)
1 parent 10bcb72 commit 459d11d

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

scripts/build_layers.sh

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ set -e
1515
LAYER_DIR=".layers"
1616
LAYER_FILES_PREFIX="datadog_lambda_py"
1717
AVAILABLE_PYTHON_VERSIONS=("3.8" "3.9" "3.10" "3.11" "3.12")
18+
AVAILABLE_ARCHS=("arm64" "amd64")
19+
20+
if [ -z "$ARCH" ]; then
21+
echo "No architectures specified, building layers for all architectures."
22+
ARCHS=("${AVAILABLE_ARCHS[@]}")
23+
else
24+
echo "Architecture specified: $ARCH"
25+
if [[ ! " ${AVAILABLE_ARCHS[@]} " =~ " ${ARCH} " ]]; then
26+
echo "Architecture $ARCH is not a valid option. Choose from: ${AVAILABLE_ARCHS[@]}"
27+
echo ""
28+
echo "EXITING SCRIPT."
29+
exit 1
30+
fi
31+
ARCHS=$ARCH
32+
fi
1833

1934
# Determine which Python versions to build layers for
2035
if [ -z "$PYTHON_VERSION" ]; then
@@ -64,10 +79,11 @@ mkdir $LAYER_DIR
6479

6580
for python_version in "${PYTHON_VERSIONS[@]}"
6681
do
67-
echo "Building layer for Python ${python_version} arch=arm64"
68-
docker_build_zip ${python_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-arm64-${python_version}.zip arm64
69-
echo "Building layer for Python ${python_version} arch=amd64"
70-
docker_build_zip ${python_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-amd64-${python_version}.zip amd64
82+
for architecture in "${ARCHS[@]}"
83+
do
84+
echo "Building layer for Python ${python_version} arch=${architecture}"
85+
docker_build_zip ${python_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-${architecture}-${python_version}.zip ${architecture}
86+
done
7187
done
7288

7389
echo "Done creating layers:"

0 commit comments

Comments
 (0)