Add scripts for building/pushing to docker registry
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
FROM arm64v8/ros:jazzy as magrob.env
|
FROM arm64v8/ros:jazzy-ros-core AS magrob.base.env
|
||||||
|
|
||||||
RUN mkdir -p /ros_ws/src
|
RUN mkdir -p /ros_ws/src
|
||||||
WORKDIR /ros_ws/src
|
WORKDIR /ros_ws/src
|
||||||
@@ -7,9 +7,7 @@ RUN --mount=type=bind,source=./,target=/ros_ws/src/ \
|
|||||||
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||||
. /opt/ros/jazzy/setup.sh && \
|
. /opt/ros/jazzy/setup.sh && \
|
||||||
apt update && \
|
scripts/install_base_deps.sh
|
||||||
apt-get install -y ros-jazzy-hardware-interface && \
|
|
||||||
rosdep install -i --from-paths . -y
|
|
||||||
|
|
||||||
RUN cat <<EOF >> /root/.bashrc
|
RUN cat <<EOF >> /root/.bashrc
|
||||||
source /opt/ros/jazzy/setup.bash
|
source /opt/ros/jazzy/setup.bash
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
services:
|
services:
|
||||||
magrob_base:
|
magrob_base:
|
||||||
network_mode: host
|
network_mode: host
|
||||||
image: localhost/magrob.env
|
image: localhost/magrob.base.env
|
||||||
build:
|
build:
|
||||||
dockerfile: Dockerfile.env
|
dockerfile: Dockerfile.base.env
|
||||||
|
|
||||||
entrypoint: ["sleep","infinity"]
|
entrypoint: ["sleep","infinity"]
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
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
|
||||||
|
|
||||||
|
|
||||||
17
scripts/install_base_deps.sh
Executable file
17
scripts/install_base_deps.sh
Executable 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
|
||||||
9
util/docker_registry/config/config.yml
Normal file
9
util/docker_registry/config/config.yml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
version: 0.1
|
||||||
|
storage:
|
||||||
|
filesystem:
|
||||||
|
rootdirectory: /var/lib/registry
|
||||||
|
http:
|
||||||
|
addr: :5000
|
||||||
|
headers:
|
||||||
|
X-Content-Type-Options: [nosniff]
|
||||||
|
|
||||||
13
util/docker_registry/docker-compose.yaml
Normal file
13
util/docker_registry/docker-compose.yaml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
services:
|
||||||
|
registry:
|
||||||
|
restart: always
|
||||||
|
image: registry:2
|
||||||
|
ports:
|
||||||
|
- 5000:5000
|
||||||
|
environment:
|
||||||
|
REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt
|
||||||
|
REGISTRY_HTTP_TLS_KEY: /certs/domain.key
|
||||||
|
REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /var/lib/registry
|
||||||
|
volumes:
|
||||||
|
- ./config/config.yml:/etc/docker/registry/config.yml:ro
|
||||||
|
- ./data:/var/lib/registry:rw
|
||||||
Reference in New Issue
Block a user