Skip to content

chore: allow builds to use specified architecture #413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions scripts/build_layers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ set -e
LAYER_DIR=".layers"
LAYER_FILES_PREFIX="datadog_lambda_py"
AVAILABLE_PYTHON_VERSIONS=("3.8" "3.9" "3.10" "3.11" "3.12")
AVAILABLE_ARCHS=("arm64" "amd64")

if [ -z "$ARCH" ]; then
echo "No architectures specified, building layers for all architectures."
ARCHS=("${AVAILABLE_ARCHS[@]}")
else
echo "Architecture specified: $ARCH"
if [[ ! " ${AVAILABLE_ARCHS[@]} " =~ " ${ARCH} " ]]; then
echo "Architecture $ARCH is not a valid option. Choose from: ${AVAILABLE_ARCHS[@]}"
echo ""
echo "EXITING SCRIPT."
exit 1
fi
ARCHS=$ARCH
fi

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

for python_version in "${PYTHON_VERSIONS[@]}"
do
echo "Building layer for Python ${python_version} arch=arm64"
docker_build_zip ${python_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-arm64-${python_version}.zip arm64
echo "Building layer for Python ${python_version} arch=amd64"
docker_build_zip ${python_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-amd64-${python_version}.zip amd64
for architecture in "${ARCHS[@]}"
do
echo "Building layer for Python ${python_version} arch=${architecture}"
docker_build_zip ${python_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-${architecture}-${python_version}.zip ${architecture}
done
done

echo "Done creating layers:"
Expand Down