Skip to content

Commit

Permalink
Add support to choose docker build target architecture (#1350)
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Gomez Ferrer <andresg@spotify.com>
Signed-off-by: Hongxin Liang <honnix@users.noreply.github.com>
  • Loading branch information
andresgomezfrr authored Dec 1, 2022
1 parent fb10e4b commit 7994f47
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions flytekit_scripts/flytekit_build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,20 @@ if [ -n "$REGISTRY" ]; then
else
FLYTE_INTERNAL_IMAGE=${IMAGE_NAME}:${PREFIX}${TAG}
fi
echo "Building: $FLYTE_INTERNAL_IMAGE"

DOCKER_PLATFORM_OPT=()
# Check if the user set the target build architecture, if not use the default instead.
if [ -n "$TARGET_PLATFORM_BUILD" ]; then
DOCKER_PLATFORM_OPT=(--platform "$TARGET_PLATFORM_BUILD")
else
TARGET_PLATFORM_BUILD="default"
fi

echo "Building: $FLYTE_INTERNAL_IMAGE for $TARGET_PLATFORM_BUILD architecture"

# This build command is the raison d'etre of this script, it ensures that the version is injected into the image itself
docker build . --build-arg tag="$FLYTE_INTERNAL_IMAGE" -t "$FLYTE_INTERNAL_IMAGE" -f "${DOCKERFILE_PATH}"
docker build . "${DOCKER_PLATFORM_OPT[@]}" --build-arg tag="${FLYTE_INTERNAL_IMAGE}" -t "${FLYTE_INTERNAL_IMAGE}" -f "${DOCKERFILE_PATH}"

echo "$IMAGE_NAME built locally."

# Create the appropriate tags
Expand Down

0 comments on commit 7994f47

Please sign in to comment.