Skip to content

Commit

Permalink
Remove code duplication.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxpolzin committed Nov 26, 2024
1 parent 009c851 commit a1891b1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
6 changes: 4 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

REPOSITORY_NAME="$(basename "$(dirname -- "$( readlink -f -- "$0"; )")")"
export BUILDKIT_PROGRESS=plain

docker build --progress=plain -t ghcr.io/rosblox/${REPOSITORY_NAME}:humble .
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

docker compose -f $SCRIPT_DIR/docker-compose.yml build
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
ros-template:
image: ghcr.io/rosblox/ros-template:humble
build:
context: .
dockerfile: Dockerfile
restart: always
network_mode: "host"
ipc: host
pid: host
environment:
- UID=${HOST_UID}
- ROS_DOMAIN_ID
command: su - ros --whitelist-environment=ROS_DOMAIN_ID /run.sh
2 changes: 1 addition & 1 deletion ros_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ set -e
id -u ros &>/dev/null || adduser --quiet --disabled-password --gecos '' --uid ${UID:=1000} ros

source /opt/ros/${ROS_DISTRO}/setup.bash
source /colcon_ws/install/setup.bash
source /colcon_ws/install/setup.bash || true

exec "$@"
14 changes: 7 additions & 7 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

REPOSITORY_NAME="$(basename "$(dirname -- "$( readlink -f -- "$0"; )")")"
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

docker run -it --rm \
--network=host \
--ipc=host --pid=host \
--env UID=$(id -u) \
--env GID=$(id -g) \
ghcr.io/rosblox/${REPOSITORY_NAME}:humble
export HOST_UID=$(id -u)

docker compose -f $SCRIPT_DIR/docker-compose.yml run \
--volume $(pwd)/livox_ros_driver2:/colcon_ws/src/livox_ros_driver2 \
--volume $(pwd)/Livox-SDK2:/Livox-SDK2 \
ros-livox-ros-driver2 bash

0 comments on commit a1891b1

Please sign in to comment.