Skip to content

Commit

Permalink
moving stuff around
Browse files Browse the repository at this point in the history
  • Loading branch information
klaxalk committed Oct 18, 2024
1 parent 4e131ee commit 5db302b
Show file tree
Hide file tree
Showing 44 changed files with 114 additions and 38 deletions.
11 changes: 0 additions & 11 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -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)
21 changes: 0 additions & 21 deletions docker/custom_package/build.sh

This file was deleted.

1 change: 0 additions & 1 deletion docker/custom_package/src/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions docker/main_image/export_image.sh

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
cache
*.tar
*.tar.gz
File renamed without changes.
53 changes: 53 additions & 0 deletions docker/user_workspace/build_image.sh
Original file line number Diff line number Diff line change
@@ -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 ""
28 changes: 28 additions & 0 deletions docker/user_workspace/clean_cache.sh
Original file line number Diff line number Diff line change
@@ -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 ""
29 changes: 29 additions & 0 deletions docker/user_workspace/export_image.sh
Original file line number Diff line number Diff line change
@@ -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 ""

3 changes: 3 additions & 0 deletions docker/user_workspace/paths.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export WORKSPACE_PATH=etc/catkin_workspace
export CACHE_PATH=cache

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 5db302b

Please sign in to comment.