-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command line options to build.sh
- Loading branch information
1 parent
5d009c7
commit a6bed0f
Showing
1 changed file
with
41 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |