Skip to content
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

Draft: Rename (non-minimal) release to frozen #105

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .docker_scripts/exec.bash
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if [ "$EXECMODE" = "devel" ]; then
fi
fi

if [ "$EXECMODE" = "storedrelease" ]; then
if [ "$EXECMODE" = "stored" ]; then
# Read image name from command line, first arg already shifted away
set_stored_image_name $1
shift
Expand Down
2 changes: 1 addition & 1 deletion .docker_scripts/git_hooks/post-merge
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
#
echo -e "\n\e[4;33mScripts were updated, please remember to update the images using: ./tools/update_image.bash [devel|release]\e[0m \n"
echo -e "\n\e[4;33mScripts were updated, please remember to update the images using: ./tools/update_image.bash [devel|frozen|release]\e[0m \n"
7 changes: 5 additions & 2 deletions .docker_scripts/variables.bash
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SCRIPTSVERSION=$(cat $ROOT_DIR/VERSION | head -n1 | awk -F' ' '{print $1}')
# (several checkouts of this repo possible without interfering)
FOLDER_MD5=$(echo $ROOT_DIR | md5sum | cut -b 1-8)

EXECMODES=("base" "devel" "release" "storedrelease" "CD")
EXECMODES=("base" "devel" "frozen" "release" "stored" "CD")

PRINT_WARNING=echo
PRINT_INFO=echo
Expand Down Expand Up @@ -71,10 +71,13 @@ function set_image_name(){
if [ "$EXECMODE" = "devel" ]; then
IMAGE_NAME=${DEVEL_REGISTRY:+${DEVEL_REGISTRY}/}$WORKSPACE_DEVEL_IMAGE
fi
if [ "$EXECMODE" = "frozen" ]; then
IMAGE_NAME=${FROZEN_REGISTRY:+${FROZEN_REGISTRY}/}$WORKSPACE_FROZEN_IMAGE
fi
if [ "$EXECMODE" = "release" ]; then
IMAGE_NAME=${RELEASE_REGISTRY:+${RELEASE_REGISTRY}/}$WORKSPACE_RELEASE_IMAGE
fi
if [ "$EXECMODE" = "storedrelease" ]; then
if [ "$EXECMODE" = "stored" ]; then
set_stored_image_name $1
fi
if [ "$EXECMODE" = "CD" ]; then
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ workspace
container_root
.container_config.txt
*.tar.gz
*.tar
/image_setup/01_base_images/VERSION
/image_setup/04_save_release/autocomplete.me
12 changes: 6 additions & 6 deletions autocomplete.me
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ _exec_bash(){

cur=${COMP_WORDS[COMP_CWORD]}

if [ "${COMP_WORDS[1]}" = "storedrelease" ]; then
if [ "${COMP_WORDS[1]}" = "stored" ]; then
# nothing comes after release
if [ "${#COMP_WORDS[@]}" -gt "4" ]; then
return
Expand All @@ -28,13 +28,13 @@ _exec_bash(){
return
fi

COMPREPLY=($(compgen -W "base devel release CD storedrelease $(ls startscripts | xargs) /bin/bash write_osdeps" -- "$cur"))
COMPREPLY=($(compgen -W "base devel release CD stored $(ls startscripts | xargs) /bin/bash write_osdeps" -- "$cur"))

}

complete -F _exec_bash ./exec.bash
complete -F _exec_bash exec.bash
complete -W "base devel release CD storedrelease" ./stop.bash
complete -W "base devel release CD storedrelease" stop.bash
complete -W "base devel release CD storedrelease" ./delete_container.bash
complete -W "base devel release CD storedrelease" delete_container.bash
complete -W "base devel release CD stored" ./stop.bash
complete -W "base devel release CD stored" stop.bash
complete -W "base devel release CD stored" ./delete_container.bash
complete -W "base devel release CD stored" delete_container.bash
10 changes: 10 additions & 0 deletions image_setup/02_devel_image/build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ IMAGE_NAME=${DEVEL_REGISTRY:+${DEVEL_REGISTRY}/}$WORKSPACE_DEVEL_IMAGE

INTERACTIVE=${INTERACTIVE:="true"}

if [ "${PROJECT_NAME}" == "docker_image_development" ]; then
while $INTERACTIVE; do
read -p "your project name is still docker_image_development, proceed anyways [y/n]? " answer
case $answer in
[Yy]* ) DOCKER_REGISTRY_AUTOPULL=true; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
fi
while $INTERACTIVE; do
read -p "Do you wish to download the most recent base image [y/n]? " answer
case $answer in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ export DEVEL_IMAGE_NAME=${DEVEL_REGISTRY:+${DEVEL_REGISTRY}/}$WORKSPACE_DEVEL_IM
#do not pull for release, use the local image, as the release should be based on the exact same devel image
#fi

RELEASE_IMAGE_NAME=${RELEASE_REGISTRY:+${RELEASE_REGISTRY}/}$WORKSPACE_RELEASE_IMAGE
echo "Buidling release image: ${RELEASE_IMAGE_NAME}_$TAG by $USER on $HOST Date: $DATE"
FROZEN_IMAGE_NAME=${FROZEN_REGISTRY:+${FROZEN_REGISTRY}/}$WORKSPACE_FROZEN_IMAGE
echo "Buidling release image: ${FROZEN_IMAGE_NAME}_$TAG by $USER on $HOST Date: $DATE"

# tag the docker development repo with the release date
git tag -a release_$TAG -m"${RELEASE_IMAGE_NAME}_$TAG"
git tag -a frozen_$TAG -m"${FROZEN_IMAGE_NAME}_$TAG"
# tag the devel image used to create the release (for extracting workspaces later)
docker tag $DEVEL_IMAGE_NAME ${DEVEL_IMAGE_NAME}_$TAG

docker build --no-cache --build-arg DEVEL_IMAGE_NAME --build-arg USER --build-arg HOST --build-arg DATE -f $THIS_DIR/Dockerfile -t $RELEASE_IMAGE_NAME --label "release-image-name=$RELEASE_IMAGE_NAME" --label "release-image-created-from=${DEVEL_IMAGE_NAME} - $(docker inspect --format '{{.Id}}' $DEVEL_IMAGE_NAME)" --label "dockerfile_repo_commit=$(git rev-parse HEAD)" $ROOT_DIR
docker build --no-cache --build-arg DEVEL_IMAGE_NAME --build-arg USER --build-arg HOST --build-arg DATE -f $THIS_DIR/Dockerfile -t $FROZEN_IMAGE_NAME --label "frozen-image-name=$FROZEN_IMAGE_NAME" --label "frozen-image-created-from=${DEVEL_IMAGE_NAME} - $(docker inspect --format '{{.Id}}' $DEVEL_IMAGE_NAME)" --label "dockerfile_repo_commit=$(git rev-parse HEAD)" $ROOT_DIR

echo "tagging $RELEASE_IMAGE_NAME as ${RELEASE_IMAGE_NAME}_$TAG"
docker tag $RELEASE_IMAGE_NAME ${RELEASE_IMAGE_NAME}_$TAG
echo "tagging $FROZEN_IMAGE_NAME as ${FROZEN_IMAGE_NAME}_$TAG"
docker tag $FROZEN_IMAGE_NAME ${FROZEN_IMAGE_NAME}_$TAG

echo
echo "don't forget to push or store the image, if you wish:"
echo "docker push $RELEASE_IMAGE_NAME"
echo "docker push ${RELEASE_IMAGE_NAME}_$TAG"
echo "docker push $FROZEN_IMAGE_NAME"
echo "docker push ${FROZEN_IMAGE_NAME}_$TAG"
echo "docker push ${DEVEL_IMAGE_NAME}_$TAG"
echo "bash store.bash ${RELEASE_IMAGE_NAME}_$TAG <SHORTNAME>"
echo "bash store.bash ${FROZEN_IMAGE_NAME}_$TAG <SHORTNAME>"
echo
11 changes: 0 additions & 11 deletions image_setup/03_release_minimal/entrypoint.bash

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
ARG DISTRO_IMAGE
#ARG DEPENDENCIES_FOLDER
ARG EXECUTABLE
ARG EXECUTABLE_PARAMS=""

FROM ${DISTRO_IMAGE}

Expand Down Expand Up @@ -31,11 +30,5 @@ ADD entrypoint.bash /opt/entrypoint.bash
RUN chmod 755 /opt/entrypoint.bash
ENTRYPOINT ["/opt/entrypoint.bash"]


# add default command
#use ENV VAR to forward to cmd
ENV EXECUTABLE_ENVVAR="${EXECUTABLE}"
ENV EXECUTABLE_PARAMS_ENVVAR="${EXECUTABLE_PARAMS}"
#CMD [./rrc_gamepad_client config.yml]
#needs bach for variable
# add default command (content of "run" set in entrypoint.bash)
CMD ["run"]
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
# Minimal release

This is a more manual step that preparinf a standard release but it saves image memeory size.
This is a more manual step that preparing a standard release but it saves image memeory size.

In a normal release the image still containe all headers an libraries that are used to build the image.
In frozen images the image still contains all headers an libraries that are used to build the image.
While this can help to restore/change releases these images might not be suitable for "real" deployment in cloud services.

The minimal release build process starts with a besic image to be set in the build.bash file.
The minimal release build process starts with a basic image (not a :base image) to be set in the build.bash file.

Also in normal docker deployments there is a one image one app rule. This is why you also have to set the executable in build.bash.
The scripts will collect all linked shared objects and put them into the new image.

It will not collect plugins (not linked) and required configuration files.

You can add them inti the additional_workspace_files.txt files in paph from insice the container.
You can add them into the additional_workspace_files.txt files in paph from insice the container.
If you need to add whole folders, you can use `find -type f -exec readlink -f {} \;` in the container to generate a list.


Also, you'll need to create an entrypoitn that directly runs your allpication.
Also, you'll need to create an entrypoint that directly runs your allpication.
The example provided will still allow to run the console by providing it ad command paramater


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

set -e

# set a NEW base image
# set a NEW base image with a plain diistribution
export DISTRO_IMAGE=ubuntu:20.04
# set executable to be contained in the image
export EXECUTABLE=PATH_TO_YOUR_BINARY # e.g.:/opt/workspace/install/bin/program
# add params foe the executable
export EXECUTABLE_PARAMS=""

export EXECUTABLE=/opt/workspace/PATH_TO_YOUR_BINARY # e.g.:/opt/workspace/install/bin/program

THIS_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
ROOT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )
Expand All @@ -22,7 +19,7 @@ export TAG=$(date +%Y_%m_%d-%H_%M)
export HOST=$(hostname)
export DEVEL_IMAGE_NAME=${DEVEL_REGISTRY:+${DEVEL_REGISTRY}/}$WORKSPACE_DEVEL_IMAGE

