Add scripts for building/pushing to docker registry

This commit is contained in:
2026-01-05 03:13:34 +01:00
parent fe52c5ea80
commit 32a395f7e6
6 changed files with 98 additions and 6 deletions

55
scripts/docker_build.sh Executable file
View 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

17
scripts/install_base_deps.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
ros_distro="jazzy"
script_dir=$(dirname "$(readlink -f "${bash_source[0]}")")
source "/opt/ros/${ROS_DISTRO}/setup.bash"
apt update
apt-get install -y ros-jazzy-hardware-interface # For some reason this package is problamatic
rosdep install -i -y \
--from-paths ./mg_bringup \
--from-paths ./mg_msgs \
--from-paths ./mg_navigation \
--from-paths ./mg_control \
--from-paths ./mg_odometry \
--from-paths ./mg_obstacles \
--from-paths ./mg_lidar