From e4e7b90bf3bdacd80c2df2d050bd1f51184564c7 Mon Sep 17 00:00:00 2001 From: David Lee Date: Wed, 16 Aug 2023 09:56:09 -0700 Subject: [PATCH] Support building extension images for alpine (#162) --- scripts/Dockerfile.alpine | 4 ++++ scripts/build_and_push_docker_image.sh | 13 ++++++++++--- scripts/build_binary_and_layer_dockerized.sh | 7 +++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 scripts/Dockerfile.alpine diff --git a/scripts/Dockerfile.alpine b/scripts/Dockerfile.alpine new file mode 100644 index 00000000..37a4e29e --- /dev/null +++ b/scripts/Dockerfile.alpine @@ -0,0 +1,4 @@ +FROM scratch +ARG TARGETARCH +COPY .layers/datadog_extension-$TARGETARCH-alpine/extensions/datadog-agent opt/extensions/datadog-agent +COPY --chmod=0755 scripts/datadog_wrapper opt/datadog_wrapper diff --git a/scripts/build_and_push_docker_image.sh b/scripts/build_and_push_docker_image.sh index 673ef5c6..9153ff12 100755 --- a/scripts/build_and_push_docker_image.sh +++ b/scripts/build_and_push_docker_image.sh @@ -10,7 +10,6 @@ set -e DOCKER_REPOSITORY_NAME="datadog/lambda-extension" -DOCKERFILE_LOCATION="scripts/Dockerfile" # Move into the root directory, so this script can be called from any directory SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" @@ -24,10 +23,18 @@ if [ -z "$VERSION" ]; then fi # Build the image, tagged with the version -echo "Building the Docker image, and pushing to Dockerhub" +echo "Building the non-alpine Docker image, and pushing to Dockerhub" docker buildx build --platform linux/arm64,linux/amd64 \ -t $DOCKER_REPOSITORY_NAME:$VERSION \ -t $DOCKER_REPOSITORY_NAME:latest \ -f ./scripts/Dockerfile \ --build-arg EXTENSION_VERSION="${VERSION}" . \ - --push \ No newline at end of file + --push + +echo "Building the alpine Docker image, and pushing to Dockerhub" +docker buildx build --platform linux/arm64,linux/amd64 \ + -t $DOCKER_REPOSITORY_NAME:$VERSION-alpine \ + -t $DOCKER_REPOSITORY_NAME:latest-alpine \ + -f ./scripts/Dockerfile.alpine \ + --build-arg EXTENSION_VERSION="${VERSION}" . \ + --push diff --git a/scripts/build_binary_and_layer_dockerized.sh b/scripts/build_binary_and_layer_dockerized.sh index 0abbf1f2..334cc2a0 100755 --- a/scripts/build_binary_and_layer_dockerized.sh +++ b/scripts/build_binary_and_layer_dockerized.sh @@ -89,11 +89,18 @@ if [ "$SERVERLESS_INIT" == "true" ]; then elif [ "$ARCHITECTURE" == "amd64" ]; then echo "Building for amd64 only" docker_build_zip amd64 + BUILD_FILE=Dockerfile.alpine.build + docker_build_zip amd64 -alpine elif [ "$ARCHITECTURE" == "arm64" ]; then echo "Building for arm64 only" docker_build_zip arm64 + BUILD_FILE=Dockerfile.alpine.build + docker_build_zip arm64 -alpine else echo "Building for both amd64 and arm64" docker_build_zip amd64 docker_build_zip arm64 + BUILD_FILE=Dockerfile.alpine.build + docker_build_zip amd64 -alpine + docker_build_zip arm64 -alpine fi