@@ -40,17 +40,21 @@ function docker_build_zip {
4040 # Args: [python version] [zip destination]
4141
4242 destination=$( make_path_absolute $2 )
43+ arch=$3
4344
4445 # Install datadogpy in a docker container to avoid the mess from switching
4546 # between different python runtimes.
4647 temp_dir=$( mktemp -d)
47- docker build -t datadog-lambda-python:$1 . --no-cache \
48+ docker buildx build -t datadog-lambda-python- ${arch} :$1 . --no-cache \
4849 --build-arg image=python:$1 \
49- --build-arg runtime=python$1
50+ --build-arg runtime=python$1 \
51+ --platform linux/${arch} \
52+ --load
5053
5154 # Run the image by runtime tag, tar its generatd `python` directory to sdout,
5255 # then extract it to a temp directory.
53- docker run datadog-lambda-python:$1 tar cf - python | tar -xf - -C $temp_dir
56+ docker run datadog-lambda-python-${arch} :$1 tar cf - python | tar -xf - -C $temp_dir
57+
5458
5559 # Zip to destination, and keep directory structure as based in $temp_dir
5660 (cd $temp_dir && zip -q -r $destination ./)
@@ -64,8 +68,12 @@ mkdir $LAYER_DIR
6468
6569for python_version in " ${PYTHON_VERSIONS[@]} "
6670do
67- echo " Building layer for Python ${python_version} "
68- docker_build_zip ${python_version} $LAYER_DIR /${LAYER_FILES_PREFIX}${python_version} .zip
71+ if [ " $python_version " == " 3.8" ] || [ " $python_version " == " 3.9" ]; then
72+ echo " Building layer for Python ${python_version} arch=arm64"
73+ docker_build_zip ${python_version} $LAYER_DIR /${LAYER_FILES_PREFIX} -arm64-${python_version} .zip arm64
74+ fi
75+ echo " Building layer for Python ${python_version} arch=amd64"
76+ docker_build_zip ${python_version} $LAYER_DIR /${LAYER_FILES_PREFIX} -amd64-${python_version} .zip amd64
6977done
7078
7179echo " Done creating layers:"
0 commit comments