1
0
mirror of synced 2026-01-05 03:04:38 -05:00
Files
airbyte/tools/bin/build_image.sh
girarda fd13ab1970 Fix CONNECTORS_BASE build for M1 (#10925)
* Pass in arm64

* default value

* fix
2022-03-07 17:30:41 -08:00

52 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
ROOT_DIR="$1"
PROJECT_DIR="$2"
DOCKERFILE="$3"
TAGGED_IMAGE="$4"
ID_FILE="$5"
FOLLOW_SYMLINKS="$6"
DOCKER_BUILD_ARCH="${DOCKER_BUILD_ARCH:-amd64}"
# https://docs.docker.com/develop/develop-images/build_enhancements/
export DOCKER_BUILDKIT=1
cd "$ROOT_DIR"
. tools/lib/lib.sh
assert_root
cd "$PROJECT_DIR"
function validate_dockerignore() {
excludes_all=$(grep -w '^\*$' .dockerignore)
excludes_except=$(grep -w '^!.*' .dockerignore)
if [ -n "$excludes_all" ] || [ -n "$excludes_except" ]; then
error "Cannot include exclusion exceptions when following symlinks. Please use an exclude pattern that doesn't use exclude-all (e.g: *) or exclude-except (e.g: !/some/pattern)"
fi
}
args=(
-f "$DOCKERFILE"
-t "$TAGGED_IMAGE"
--iidfile "$ID_FILE"
)
if [ "$FOLLOW_SYMLINKS" == "true" ]; then
exclusions=()
if [ -f ".dockerignore" ]; then
validate_dockerignore
exclusions+=(--exclude-from .dockerignore)
fi
# Docker does not follow symlinks in the build context. So we create a tar of the directory, following symlinks, and provide the archive to Docker
# to use as the build context
tar cL "${exclusions[@]}" . | docker build - "${args[@]}"
else
JDK_VERSION="${JDK_VERSION:-17.0.1}"
if [[ -z "${DOCKER_BUILD_PLATFORM}" ]]; then
docker build --build-arg JDK_VERSION="$JDK_VERSION" --build-arg DOCKER_BUILD_ARCH="$DOCKER_BUILD_ARCH" . "${args[@]}"
else
docker build --build-arg JDK_VERSION="$JDK_VERSION" --build-arg DOCKER_BUILD_ARCH="$DOCKER_BUILD_ARCH" --platform="$DOCKER_BUILD_PLATFORM" . "${args[@]}"
fi
fi