Add scripts for building/pushing to docker registry
This commit is contained in:
55
scripts/docker_build.sh
Executable file
55
scripts/docker_build.sh
Executable file
@@ -0,0 +1,55 @@
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage:
|
||||
docker_build.sh <target> <registry> [<args>]
|
||||
docker_build.sh -h
|
||||
|
||||
Build and push a docker image to a arm64v8 registry
|
||||
|
||||
Targets:
|
||||
base The pacakges aimed at running on the raspberry pi
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
TARGET="$1"
|
||||
REGISTRY="$2"
|
||||
ARGS="$2"
|
||||
|
||||
if [[ $TARGET == "-h" || $TARGET == "--help" ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ $# -lt 2 ]]; then
|
||||
echo "Error: Expected at least 2 arguments."
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
|
||||
|
||||
case $TARGET in
|
||||
"base_env")
|
||||
ssh -N \
|
||||
-o StrictHostKeyChecking=no \
|
||||
-o UserKnownHostsFile=/dev/null \
|
||||
-L *:5000:localhost:5000 \
|
||||
$REGISTRY &
|
||||
|
||||
echo "Building target: base"
|
||||
|
||||
sudo docker buildx build \
|
||||
--platform linux/arm64 \
|
||||
-t host.docker.internal:5000/magrob.env:latest \
|
||||
-f Dockerfile.env \
|
||||
--output type=registry \
|
||||
.
|
||||
;;
|
||||
*)
|
||||
echo "Target not defined"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
Reference in New Issue
Block a user