RELEASE_IMAGE_NAME=${RELEASE_REGISTRY:+${RELEASE_REGISTRY}/}slam/cloud_slam
RELEASE_IMAGE_NAME=${WORKSPACE_RELEASE_IMAGE}
echo "Buidling minimal release image: ${RELEASE_IMAGE_NAME}_$TAG by $USER on $HOST Date: $DATE"


Expand All @@ -42,13 +39,13 @@ mv $ROOT_DIR/workspace/dependencies.tar ./

docker build --no-cache --build-arg EXECUTABLE=$EXECUTABLE --build-arg EXECUTABLE_PARAMS="$EXECUTABLE_PARAMS" --build-arg DISTRO_IMAGE -f $THIS_DIR/Dockerfile -t $RELEASE_IMAGE_NAME --label "release-image-name=$RELEASE_IMAGE_NAME" --label "release-image-created-from=${DEVEL_IMAGE_NAME} - $(docker inspect --format '{{.Id}}' $DEVEL_IMAGE_NAME)" --label "dockerfile_repo_commit=$(git rev-parse HEAD)" $THIS_DIR

# echo "tagging $RELEASE_IMAGE_NAME as ${RELEASE_IMAGE_NAME}_$TAG"
# docker tag $RELEASE_IMAGE_NAME ${RELEASE_IMAGE_NAME}_$TAG
echo "tagging $RELEASE_IMAGE_NAME as ${RELEASE_IMAGE_NAME}_$TAG"
docker tag $RELEASE_IMAGE_NAME ${RELEASE_IMAGE_NAME}_$TAG

echo
echo "don't forget to push or store the image, if you wish:"
echo "docker push $RELEASE_IMAGE_NAME"
echo "docker push ${RELEASE_IMAGE_NAME}_$TAG"
echo "bash store.bash ${RELEASE_IMAGE_NAME}_$TAG <SHORTNAME>"
echo

