diff --git a/docker/README.md b/docker/README.md index 9cb8a4b..1adf31e 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,14 +1,3 @@ # Docker This folder contains Docker sessions. - -## User-usable sessions - -* [custom_package](./custom_package) builds a custom ROS package into a Docker image -* [local_docker_registry](./local_docker_registry) starts a local docker registry on a personal machine -* [uav_session](./uav_session) sessions supposed to be started by the user via the Portainer system - * - -## Admin and initial setup sessions - -* [portainer](./portainer) starts the Portainer-CE system (initial setup only) diff --git a/docker/custom_package/build.sh b/docker/custom_package/build.sh deleted file mode 100755 index 0daa238..0000000 --- a/docker/custom_package/build.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -LOCAL_TAG=custom_package:1.0.0 - -ARCH=arm64 -# ARCH=amd64 - -WORKSPACE_PATH=etc/catkin_workspace -CACHE_PATH=cache - -# initialize the cache -mkdir -p ./${CACHE_PATH}/${WORKSPACE_PATH} - -docker buildx select default - -# this first build compiles the contents of "src" and storest the intermediate -docker build . --target stage_cache_workspace --output ./${CACHE_PATH} --build-arg WORKSPACE_PATH=${WORKSPACE_PATH} --file Dockerfile --platform=linux/$ARCH - -# this second build takes the resulting workspace and storest in in a final image -# that can be deployed to a drone -docker build . --target stage_finalization --file Dockerfile --build-arg WORKSPACE_PATH=${WORKSPACE_PATH} --tag $LOCAL_TAG --platform=linux/$ARCH diff --git a/docker/custom_package/src/.gitignore b/docker/custom_package/src/.gitignore deleted file mode 100644 index 1d085ca..0000000 --- a/docker/custom_package/src/.gitignore +++ /dev/null @@ -1 +0,0 @@ -** diff --git a/docker/main_image/export_image.sh b/docker/main_image/export_image.sh deleted file mode 100755 index 7e8e40f..0000000 --- a/docker/main_image/export_image.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -LOCAL_TAG=custom_package:1.0.0 - -docker save $LOCAL_TAG --output custom_package.tar diff --git a/docker/uav_session/camera_test_bottom/compose.yaml b/docker/uav_sessions/camera_test_bottom/compose.yaml similarity index 100% rename from docker/uav_session/camera_test_bottom/compose.yaml rename to docker/uav_sessions/camera_test_bottom/compose.yaml diff --git a/docker/uav_session/camera_test_bottom/rviz/camera_test.rviz b/docker/uav_sessions/camera_test_bottom/rviz/camera_test.rviz similarity index 100% rename from docker/uav_session/camera_test_bottom/rviz/camera_test.rviz rename to docker/uav_sessions/camera_test_bottom/rviz/camera_test.rviz diff --git a/docker/uav_session/camera_test_bottom/rviz/rviz.sh b/docker/uav_sessions/camera_test_bottom/rviz/rviz.sh similarity index 100% rename from docker/uav_session/camera_test_bottom/rviz/rviz.sh rename to docker/uav_sessions/camera_test_bottom/rviz/rviz.sh diff --git a/docker/uav_session/camera_test_bottom/variables.env b/docker/uav_sessions/camera_test_bottom/variables.env similarity index 100% rename from docker/uav_session/camera_test_bottom/variables.env rename to docker/uav_sessions/camera_test_bottom/variables.env diff --git a/docker/uav_session/camera_test_front/compose.yaml b/docker/uav_sessions/camera_test_front/compose.yaml similarity index 100% rename from docker/uav_session/camera_test_front/compose.yaml rename to docker/uav_sessions/camera_test_front/compose.yaml diff --git a/docker/uav_session/camera_test_front/rviz/camera_test.rviz b/docker/uav_sessions/camera_test_front/rviz/camera_test.rviz similarity index 100% rename from docker/uav_session/camera_test_front/rviz/camera_test.rviz rename to docker/uav_sessions/camera_test_front/rviz/camera_test.rviz diff --git a/docker/uav_session/camera_test_front/rviz/rviz.sh b/docker/uav_sessions/camera_test_front/rviz/rviz.sh similarity index 100% rename from docker/uav_session/camera_test_front/rviz/rviz.sh rename to docker/uav_sessions/camera_test_front/rviz/rviz.sh diff --git a/docker/uav_session/camera_test_front/variables.env b/docker/uav_sessions/camera_test_front/variables.env similarity index 100% rename from docker/uav_session/camera_test_front/variables.env rename to docker/uav_sessions/camera_test_front/variables.env diff --git a/docker/uav_session/gnss/compose.yaml b/docker/uav_sessions/gnss/compose.yaml similarity index 100% rename from docker/uav_session/gnss/compose.yaml rename to docker/uav_sessions/gnss/compose.yaml diff --git a/docker/uav_session/gnss/variables.env b/docker/uav_sessions/gnss/variables.env similarity index 100% rename from docker/uav_session/gnss/variables.env rename to docker/uav_sessions/gnss/variables.env diff --git a/docker/uav_session/sensor_diagnostics/compose.yaml b/docker/uav_sessions/sensor_diagnostics/compose.yaml similarity index 100% rename from docker/uav_session/sensor_diagnostics/compose.yaml rename to docker/uav_sessions/sensor_diagnostics/compose.yaml diff --git a/docker/uav_session/sensor_diagnostics/variables.env b/docker/uav_sessions/sensor_diagnostics/variables.env similarity index 100% rename from docker/uav_session/sensor_diagnostics/variables.env rename to docker/uav_sessions/sensor_diagnostics/variables.env diff --git a/docker/user_session/compose.yaml b/docker/uav_sessions/user_session/compose.yaml similarity index 100% rename from docker/user_session/compose.yaml rename to docker/uav_sessions/user_session/compose.yaml diff --git a/docker/user_session/variables.env b/docker/uav_sessions/user_session/variables.env similarity index 100% rename from docker/user_session/variables.env rename to docker/uav_sessions/user_session/variables.env diff --git a/docker/uav_session/vio/compose.yaml b/docker/uav_sessions/vio/compose.yaml similarity index 100% rename from docker/uav_session/vio/compose.yaml rename to docker/uav_sessions/vio/compose.yaml diff --git a/docker/uav_session/vio/variables.env b/docker/uav_sessions/vio/variables.env similarity index 100% rename from docker/uav_session/vio/variables.env rename to docker/uav_sessions/vio/variables.env diff --git a/docker/custom_package/.gitignore b/docker/user_workspace/.gitignore similarity index 57% rename from docker/custom_package/.gitignore rename to docker/user_workspace/.gitignore index 2fd7fd0..1061e97 100644 --- a/docker/custom_package/.gitignore +++ b/docker/user_workspace/.gitignore @@ -1,2 +1,3 @@ cache *.tar +*.tar.gz diff --git a/docker/custom_package/Dockerfile b/docker/user_workspace/Dockerfile similarity index 100% rename from docker/custom_package/Dockerfile rename to docker/user_workspace/Dockerfile diff --git a/docker/user_workspace/build_image.sh b/docker/user_workspace/build_image.sh new file mode 100755 index 0000000..188c5ad --- /dev/null +++ b/docker/user_workspace/build_image.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +set -e + +trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG +trap 'echo "$0: \"${last_command}\" command failed with exit code $?"' ERR + +# get the path to this script +MY_PATH=`dirname "$0"` +MY_PATH=`( cd "$MY_PATH" && pwd )` + +cd ${MY_PATH} + +## -------------------------------------------------------------- +## | setup | +## -------------------------------------------------------------- + +LOCAL_TAG=user_workspace:1.0.0 + +ARCH=arm64 # robofly +# ARCH=amd64 + +source ./paths.sh + +## -------------------------------------------------------------- +## | build | +## -------------------------------------------------------------- + +# initialize the cache +[ ! -e ${CACHE_PATH}/${WORKSPACE_PATH} ] && mkdir -p ./${CACHE_PATH}/${WORKSPACE_PATH} + +PASS_TO_DOCKER_BUILD="Dockerfile src ${CACHE_PATH}/${WORKSPACE_PATH}" + +docker buildx use default + +echo "" +echo "$0: building the user's workspace" +echo "" + +# this first build compiles the contents of "src" and storest the intermediate +tar -czh $PASS_TO_DOCKER_BUILD 2>/dev/null | docker build - --no-cache --target stage_cache_workspace --output ./${CACHE_PATH} --build-arg WORKSPACE_PATH=${WORKSPACE_PATH} --file Dockerfile --platform=linux/$ARCH + +echo "" +echo "$0: packing the workspace into a docker image" +echo "" + +# this second build takes the resulting workspace and storest in in a final image +# that can be deployed to a drone +docker build . --no-cache --target stage_finalization --file Dockerfile --build-arg WORKSPACE_PATH=${WORKSPACE_PATH} --tag $LOCAL_TAG --platform=linux/$ARCH + +echo "" +echo "$0: workspace was packed into '$LOCAL_TAG'" +echo "" diff --git a/docker/user_workspace/clean_cache.sh b/docker/user_workspace/clean_cache.sh new file mode 100755 index 0000000..e7b04d5 --- /dev/null +++ b/docker/user_workspace/clean_cache.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +set -e + +trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG +trap 'echo "$0: \"${last_command}\" command failed with exit code $?"' ERR + +# get the path to this script +MY_PATH=`dirname "$0"` +MY_PATH=`( cd "$MY_PATH" && pwd )` + +cd ${MY_PATH} + +## -------------------------------------------------------------- +## | setup | +## -------------------------------------------------------------- + +source ./paths.sh + +## -------------------------------------------------------------- +## | build | +## -------------------------------------------------------------- + +rm -rf $CACHE_PATH + +echo "" +echo "$0: cache cleaned" +echo "" diff --git a/docker/user_workspace/export_image.sh b/docker/user_workspace/export_image.sh new file mode 100755 index 0000000..01d8ac6 --- /dev/null +++ b/docker/user_workspace/export_image.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -e + +trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG +trap 'echo "$0: \"${last_command}\" command failed with exit code $?"' ERR + +# get the path to this script +MY_PATH=`dirname "$0"` +MY_PATH=`( cd "$MY_PATH" && pwd )` + +cd ${MY_PATH} + +## -------------------------------------------------------------- +## | setup | +## -------------------------------------------------------------- + +LOCAL_TAG=user_workspace:1.0.0 + +## -------------------------------------------------------------- +## | export | +## -------------------------------------------------------------- + +docker save $LOCAL_TAG | gzip > ${LOCAL_TAG}.tar.gz + +echo "" +echo "$0: image exorted as ${LOCAL_TAG}.tar.gz" +echo "" + diff --git a/docker/user_workspace/paths.sh b/docker/user_workspace/paths.sh new file mode 100644 index 0000000..fab567d --- /dev/null +++ b/docker/user_workspace/paths.sh @@ -0,0 +1,3 @@ +export WORKSPACE_PATH=etc/catkin_workspace +export CACHE_PATH=cache + diff --git a/docker/local_docker_registry/README.md b/setup/docker_registry/README.md similarity index 100% rename from docker/local_docker_registry/README.md rename to setup/docker_registry/README.md diff --git a/docker/local_docker_registry/compose.yaml b/setup/docker_registry/compose.yaml similarity index 100% rename from docker/local_docker_registry/compose.yaml rename to setup/docker_registry/compose.yaml diff --git a/docker/local_docker_registry/down.sh b/setup/docker_registry/down.sh similarity index 100% rename from docker/local_docker_registry/down.sh rename to setup/docker_registry/down.sh diff --git a/docker/local_docker_registry/up.sh b/setup/docker_registry/up.sh similarity index 100% rename from docker/local_docker_registry/up.sh rename to setup/docker_registry/up.sh diff --git a/docker/portainer/README.md b/setup/portainer/README.md similarity index 100% rename from docker/portainer/README.md rename to setup/portainer/README.md diff --git a/docker/portainer/agent/compose.yaml b/setup/portainer/agent/compose.yaml similarity index 100% rename from docker/portainer/agent/compose.yaml rename to setup/portainer/agent/compose.yaml diff --git a/docker/portainer/agent/down.sh b/setup/portainer/agent/down.sh similarity index 100% rename from docker/portainer/agent/down.sh rename to setup/portainer/agent/down.sh diff --git a/docker/portainer/agent/up.sh b/setup/portainer/agent/up.sh similarity index 100% rename from docker/portainer/agent/up.sh rename to setup/portainer/agent/up.sh diff --git a/docker/portainer/agent_and_server/compose.yaml b/setup/portainer/agent_and_server/compose.yaml similarity index 100% rename from docker/portainer/agent_and_server/compose.yaml rename to setup/portainer/agent_and_server/compose.yaml diff --git a/docker/portainer/agent_and_server/down.sh b/setup/portainer/agent_and_server/down.sh similarity index 100% rename from docker/portainer/agent_and_server/down.sh rename to setup/portainer/agent_and_server/down.sh diff --git a/docker/portainer/agent_and_server/up.sh b/setup/portainer/agent_and_server/up.sh similarity index 100% rename from docker/portainer/agent_and_server/up.sh rename to setup/portainer/agent_and_server/up.sh diff --git a/docker/portainer/server/compose.yaml b/setup/portainer/server/compose.yaml similarity index 100% rename from docker/portainer/server/compose.yaml rename to setup/portainer/server/compose.yaml diff --git a/docker/portainer/server/down.sh b/setup/portainer/server/down.sh similarity index 100% rename from docker/portainer/server/down.sh rename to setup/portainer/server/down.sh diff --git a/docker/portainer/server/up.sh b/setup/portainer/server/up.sh similarity index 100% rename from docker/portainer/server/up.sh rename to setup/portainer/server/up.sh diff --git a/docker/main_image/Dockerfile b/setup/robofly_docker_image/Dockerfile similarity index 100% rename from docker/main_image/Dockerfile rename to setup/robofly_docker_image/Dockerfile diff --git a/docker/main_image/build.sh b/setup/robofly_docker_image/build.sh similarity index 100% rename from docker/main_image/build.sh rename to setup/robofly_docker_image/build.sh diff --git a/docker/main_image/build_arm64.sh b/setup/robofly_docker_image/build_arm64.sh similarity index 100% rename from docker/main_image/build_arm64.sh rename to setup/robofly_docker_image/build_arm64.sh diff --git a/docker/custom_package/export_image.sh b/setup/robofly_docker_image/export_image.sh similarity index 100% rename from docker/custom_package/export_image.sh rename to setup/robofly_docker_image/export_image.sh