Skip to content

Commit

Permalink
Add command line options to build.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
madelen-at-work committed Mar 20, 2024
1 parent 5d009c7 commit a6bed0f
Showing 1 changed file with 41 additions and 11 deletions.
52 changes: 41 additions & 11 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,51 @@
#!/bin/sh -eu
case "${1:-}" in
armv7hf | aarch64) ;;
*)
# error
echo "Invalid argument '${1:-}', valid arguments are armv7hf or aarch64"
#!/bin/bash -eu

imagetag="docker-acap-with-compose:1.0"

function exit_with_message {
echo "$1"
echo
echo "Usage: $0 ARCH [ --plain ] [ --cache ] [ --image-tag IMAGETAG ]"
echo
echo "ARCH must be 'armv7hf' or 'aarch64'"
echo "--plain will simplify the Docker progress bar."
echo "--cache will enable Docker's caching mechanism."
echo "--image-tag sets the supplied tag of the image. Default is $imagetag."
exit 1
;;
}

arch="${1:-}"

case "$arch" in
armv7hf | aarch64) ;;
*) exit_with_message "Invalid architecture '$arch'" ;;
esac
shift

progress_arg=
cache_arg=--no-cache

imagetag="${2:-docker-acap-with-compose:1.0}"
while (($#)); do
case "$1" in
--plain) progress_arg="--progress plain" ;;
--cache) cache_arg= ;;
--image-tag)
shift
imagetag="$1"
;;
*) exit_with_message "Invalid argument '$1'" ;;
esac
shift
done

# Build and copy out the acap
docker buildx build --build-arg ACAPARCH="$1" \
# shellcheck disable=SC2086
docker buildx build --build-arg ACAPARCH="$arch" \
--build-arg HTTP_PROXY="${HTTP_PROXY:-}" \
--build-arg HTTPS_PROXY="${HTTPS_PROXY:-}" \
--file Dockerfile \
--no-cache \
$progress_arg \
$cache_arg \
--tag "$imagetag" .

docker cp "$(docker create "$imagetag")":/opt/app/ ./build-"$1"
docker cp "$(docker create "$imagetag")":/opt/app/ ./build-"$arch"

0 comments on commit a6bed0f

Please sign in to comment.