-
Notifications
You must be signed in to change notification settings - Fork 4
Sample docker project for humble/jazzy supervisor runtime containers #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pietropier1
wants to merge
4
commits into
3LawsRobotics:master
Choose a base branch
from
pietropier1:feature/runtime-docker
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+157
−0
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5729c8e
Sample project for creating humble/jazzy supervisor runtime dockers
pietropier1 aacca6f
Refactors Docker setup for supervisor
pietropier1 d8587cc
Adjusted docker instructions on README
pietropier1 852e272
Fixed merged conflicts on README
pietropier1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| ARG ROS_DISTRO=humble | ||
| ARG BASE_IMAGE=ros:$ROS_DISTRO-ros-core | ||
| FROM $BASE_IMAGE | ||
|
|
||
| ## Sup options | ||
| ARG ASSET_ID | ||
| ARG ASSET_NAME | ||
|
|
||
| ## Install some packages | ||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends \ | ||
| sudo \ | ||
| software-properties-common \ | ||
| screen \ | ||
| vim \ | ||
| ros-$ROS_DISTRO-rosbridge-server | ||
|
|
||
| ## Get Supervisor | ||
| ENV GH_REPO="https://api.github.com/repos/3LawsRobotics/3laws" | ||
|
|
||
| ## Install Supervisor | ||
| WORKDIR /tmp | ||
| ARG CURL_ARGS="-LJO#" | ||
| ARG GH_ASSET="$GH_REPO/releases/assets/$ASSET_ID" | ||
| RUN curl $CURL_ARGS -s -H 'Accept: application/octet-stream' "$GH_ASSET" | ||
| RUN sudo apt install -f ./"$ASSET_NAME" -y --no-install-recommends | ||
|
|
||
| ## Add entrypoint | ||
| WORKDIR / | ||
| COPY entrypoint.sh /root/entrypoint.sh | ||
| ENTRYPOINT ["/root/entrypoint.sh"] |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #!/bin/bash | ||
|
|
||
| DOCKER_IMAGE_NAME="lll-supervisor-runtime" | ||
|
|
||
| # Get ROS_DISTRO from first argument, error if not provided | ||
| if [ -z "$1" ]; then | ||
| echo "Usage: $0 <ROS_DISTRO>. Specify jazzy|humble" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Check if provided ROS_DISTRO is either "jazzy" or "humble" | ||
| if [ "$1" != "jazzy" ] && [ "$1" != "humble" ]; then | ||
| echo "Error - supported ROS_DISTRO values are: jazzy|humble" | ||
| exit 1 | ||
| fi | ||
| TAG=$1 | ||
|
|
||
| GH_REPO="https://api.github.com/repos/3LawsRobotics/3laws/releases/latest" | ||
| PACKAGE_NAME="lll-supervisor-full-${TAG}" | ||
| REGEX_QUERY="${PACKAGE_NAME}_[0-9]\+\.[0-9]\+\.[0-9]\+-[0-9]\+_amd64_ubuntu[0-9]\+.[0-9]\+" | ||
|
|
||
| # Read asset tags. | ||
| RESPONSE=$(curl -s -H "application/vnd.github+json" $GH_REPO) | ||
| ASSET_NAME=$(echo "$RESPONSE" | grep -o "name.:.\+${REGEX_QUERY}.deb" | cut -d ":" -f2- | cut -d "\"" -f2-) | ||
| ASSET_ID=$(echo "$RESPONSE" | grep -C3 "name.:.\+$REGEX_QUERY" | grep -w id | tr : = | tr -cd '[[:alnum:]]=' | cut -d'=' -f2-) | ||
|
|
||
| echo "Building Docker image $DOCKER_IMAGE_NAME:$TAG with asset $ASSET_NAME (id: $ASSET_ID)" | ||
|
|
||
| docker build --rm \ | ||
| --build-arg ROS_DISTRO="$TAG" \ | ||
| --build-arg ASSET_ID="$ASSET_ID" \ | ||
| --build-arg ASSET_NAME="$ASSET_NAME" \ | ||
| -t "$DOCKER_IMAGE_NAME:$TAG" \ | ||
| -f "$(pwd)/Dockerfile" . |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e # Exit immediately if a command exits with a non-zero status | ||
|
|
||
| screen -dmS lll_rosbridge bash -lc "source /opt/ros/$ROS_DISTRO/setup.bash && exec ros2 launch rosbridge_server rosbridge_websocket_launch.xml port:=9091" | ||
|
|
||
| screen -dmS lll_control_panel /opt/3laws/control_panel/control-panel-backend 8000 /opt/3laws/control_panel/build/ | ||
|
|
||
| source /opt/ros/humble/setup.bash && exec "$@" |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e # Exit on error, print commands, and treat unset variables as an error | ||
|
|
||
| TAG="$1" | ||
| IMAGE_NAME="lll-supervisor-runtime" | ||
|
|
||
| # Get all tags for the image | ||
| tags=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep "^${IMAGE_NAME}:" | cut -d: -f2) | ||
|
|
||
| # Check if TAG exists in tags | ||
| if echo "$tags" | grep -q "^${TAG}$"; then | ||
| IMAGE_TAG=$TAG | ||
| else | ||
| echo "Selected tag '$TAG' not found. Available tags are:" | ||
| echo "$tags" | ||
| exit 1 | ||
| fi | ||
|
|
||
| DOCKER_HOME=/ | ||
| DOCKER_LLL_CONFIG_DIR="$DOCKER_HOME/.3laws/config" | ||
| IMAGE_NAME="lll-supervisor-runtime" | ||
|
|
||
| # Check if Docker image exists | ||
| if ! docker image inspect $IMAGE_NAME:$IMAGE_TAG >/dev/null 2>&1; then | ||
| echo "Docker image $IMAGE_NAME:$IMAGE_TAG not found. Run build_docker.bash first to create image." | ||
| exit 1 | ||
| fi | ||
|
|
||
| docker volume create lll_supervisor_config | ||
| docker run --privileged --rm -it \ | ||
| --name lll-supervisor \ | ||
| --net=host \ | ||
| -v lll_supervisor_config:/$DOCKER_LLL_CONFIG_DIR/ \ | ||
| "$IMAGE_NAME":"$IMAGE_TAG" bash |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.