# echo
# echo "don't forget to push or store the image, if you wish:"
# echo "docker push $RELEASE_IMAGE_NAME"
# echo "docker push ${RELEASE_IMAGE_NAME}_$TAG"
# echo "docker push ${DEVEL_IMAGE_NAME}_$TAG"
# echo "bash store.bash ${RELEASE_IMAGE_NAME}_$TAG <SHORTNAME>"
# echo
13 changes: 13 additions & 0 deletions image_setup/04_release_image/entrypoint.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

echo $1


if [ "$1" == "run" ]; then
#"run" isn the default cmd in the Dockerfile" so thsi is run when the container is run without paramater
echo "replace this echo command in the entrypoint.bash to run your application"
# exit with error if app fails
exit 1
fi

exec "$@"
10 changes: 7 additions & 3 deletions settings.bash
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ export DOCKER_REGISTRY_GROUP=developmentimage
# e.g. store base images on hub.docker.com and others in a local registry
export BASE_REGISTRY=
export DEVEL_REGISTRY=$DOCKER_REGISTRY
export FROZEN_REGISTRY=$DOCKER_REGISTRY
export RELEASE_REGISTRY=$DOCKER_REGISTRY

# when your images should be stored in different groups of your registry, you can chage it here
# (or completely customize by setting WORKSPACE_DEVEL_IMAGE, WORKSPACE_RELEASE_IMAGE, WORKSPACE_CD_IMAGE below directly)
export DEVEL_REGISTRY_GROUP=$DOCKER_REGISTRY_GROUP
export FROZEN_REGISTRY_GROUP=$DOCKER_REGISTRY_GROUP
export RELEASE_REGISTRY_GROUP=$DOCKER_REGISTRY_GROUP
export CD_REGISTRY_GROUP=$DOCKER_REGISTRY_GROUP

Expand All @@ -28,24 +30,26 @@ export DOCKER_REGISTRY_AUTOPULL=false
### The checked in version should reflect the image status and be the highest availale image (base - devel - release)
export DEFAULT_EXECMODE="base" # Use this only for setting up the initial devel image (modify setup_workspace.bash)
# export DEFAULT_EXECMODE="devel" # This is used while deveoping code and preparing a relase
# export DEFAULT_EXECMODE="frozen" # use the release as default
# export DEFAULT_EXECMODE="release" # use the release as default
# export DEFAULT_EXECMODE="CD" # use the continuous deployment image as default

### The base image used when building a workspace image (one of the ones build in base_images)
# export WORKSPACE_BASE_IMAGE=developmentimage/rock_master_20.04:base # image with rock core dependencies installed
export WORKSPACE_BASE_IMAGE=developmentimage/rock_master_22.04:base # image with rock core dependencies installed
# export WORKSPACE_BASE_IMAGE=developmentimage/rock_master_22.04:base # image with rock core dependencies installed
# export WORKSPACE_BASE_IMAGE=developmentimage/ros_noetic_20.04:base # image with basic ros noetic installed
# export WORKSPACE_BASE_IMAGE=developmentimage/ros2_foxy_20.04:base # image with ros2 foxy desktop installed
# export WORKSPACE_BASE_IMAGE=developmentimage/ros2_humble_22.04:base # image with ros2 humble desktop installed
# export WORKSPACE_BASE_IMAGE=developmentimage/plain_20.04:base # plain image with build_essentials installed
# export WORKSPACE_BASE_IMAGE=developmentimage/plain_22.04:base # plain image with build_essentials installed
#export WORKSPACE_BASE_IMAGE=developmentimage/plain_24.04:base # plain image with build_essentials installed
export WORKSPACE_BASE_IMAGE=developmentimage/plain_22.04:base # plain image with build_essentials installed
# export WORKSPACE_BASE_IMAGE=developmentimage/plain_24.04:base # plain image with build_essentials installed

# The Name of the Workspace image to use
# you should add a workspace name folder and a image name
# e.g MY_PROJECT/docker_image_development:devel
# under normal circumstances you should not need to change the values here
export WORKSPACE_DEVEL_IMAGE=${DEVEL_REGISTRY_GROUP}/${PROJECT_NAME}:devel
export WORKSPACE_FROZEN_IMAGE=${FROZEN_REGISTRY_GROUP}/${PROJECT_NAME}:frozen
export WORKSPACE_RELEASE_IMAGE=${RELEASE_REGISTRY_GROUP}/${PROJECT_NAME}:release
export WORKSPACE_CD_IMAGE=${CD_REGISTRY_GROUP}/${PROJECT_NAME}:CD

Expand Down