From 4c1344d676287e88c41c71130a9d27214bdf257e Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Wed, 24 May 2023 23:02:34 +0200 Subject: [PATCH 01/31] rename additional.apt-dependencies to additional-debs.txt --- Dockerfile | 2 +- README.md | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 21a1f1a..5a00ca8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -74,7 +74,7 @@ RUN echo "set -e" >> $WORKSPACE/.install-dependencies.sh && \ # add additionally specified apt dependencies to install script RUN echo "apt-get install -y \\" >> $WORKSPACE/.install-dependencies.sh && \ set -o pipefail && \ - find . -type f -name "additional.apt-dependencies" -exec cat {} \; | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh && \ + find . -type f -name "additional-debs.txt" -exec cat {} \; | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh && \ echo ";" >> $WORKSPACE/.install-dependencies.sh # add custom installation commands to install script diff --git a/README.md b/README.md index af95191..75dba0a 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ The Dockerfile performs the following steps to automatically build these images: 1. All dependency repositories that are defined in a `.repos` file anywhere in the repository are cloned using [vcstool](https://github.com/dirk-thomas/vcstool). 1. The ROS dependencies listed in each package's `package.xml` are installed by [rosdep](https://docs.ros.org/en/independent/api/rosdep/html/). -1. *(optional)* Additional dependencies from a special file `additional.apt-dependencies` are installed, if needed. +1. *(optional)* Additional system dependencies from a special file `additional-debs.txt` are installed via `apt`, if needed. 1. *(optional)* A special folder `files/` is copied into the images, if needed. 1. *(optional)* A special script `custom.sh` is executed to perform further arbitrary installation commands, if needed. 1. *(deployment)* All ROS packages are built using `catkin` (ROS) or `colcon` (ROS2). @@ -58,11 +58,11 @@ The Dockerfile performs the following steps to automatically build these images: ### Advanced Integration -#### System Dependencies (apt) +#### System Dependencies (`apt`) -If your ROS-based repository requires system dependencies that cannot be installed by specifying their [rosdep](https://docs.ros.org/en/independent/api/rosdep/html/) keys in a `package.xml`, you can use the special `additional.apt-dependencies` file. +If your ROS-based repository requires system dependencies that cannot be installed by specifying their [rosdep](https://docs.ros.org/en/independent/api/rosdep/html/) keys in a `package.xml`, you can use the special `additional-debs.txt` file. -Create a file `additional.apt-dependencies` in your `docker` folder and list any other dependencies that need to be installed via apt. +Create a file `additional-debs.txt` in your `docker` folder and list any other dependencies that need to be installed via `apt`. #### Custom Installation Script From a5ee36cf1943770c14ac1746f867f5c055eaa5fc Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Wed, 24 May 2023 23:22:59 +0200 Subject: [PATCH 02/31] add build arg to modify filename and recursion of additional-debs.txt --- Dockerfile | 8 +++++++- README.md | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5a00ca8..c28c1de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -72,9 +72,15 @@ RUN echo "set -e" >> $WORKSPACE/.install-dependencies.sh && \ rm -rf /var/lib/apt/lists/* # add additionally specified apt dependencies to install script +ARG ADDITIONAL_DEBS_FILE="additional-debs.txt" +ARG ADDITIONAL_DEBS_RECURSIVE="true" RUN echo "apt-get install -y \\" >> $WORKSPACE/.install-dependencies.sh && \ set -o pipefail && \ - find . -type f -name "additional-debs.txt" -exec cat {} \; | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh && \ + if [[ $ADDITIONAL_DEBS_RECURSIVE == 'true' ]]; then \ + find . -type f -name $(basename {ADDITIONAL_DEBS_FILE}) -exec cat {} \; | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh \ + else \ + test -f ${ADDITIONAL_DEBS_FILE} && cat ${ADDITIONAL_DEBS_FILE} | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh \ + fi && \ echo ";" >> $WORKSPACE/.install-dependencies.sh # add custom installation commands to install script diff --git a/README.md b/README.md index 75dba0a..7b2b094 100644 --- a/README.md +++ b/README.md @@ -127,3 +127,10 @@ variables: | `IMAGE_RUN_TARGET` | run image tag, must match the one defined in `DOCKER_COMPOSE_FILE` | `${CI_REGISTRY_IMAGE}:latest` | | `PUSH_AS_LATEST` | push `latest` tag in addition to the tag defined in `DOCKER_COMPOSE_FILE` | `'false'` | | `ROS_DIR` | path to directory in repository that contains ROS packages | `.` | + +docker-ros build args + +| Variable | Description | Default | +| --- | --- | --- | +| `ADDITIONAL_DEBS_FILE` | filename or filepath of file containing additional system dependencies | `additional-debs.txt` | +| `ADDITIONAL_DEBS_RECURSIVE` | whether to recursively find files named `ADDITIONAL_DEBS_FILE` | `'true'` | From 132d8dfc036c9596a327ea2b70a3db35f6a87345 Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Wed, 24 May 2023 23:27:35 +0200 Subject: [PATCH 03/31] add build arg to modify filename and recursion of custom.sh --- Dockerfile | 8 +++++++- README.md | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c28c1de..741e8e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -84,7 +84,13 @@ RUN echo "apt-get install -y \\" >> $WORKSPACE/.install-dependencies.sh && \ echo ";" >> $WORKSPACE/.install-dependencies.sh # add custom installation commands to install script -RUN find . -type f -name "custom.sh" -exec cat {} >> $WORKSPACE/.install-dependencies.sh \; +ARG CUSTOM_SCRIPT_FILE="custom.sh" +ARG CUSTOM_SCRIPT_RECURSIVE="true" +RUN if [[ $CUSTOM_SCRIPT_RECURSIVE == 'true' ]]; then \ + find . -type f -name $(basename ${CUSTOM_SCRIPT_FILE}) -exec cat {} >> $WORKSPACE/.install-dependencies.sh \; \ + else \ + test -f ${CUSTOM_SCRIPT_FILE} && cat ${CUSTOM_SCRIPT_FILE} >> $WORKSPACE/.install-dependencies.sh \ + fi # remove now obsolete docker folder from copied repository content to avoid redundancies RUN rm -rf src/target/docker diff --git a/README.md b/README.md index 7b2b094..95a602a 100644 --- a/README.md +++ b/README.md @@ -134,3 +134,5 @@ docker-ros build args | --- | --- | --- | | `ADDITIONAL_DEBS_FILE` | filename or filepath of file containing additional system dependencies | `additional-debs.txt` | | `ADDITIONAL_DEBS_RECURSIVE` | whether to recursively find files named `ADDITIONAL_DEBS_FILE` | `'true'` | +| `CUSTOM_SCRIPT_FILE` | filename or filepath of file containing custom script for dependency installation | `custom.sh` | +| `CUSTOM_SCRIPT_RECURSIVE` | whether to recursively find files named `CUSTOM_SCRIPT_FILE` | `'true'` | From 1ed9bde518d78e24827dfdc1b230dd13260b547e Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Wed, 24 May 2023 23:37:18 +0200 Subject: [PATCH 04/31] add support for additional-pip-requirements.txt closes #39 --- Dockerfile | 13 +++++++++++++ README.md | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/Dockerfile b/Dockerfile index 741e8e9..08d18f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -83,6 +83,18 @@ RUN echo "apt-get install -y \\" >> $WORKSPACE/.install-dependencies.sh && \ fi && \ echo ";" >> $WORKSPACE/.install-dependencies.sh +# add additionally specified pip dependencies to install script +ARG ADDITIONAL_PIP_FILE="additional-pip-requirements.txt" +ARG ADDITIONAL_PIP_RECURSIVE="true" +RUN echo "pip install \\" >> $WORKSPACE/.install-dependencies.sh && \ + set -o pipefail && \ + if [[ $ADDITIONAL_PIP_RECURSIVE == 'true' ]]; then \ + find . -type f -name $(basename {ADDITIONAL_PIP_FILE}) -exec cat {} \; | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh \ + else \ + test -f ${ADDITIONAL_PIP_FILE} && cat ${ADDITIONAL_PIP_FILE} | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh \ + fi && \ + echo ";" >> $WORKSPACE/.install-dependencies.sh + # add custom installation commands to install script ARG CUSTOM_SCRIPT_FILE="custom.sh" ARG CUSTOM_SCRIPT_RECURSIVE="true" @@ -139,6 +151,7 @@ RUN apt-get update && \ apt-get install -y \ build-essential \ gosu \ + python3-pip \ && source /opt/ros/$ROS_DISTRO/setup.bash && \ if [ "$ROS_VERSION" == "1" ]; then \ apt-get install -y \ diff --git a/README.md b/README.md index 95a602a..14efa33 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ The Dockerfile performs the following steps to automatically build these images: 1. All dependency repositories that are defined in a `.repos` file anywhere in the repository are cloned using [vcstool](https://github.com/dirk-thomas/vcstool). 1. The ROS dependencies listed in each package's `package.xml` are installed by [rosdep](https://docs.ros.org/en/independent/api/rosdep/html/). 1. *(optional)* Additional system dependencies from a special file `additional-debs.txt` are installed via `apt`, if needed. +1. *(optional)* Additional Python dependencies from a special file `additional-pip-requirements.txt` are installed via `pip`, if needed. 1. *(optional)* A special folder `files/` is copied into the images, if needed. 1. *(optional)* A special script `custom.sh` is executed to perform further arbitrary installation commands, if needed. 1. *(deployment)* All ROS packages are built using `catkin` (ROS) or `colcon` (ROS2). @@ -64,6 +65,12 @@ If your ROS-based repository requires system dependencies that cannot be install Create a file `additional-debs.txt` in your `docker` folder and list any other dependencies that need to be installed via `apt`. +#### Python Dependencies (`pip`) + +If your ROS-based repository requires Python dependencies that cannot be installed by specifying their [rosdep](https://docs.ros.org/en/independent/api/rosdep/html/) keys in a `package.xml`, you can use the special `additional-pip-requirements.txt` file. + +Create a file `additional-pip-requirements.txt` in your `docker` folder and list any other dependencies (and version number) that need to be installed via `pip`. + #### Custom Installation Script If your ROS-based repository requires to execute any other installation or pre-/post-installation steps, you can use the special `custom.sh` script. @@ -134,5 +141,7 @@ docker-ros build args | --- | --- | --- | | `ADDITIONAL_DEBS_FILE` | filename or filepath of file containing additional system dependencies | `additional-debs.txt` | | `ADDITIONAL_DEBS_RECURSIVE` | whether to recursively find files named `ADDITIONAL_DEBS_FILE` | `'true'` | +| `ADDITIONAL_PIP_FILE` | filename or filepath of file containing additional pip dependencies | `additional-pip-requirements.txt` | +| `ADDITIONAL_PIP_RECURSIVE` | whether to recursively find files named `ADDITIONAL_PIP_FILE` | `'true'` | | `CUSTOM_SCRIPT_FILE` | filename or filepath of file containing custom script for dependency installation | `custom.sh` | | `CUSTOM_SCRIPT_RECURSIVE` | whether to recursively find files named `CUSTOM_SCRIPT_FILE` | `'true'` | From 34d640fc00c25e5fb8b32fdf0b4dfbcd0103b902 Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Wed, 24 May 2023 23:42:17 +0200 Subject: [PATCH 05/31] add build arg to modify directory name of files folder --- Dockerfile | 3 ++- README.md | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 08d18f3..6fb3de8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -144,7 +144,8 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* # copy contents of files-folder into image -ADD docker/files* /docker-ros/files/ +ARG ADDITIONAL_FILES_DIR="additional-files" +ADD docker/${ADDITIONAL_FILES_DIR}* /docker-ros/$(basename ${ADDITIONAL_FILES_DIR})/ # install essential ROS CLI tools RUN apt-get update && \ diff --git a/README.md b/README.md index 14efa33..8caac69 100644 --- a/README.md +++ b/README.md @@ -79,9 +79,9 @@ Create a script `custom.sh` in your `docker` folder that executes arbitrary comm #### Extra Image Files -If you need to have additional files present in the deployment image, you can use the special `files` folder. These will be copied into the container before the custom installation script `custom.sh` is executed. +If you need to have additional files present in the deployment image, you can use the special `additional-files` folder. These will be copied into the container before the custom installation script `custom.sh` is executed. -Create a folder `files` in your `docker` folder and place any files or directories in it. The contents will be copied to `/docker-ros/files` in the image. +Create a folder `additional-files` in your `docker` folder and place any files or directories in it. The contents will be copied to `/docker-ros/additional-files` in the image. #### Git Credentials when Building Images Locally @@ -145,3 +145,4 @@ docker-ros build args | `ADDITIONAL_PIP_RECURSIVE` | whether to recursively find files named `ADDITIONAL_PIP_FILE` | `'true'` | | `CUSTOM_SCRIPT_FILE` | filename or filepath of file containing custom script for dependency installation | `custom.sh` | | `CUSTOM_SCRIPT_RECURSIVE` | whether to recursively find files named `CUSTOM_SCRIPT_FILE` | `'true'` | +| `ADDITIONAL_FILES_DIR` | path of directory containing additional files to be copied into the image | `additional-files` | From 43baf3e4c587974b8e87476a99f9ccbedf3abb8d Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Wed, 24 May 2023 23:44:43 +0200 Subject: [PATCH 06/31] prefix build args of special files with docker folder by default --- Dockerfile | 10 +++++----- README.md | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6fb3de8..56d1a42 100644 --- a/Dockerfile +++ b/Dockerfile @@ -72,7 +72,7 @@ RUN echo "set -e" >> $WORKSPACE/.install-dependencies.sh && \ rm -rf /var/lib/apt/lists/* # add additionally specified apt dependencies to install script -ARG ADDITIONAL_DEBS_FILE="additional-debs.txt" +ARG ADDITIONAL_DEBS_FILE="docker/additional-debs.txt" ARG ADDITIONAL_DEBS_RECURSIVE="true" RUN echo "apt-get install -y \\" >> $WORKSPACE/.install-dependencies.sh && \ set -o pipefail && \ @@ -84,7 +84,7 @@ RUN echo "apt-get install -y \\" >> $WORKSPACE/.install-dependencies.sh && \ echo ";" >> $WORKSPACE/.install-dependencies.sh # add additionally specified pip dependencies to install script -ARG ADDITIONAL_PIP_FILE="additional-pip-requirements.txt" +ARG ADDITIONAL_PIP_FILE="docker/additional-pip-requirements.txt" ARG ADDITIONAL_PIP_RECURSIVE="true" RUN echo "pip install \\" >> $WORKSPACE/.install-dependencies.sh && \ set -o pipefail && \ @@ -96,7 +96,7 @@ RUN echo "pip install \\" >> $WORKSPACE/.install-dependencies.sh && \ echo ";" >> $WORKSPACE/.install-dependencies.sh # add custom installation commands to install script -ARG CUSTOM_SCRIPT_FILE="custom.sh" +ARG CUSTOM_SCRIPT_FILE="docker/custom.sh" ARG CUSTOM_SCRIPT_RECURSIVE="true" RUN if [[ $CUSTOM_SCRIPT_RECURSIVE == 'true' ]]; then \ find . -type f -name $(basename ${CUSTOM_SCRIPT_FILE}) -exec cat {} >> $WORKSPACE/.install-dependencies.sh \; \ @@ -144,8 +144,8 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* # copy contents of files-folder into image -ARG ADDITIONAL_FILES_DIR="additional-files" -ADD docker/${ADDITIONAL_FILES_DIR}* /docker-ros/$(basename ${ADDITIONAL_FILES_DIR})/ +ARG ADDITIONAL_FILES_DIR="docker/additional-files" +ADD ${ADDITIONAL_FILES_DIR}* /docker-ros/$(basename ${ADDITIONAL_FILES_DIR})/ # install essential ROS CLI tools RUN apt-get update && \ diff --git a/README.md b/README.md index 8caac69..e9f64db 100644 --- a/README.md +++ b/README.md @@ -139,10 +139,10 @@ docker-ros build args | Variable | Description | Default | | --- | --- | --- | -| `ADDITIONAL_DEBS_FILE` | filename or filepath of file containing additional system dependencies | `additional-debs.txt` | +| `ADDITIONAL_DEBS_FILE` | filename or filepath of file containing additional system dependencies | `docker/additional-debs.txt` | | `ADDITIONAL_DEBS_RECURSIVE` | whether to recursively find files named `ADDITIONAL_DEBS_FILE` | `'true'` | -| `ADDITIONAL_PIP_FILE` | filename or filepath of file containing additional pip dependencies | `additional-pip-requirements.txt` | +| `ADDITIONAL_PIP_FILE` | filename or filepath of file containing additional pip dependencies | `docker/additional-pip-requirements.txt` | | `ADDITIONAL_PIP_RECURSIVE` | whether to recursively find files named `ADDITIONAL_PIP_FILE` | `'true'` | -| `CUSTOM_SCRIPT_FILE` | filename or filepath of file containing custom script for dependency installation | `custom.sh` | +| `CUSTOM_SCRIPT_FILE` | filename or filepath of file containing custom script for dependency installation | `docker/custom.sh` | | `CUSTOM_SCRIPT_RECURSIVE` | whether to recursively find files named `CUSTOM_SCRIPT_FILE` | `'true'` | -| `ADDITIONAL_FILES_DIR` | path of directory containing additional files to be copied into the image | `additional-files` | +| `ADDITIONAL_FILES_DIR` | path of directory containing additional files to be copied into the image | `docker/additional-files` | From e98d7f3fabd257e942d115744de2ca772a5e7c45 Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Wed, 24 May 2023 23:45:23 +0200 Subject: [PATCH 07/31] disable recursive special files by default --- Dockerfile | 6 +++--- README.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 56d1a42..afd4d02 100644 --- a/Dockerfile +++ b/Dockerfile @@ -73,7 +73,7 @@ RUN echo "set -e" >> $WORKSPACE/.install-dependencies.sh && \ # add additionally specified apt dependencies to install script ARG ADDITIONAL_DEBS_FILE="docker/additional-debs.txt" -ARG ADDITIONAL_DEBS_RECURSIVE="true" +ARG ADDITIONAL_DEBS_RECURSIVE="false" RUN echo "apt-get install -y \\" >> $WORKSPACE/.install-dependencies.sh && \ set -o pipefail && \ if [[ $ADDITIONAL_DEBS_RECURSIVE == 'true' ]]; then \ @@ -85,7 +85,7 @@ RUN echo "apt-get install -y \\" >> $WORKSPACE/.install-dependencies.sh && \ # add additionally specified pip dependencies to install script ARG ADDITIONAL_PIP_FILE="docker/additional-pip-requirements.txt" -ARG ADDITIONAL_PIP_RECURSIVE="true" +ARG ADDITIONAL_PIP_RECURSIVE="false" RUN echo "pip install \\" >> $WORKSPACE/.install-dependencies.sh && \ set -o pipefail && \ if [[ $ADDITIONAL_PIP_RECURSIVE == 'true' ]]; then \ @@ -97,7 +97,7 @@ RUN echo "pip install \\" >> $WORKSPACE/.install-dependencies.sh && \ # add custom installation commands to install script ARG CUSTOM_SCRIPT_FILE="docker/custom.sh" -ARG CUSTOM_SCRIPT_RECURSIVE="true" +ARG CUSTOM_SCRIPT_RECURSIVE="false" RUN if [[ $CUSTOM_SCRIPT_RECURSIVE == 'true' ]]; then \ find . -type f -name $(basename ${CUSTOM_SCRIPT_FILE}) -exec cat {} >> $WORKSPACE/.install-dependencies.sh \; \ else \ diff --git a/README.md b/README.md index e9f64db..87fa443 100644 --- a/README.md +++ b/README.md @@ -140,9 +140,9 @@ docker-ros build args | Variable | Description | Default | | --- | --- | --- | | `ADDITIONAL_DEBS_FILE` | filename or filepath of file containing additional system dependencies | `docker/additional-debs.txt` | -| `ADDITIONAL_DEBS_RECURSIVE` | whether to recursively find files named `ADDITIONAL_DEBS_FILE` | `'true'` | +| `ADDITIONAL_DEBS_RECURSIVE` | whether to recursively find files named `ADDITIONAL_DEBS_FILE` | `'false'` | | `ADDITIONAL_PIP_FILE` | filename or filepath of file containing additional pip dependencies | `docker/additional-pip-requirements.txt` | -| `ADDITIONAL_PIP_RECURSIVE` | whether to recursively find files named `ADDITIONAL_PIP_FILE` | `'true'` | +| `ADDITIONAL_PIP_RECURSIVE` | whether to recursively find files named `ADDITIONAL_PIP_FILE` | `'false'` | | `CUSTOM_SCRIPT_FILE` | filename or filepath of file containing custom script for dependency installation | `docker/custom.sh` | -| `CUSTOM_SCRIPT_RECURSIVE` | whether to recursively find files named `CUSTOM_SCRIPT_FILE` | `'true'` | +| `CUSTOM_SCRIPT_RECURSIVE` | whether to recursively find files named `CUSTOM_SCRIPT_FILE` | `'false'` | | `ADDITIONAL_FILES_DIR` | path of directory containing additional files to be copied into the image | `docker/additional-files` | From b48a7137b0783f10f2b6803a2a2a66f97dba3da5 Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Wed, 24 May 2023 23:57:13 +0200 Subject: [PATCH 08/31] fix error in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 87fa443..844318b 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The Dockerfile performs the following steps to automatically build these images: 1. The ROS dependencies listed in each package's `package.xml` are installed by [rosdep](https://docs.ros.org/en/independent/api/rosdep/html/). 1. *(optional)* Additional system dependencies from a special file `additional-debs.txt` are installed via `apt`, if needed. 1. *(optional)* Additional Python dependencies from a special file `additional-pip-requirements.txt` are installed via `pip`, if needed. -1. *(optional)* A special folder `files/` is copied into the images, if needed. +1. *(optional)* A special folder `additional-files/` is copied into the images, if needed. 1. *(optional)* A special script `custom.sh` is executed to perform further arbitrary installation commands, if needed. 1. *(deployment)* All ROS packages are built using `catkin` (ROS) or `colcon` (ROS2). 1. *(deployment)* A custom launch command is configured to run on container start. From 4298358b773d68916ec45798c052da6f99f6dfcf Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Sat, 10 Jun 2023 20:01:31 +0200 Subject: [PATCH 09/31] pipe additional-deb-file and other args through all scripts --- .gitlab-ci/docker-ros.yml | 47 ++++++++++++++++++-------------- action.yml | 56 +++++++++++++++++++++++++++++++++++++++ scripts/build.sh | 7 +++++ scripts/ci.sh | 7 +++++ 4 files changed, 97 insertions(+), 20 deletions(-) diff --git a/.gitlab-ci/docker-ros.yml b/.gitlab-ci/docker-ros.yml index df3c81c..5dec5f6 100644 --- a/.gitlab-ci/docker-ros.yml +++ b/.gitlab-ci/docker-ros.yml @@ -9,26 +9,33 @@ workflow: variables: - TARGET: run # Target stage of Dockerfile (comma-separated list) [dev|run] - PLATFORM: '' # Target platform architecture (comma-separated list) [amd64|arm64|...] - BASE_IMAGE: '' # Base image name:tag (required) - COMMAND: '' # Launch command of run image (required if target=run) - IMAGE_NAME: ${CI_REGISTRY_IMAGE} # Image name of run image - IMAGE_TAG: latest # Image tag of run image - DEV_IMAGE_NAME: ${IMAGE_NAME} # Image name of dev image - DEV_IMAGE_TAG: ${IMAGE_TAG}-dev # Image tag of dev image - BUILD_CONTEXT: . # Build context of Docker build process - REGISTRY: ${CI_REGISTRY} # Docker registry to push images to - REGISTRY_USERNAME: ${CI_REGISTRY_USER} # Docker registry username - REGISTRY_PASSWORD: ${CI_REGISTRY_PASSWORD} # Docker registry password - ENABLE_INDUSTRIAL_CI: 'false' # Enable industrial_ci - ENABLE_SINGLEARCH_PUSH: 'false' # Enable push of single arch images with [-amd64|-arm64] postfix - ENABLE_PUSH_AS_LATEST: 'false' # Push images with tag `latest`/`latest-dev` in addition to the configured image names - GIT_HTTPS_SERVER: ${CI_SERVER_HOST} # Server URL (without protocol) for cloning private Git repositories via HTTPS - GIT_HTTPS_USER: gitlab-ci-token # Username for cloning private Git repositories via HTTPS - GIT_HTTPS_PASSWORD: ${CI_JOB_TOKEN} # Password for cloning private Git repositories via HTTPS - GIT_SSH_PRIVATE_KEY: '' # SSH private key for cloning private Git repositories via SSH - GIT_SSH_KNOWN_HOST_KEYS: '' # Known SSH host keys for cloning private Git repositories via SSH (may be obtained using `ssh-keyscan`) + TARGET: run # Target stage of Dockerfile (comma-separated list) [dev|run] + PLATFORM: '' # Target platform architecture (comma-separated list) [amd64|arm64|...] + BASE_IMAGE: '' # Base image name:tag (required) + COMMAND: '' # Launch command of run image (required if target=run) + IMAGE_NAME: ${CI_REGISTRY_IMAGE} # Image name of run image + IMAGE_TAG: latest # Image tag of run image + DEV_IMAGE_NAME: ${IMAGE_NAME} # Image name of dev image + DEV_IMAGE_TAG: ${IMAGE_TAG}-dev # Image tag of dev image + BUILD_CONTEXT: . # Build context of Docker build process + REGISTRY: ${CI_REGISTRY} # Docker registry to push images to + REGISTRY_USERNAME: ${CI_REGISTRY_USER} # Docker registry username + REGISTRY_PASSWORD: ${CI_REGISTRY_PASSWORD} # Docker registry password + ENABLE_INDUSTRIAL_CI: 'false' # Enable industrial_ci + ENABLE_SINGLEARCH_PUSH: 'false' # Enable push of single arch images with [-amd64|-arm64] postfix + ENABLE_PUSH_AS_LATEST: 'false' # Push images with tag `latest`/`latest-dev` in addition to the configured image names + GIT_HTTPS_SERVER: ${CI_SERVER_HOST} # Server URL (without protocol) for cloning private Git repositories via HTTPS + GIT_HTTPS_USER: gitlab-ci-token # Username for cloning private Git repositories via HTTPS + GIT_HTTPS_PASSWORD: ${CI_JOB_TOKEN} # Password for cloning private Git repositories via HTTPS + GIT_SSH_PRIVATE_KEY: '' # SSH private key for cloning private Git repositories via SSH + GIT_SSH_KNOWN_HOST_KEYS: '' # Known SSH host keys for cloning private Git repositories via SSH (may be obtained using `ssh-keyscan`) + ADDITIONAL_DEBS_FILE: docker/additional-debs.txt # Relative filepath to file containing additional apt deb packages to install + ADDITIONAL_DEBS_RECURSIVE: 'false' # Enable recursive discovery of files named `additional-debs-file` + ADDITIONAL_FILES_DIR: docker/additional-files # Relative path to directory containing additional files to copy into image" + ADDITIONAL_PIP_FILE: docker/additional-pip-requirements.txt # Relative filepath to file containing additional pip packages to install + ADDITIONAL_PIP_RECURSIVE: 'false' # Enable recursive discovery of files named `additional-pip-file` + CUSTOM_SCRIPT_FILE: docker/custom.sh # Relative filepath to script containing custom installation commands + CUSTOM_SCRIPT_RECURSIVE: 'false' # Enable recursive discovery of files named `custom-script-file` # ----- DOCKER_ROS_GIT_REF: main diff --git a/action.yml b/action.yml index 0507066..daf39b5 100644 --- a/action.yml +++ b/action.yml @@ -65,6 +65,41 @@ inputs: git-ssh-known-host-keys: description: "Known SSH host keys for cloning private Git repositories via SSH (may be obtained using `ssh-keyscan`)" + # TODO: no default, instead only process if explicitly specified? + additional-debs-file: + description: "Relative filepath to file containing additional apt deb packages to install" + default: docker/additional-debs.txt + + # TODO: rename to enable_*? + additional-debs-recursive: + description: "Enable recursive discovery of files named `additional-debs-file`" + default: false + + # TODO: no default, instead only process if explicitly specified? + additional-files-dir: + description: "Relative path to directory containing additional files to copy into image" + default: docker/additional-files + + # TODO: no default, instead only process if explicitly specified? + additional-pip-file: + description: "Relative filepath to file containing additional pip packages to install" + default: docker/additional-pip-requirements.txt + + # TODO: rename to enable_*? + additional-pip-recursive: + description: "Enable recursive discovery of files named `additional-pip-file`" + default: false + + # TODO: no default, instead only process if explicitly specified? + custom-script-file: + description: "Relative filepath to script containing custom installation commands" + default: docker/custom.sh + + # TODO: rename to enable_*? + custom-script-recursive: + description: "Enable recursive discovery of files named `custom-script-file`" + default: false + enable-industrial-ci: description: "Enable industrial_ci" default: false @@ -135,6 +170,13 @@ runs: GIT_HTTPS_PASSWORD: ${{ inputs.git-https-password }} GIT_SSH_PRIVATE_KEY: ${{ inputs.git-ssh-private-key }} GIT_SSH_KNOWN_HOST_KEYS: ${{ inputs.git-ssh-known-host-keys }} + ADDITIONAL_DEBS_FILE: ${{ inputs.additional-debs-file }} + ADDITIONAL_DEBS_RECURSIVE: ${{ inputs.additional-debs-recursive }} + ADDITIONAL_FILES_DIR: ${{ inputs.additional-files-dir }} + ADDITIONAL_PIP_FILE: ${{ inputs.additional-pip-file }} + ADDITIONAL_PIP_RECURSIVE: ${{ inputs.additional-pip-recursive }} + CUSTOM_SCRIPT_FILE: ${{ inputs.custom-script-file }} + CUSTOM_SCRIPT_RECURSIVE: ${{ inputs.custom-script-recursive }} - name: Set up industrial_ci if: ${{ inputs.enable-industrial-ci == 'true' }} @@ -180,6 +222,13 @@ runs: GIT_HTTPS_PASSWORD: ${{ inputs.git-https-password }} GIT_SSH_PRIVATE_KEY: ${{ inputs.git-ssh-private-key }} GIT_SSH_KNOWN_HOST_KEYS: ${{ inputs.git-ssh-known-host-keys }} + ADDITIONAL_DEBS_FILE: ${{ inputs.additional-debs-file }} + ADDITIONAL_DEBS_RECURSIVE: ${{ inputs.additional-debs-recursive }} + ADDITIONAL_FILES_DIR: ${{ inputs.additional-files-dir }} + ADDITIONAL_PIP_FILE: ${{ inputs.additional-pip-file }} + ADDITIONAL_PIP_RECURSIVE: ${{ inputs.additional-pip-recursive }} + CUSTOM_SCRIPT_FILE: ${{ inputs.custom-script-file }} + CUSTOM_SCRIPT_RECURSIVE: ${{ inputs.custom-script-recursive }} _ENABLE_IMAGE_PUSH: true _IMAGE_POSTFIX: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) && format('_{0}_ci', steps.slugify-ref-name.outputs.slug) || '' }} @@ -203,5 +252,12 @@ runs: GIT_HTTPS_PASSWORD: ${{ inputs.git-https-password }} GIT_SSH_PRIVATE_KEY: ${{ inputs.git-ssh-private-key }} GIT_SSH_KNOWN_HOST_KEYS: ${{ inputs.git-ssh-known-host-keys }} + ADDITIONAL_DEBS_FILE: ${{ inputs.additional-debs-file }} + ADDITIONAL_DEBS_RECURSIVE: ${{ inputs.additional-debs-recursive }} + ADDITIONAL_FILES_DIR: ${{ inputs.additional-files-dir }} + ADDITIONAL_PIP_FILE: ${{ inputs.additional-pip-file }} + ADDITIONAL_PIP_RECURSIVE: ${{ inputs.additional-pip-recursive }} + CUSTOM_SCRIPT_FILE: ${{ inputs.custom-script-file }} + CUSTOM_SCRIPT_RECURSIVE: ${{ inputs.custom-script-recursive }} _ENABLE_IMAGE_PUSH: true _IMAGE_POSTFIX: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) && format('_{0}_ci', steps.slugify-ref-name.outputs.slug) || '' }} \ No newline at end of file diff --git a/scripts/build.sh b/scripts/build.sh index 1486b3d..dc0530d 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -22,6 +22,13 @@ build_image() { --build-arg GIT_HTTPS_PASSWORD="${GIT_HTTPS_PASSWORD}" \ --build-arg GIT_SSH_PRIVATE_KEY="${GIT_SSH_PRIVATE_KEY}" \ --build-arg GIT_SSH_KNOWN_HOST_KEYS="${GIT_SSH_KNOWN_HOST_KEYS}" \ + --build-arg ADDITIONAL_DEBS_FILE="${ADDITIONAL_DEBS_FILE}" \ + --build-arg ADDITIONAL_DEBS_RECURSIVE="${ADDITIONAL_DEBS_RECURSIVE}" \ + --build-arg ADDITIONAL_FILES_DIR="${ADDITIONAL_FILES_DIR}" \ + --build-arg ADDITIONAL_PIP_FILE="${ADDITIONAL_PIP_FILE}" \ + --build-arg ADDITIONAL_PIP_RECURSIVE="${ADDITIONAL_PIP_RECURSIVE}" \ + --build-arg CUSTOM_SCRIPT_FILE="${CUSTOM_SCRIPT_FILE}" \ + --build-arg CUSTOM_SCRIPT_RECURSIVE="${CUSTOM_SCRIPT_RECURSIVE}" \ . echo "Successfully built stage '${TARGET}' for platform '${PLATFORM}' as '${IMAGE}'" } diff --git a/scripts/ci.sh b/scripts/ci.sh index f9dad06..a4bf62f 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -25,6 +25,13 @@ GIT_HTTPS_USER="${GIT_HTTPS_USER:-''}" GIT_HTTPS_PASSWORD="${GIT_HTTPS_PASSWORD:-''}" GIT_SSH_PRIVATE_KEY="${GIT_SSH_PRIVATE_KEY:-''}" GIT_SSH_KNOWN_HOST_KEYS="${GIT_SSH_KNOWN_HOST_KEYS:-''}" +ADDITIONAL_DEBS_FILE="${ADDITIONAL_DEBS_FILE:-'docker/additional-debs.txt'}" +ADDITIONAL_DEBS_RECURSIVE="${ADDITIONAL_DEBS_RECURSIVE:-'false'}" +ADDITIONAL_FILES_DIR="${ADDITIONAL_FILES_DIR:-'docker/additional-files'}" +ADDITIONAL_PIP_FILE="${ADDITIONAL_PIP_FILE:-'docker/additional-pip-requirements.txt'}" +ADDITIONAL_PIP_RECURSIVE="${ADDITIONAL_PIP_RECURSIVE:-'false'}" +CUSTOM_SCRIPT_FILE="${CUSTOM_SCRIPT_FILE:-'docker/custom.sh'}" +CUSTOM_SCRIPT_RECURSIVE="${CUSTOM_SCRIPT_RECURSIVE:-'false'}" _ENABLE_IMAGE_PUSH="${_ENABLE_IMAGE_PUSH:-false}" _IMAGE_POSTFIX="${_IMAGE_POSTFIX:-""}" From bba045ce5eb59e4a88363e70562943562e5f6410 Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Sat, 10 Jun 2023 20:06:13 +0200 Subject: [PATCH 10/31] mention additional-deb-file and other args in readme --- README.md | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 77ad281..0f6535c 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,8 @@ - [Build multi-arch images on arch-specific self-hosted runners in parallel](#build-multi-arch-images-on-arch-specific-self-hosted-runners-in-parallel) - [Build images locally](#build-images-locally) - [Advanced Dependencies](#advanced-dependencies) - - [Extra System Dependencies (apt)](#extra-system-dependencies-apt) + - [Extra System Dependencies (*apt*)](#extra-system-dependencies-apt) + - [Extra System Dependencies (*pip*)](#extra-system-dependencies-pip) - [Custom Installation Script](#custom-installation-script) - [Extra Image Files](#extra-image-files) - [Configuration Variables](#configuration-variables) @@ -274,23 +275,29 @@ jobs: In order to keep things organized, we recommend to place all *docker-ros* related files in a `docker` folder on top repository level. -### Extra System Dependencies (apt) +### Extra System Dependencies (*apt*) -If your ROS-based repository requires system dependencies that cannot be installed by specifying their [rosdep](https://docs.ros.org/en/independent/api/rosdep/html/) keys in a `package.xml`, you can use the special `additional.apt-dependencies` file. +If your ROS-based repository requires system dependencies that cannot be installed by specifying their [rosdep](https://docs.ros.org/en/independent/api/rosdep/html/) keys in a `package.xml`, you can use a special `additional-debs.txt` file. -Create a file `additional.apt-dependencies` in your `docker` folder and list any other dependencies that need to be installed via apt. +Create a file `additional-debs.txt` in your `docker` folder (or configure a different `ADDITIONAL_DEBS_FILE`) and list any other dependencies that need to be installed via *apt*. + +### Extra System Dependencies (*pip*) + +If your ROS-based repository requires Python dependencies that cannot be installed by specifying their [rosdep](https://docs.ros.org/en/independent/api/rosdep/html/) keys in a `package.xml`, you can use a special `additional-pip-requirements.txt` file. + +Create a file `additional-pip-requirements.txt` in your `docker` folder (or configure a different `ADDITIONAL_PIP_FILE`) and list any other Python dependencies that need to be installed via *pip*. ### Custom Installation Script -If your ROS-based repository requires to execute any other installation or pre-/post-installation steps, you can use the special `custom.sh` script. +If your ROS-based repository requires to execute any other installation or pre-/post-installation steps, you can use a special `custom.sh` script. -Create a script `custom.sh` in your `docker` folder that executes arbitrary commands as part of the image building process. +Create a script `custom.sh` in your `docker` folder (or configure a different `CUSTOM_SCRIPT_FILE`) that executes arbitrary commands as part of the image building process. ### Extra Image Files -If you need to have additional files present in the deployment image, you can use the special `files` folder. These will be copied into the container before the custom installation script `custom.sh` is executed. +If you need to have additional files present in the deployment image, you can use a special `additional-files` folder. The folder contents will be copied into the container before the custom installation script `custom.sh` is executed. -Create a folder `files` in your `docker` folder and place any files or directories in it. The contents will be copied to `/docker-ros/files` in the image. +Create a folder `additional-files` in your `docker` folder (or configure a different `ADDITIONAL_FILES_DIR`) and place any files or directories in it. The contents will be copied to `/docker-ros` in the image. ## Configuration Variables @@ -298,6 +305,21 @@ Create a folder `files` in your `docker` folder and place any files or directori > **Note** > *GitHub Action input* | *GitLab CI environment variable* +- **`additional-debs-file` | `ADDITIONAL_DEBS_FILE`** + Relative filepath to file containing additional apt deb packages to install + *default:* `docker/additional-debs.txt` +- **`additional-debs-recursive` | `ADDITIONAL_DEBS_RECURSIVE`** + Enable recursive discovery of files named `additional-debs-file` + *default:* `false` +- **`additional-files-dir` | `ADDITIONAL_FILES_DIR`** + Relative path to directory containing additional files to copy into image + *default:* `docker/additional-files` +- **`additional-pip-file` | `ADDITIONAL_PIP_FILE`** + Relative filepath to file containing additional pip packages to install + *default:* `docker/additional-pip-requirements.txt` +- **`additional-pip-recursive` | `ADDITIONAL_PIP_RECURSIVE`** + Enable recursive discovery of files named `additional-pip-file` + *default:* `false` - **`base-image` | `BASE_IMAGE`** Base image `name:tag` *required* @@ -307,6 +329,12 @@ Create a folder `files` in your `docker` folder and place any files or directori - **`command` | `COMMAND`** Launch command of run image *required if `target=run`* +- **`custom-script-file` | `CUSTOM_SCRIPT_FILE`** + Relative filepath to script containing custom installation commands + *default:* `docker/custom.sh` +- **`custom-script-recursive` | `CUSTOM_SCRIPT_RECURSIVE`** + Enable recursive discovery of files named `custom-script-file` + *default:* `false` - **`dev-image-name` | `DEV_IMAGE_NAME`** Image name of dev image *default:* `` From 4b0b5e65c32710d4f338c3948f3d8cee322859cf Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Sat, 10 Jun 2023 20:18:21 +0200 Subject: [PATCH 11/31] pass ROS_DISTRO arg through all scripts --- .gitlab-ci/docker-ros.yml | 1 + README.md | 10 +++++++--- action.yml | 6 ++++++ scripts/build.sh | 1 + scripts/ci.sh | 1 + 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci/docker-ros.yml b/.gitlab-ci/docker-ros.yml index 5dec5f6..3b7f8f5 100644 --- a/.gitlab-ci/docker-ros.yml +++ b/.gitlab-ci/docker-ros.yml @@ -24,6 +24,7 @@ variables: ENABLE_INDUSTRIAL_CI: 'false' # Enable industrial_ci ENABLE_SINGLEARCH_PUSH: 'false' # Enable push of single arch images with [-amd64|-arm64] postfix ENABLE_PUSH_AS_LATEST: 'false' # Push images with tag `latest`/`latest-dev` in addition to the configured image names + ROS_DISTRO: '' # ROS Distro (required if ROS is not installed in `base-image`) GIT_HTTPS_SERVER: ${CI_SERVER_HOST} # Server URL (without protocol) for cloning private Git repositories via HTTPS GIT_HTTPS_USER: gitlab-ci-token # Username for cloning private Git repositories via HTTPS GIT_HTTPS_PASSWORD: ${CI_JOB_TOKEN} # Password for cloning private Git repositories via HTTPS diff --git a/README.md b/README.md index 0f6535c..1141b6a 100644 --- a/README.md +++ b/README.md @@ -376,15 +376,19 @@ Create a folder `additional-files` in your `docker` folder (or configure a diffe Target platform architecture (comma-separated list) *default:* runner architecture *supported values:* `amd64`, `arm64` +- **`registry` | `REGISTRY`** + Docker registry to push images to + *default:* `ghcr.io` | `$CI_REGISTRY` - **`registry-password` | `REGISTRY_PASSWORD`** Docker registry password *default:* `${{ github.token }}` | `$CI_REGISTRY_PASSWORD` - **`registry-username` | `REGISTRY_USERNAME`** Docker registry username *default:* `${{ github.actor }}` | `$CI_REGISTRY_USER` -- **`registry` | `REGISTRY`** - Docker registry to push images to - *default:* `ghcr.io` | `$CI_REGISTRY` +- **`ros-distro` | `ROS_DISTRO`** + ROS Distro + *required if ROS is not installed in `base-image`* + *supported values:* `rolling`, ..., `noetic`, ... - **`target` | `TARGET`** Target stage of Dockerfile (comma-separated list) *default:* `run` diff --git a/action.yml b/action.yml index daf39b5..61bf45f 100644 --- a/action.yml +++ b/action.yml @@ -46,6 +46,9 @@ inputs: registry-password: description: "Docker registry password" default: ${{ github.token }} + + ros-distro: + description: "ROS Distro (required if ROS is not installed in `base-image`)" git-https-server: description: "Server URL (without protocol) for cloning private Git repositories via HTTPS" @@ -165,6 +168,7 @@ runs: IMAGE_TAG: ${{ inputs.image-tag }} DEV_IMAGE_NAME: ${{ inputs.dev-image-name }} DEV_IMAGE_TAG: ${{ inputs.dev-image-tag }} + ROS_DISTRO: ${{ inputs.ros-distro }} GIT_HTTPS_SERVER: ${{ inputs.git-https-server }} GIT_HTTPS_USER: ${{ inputs.git-https-user }} GIT_HTTPS_PASSWORD: ${{ inputs.git-https-password }} @@ -217,6 +221,7 @@ runs: DEV_IMAGE_NAME: ${{ inputs.dev-image-name }} DEV_IMAGE_TAG: ${{ inputs.dev-image-tag }} ENABLE_SINGLEARCH_PUSH: ${{ inputs.enable-singlearch-push }} + ROS_DISTRO: ${{ inputs.ros-distro }} GIT_HTTPS_SERVER: ${{ inputs.git-https-server }} GIT_HTTPS_USER: ${{ inputs.git-https-user }} GIT_HTTPS_PASSWORD: ${{ inputs.git-https-password }} @@ -247,6 +252,7 @@ runs: DEV_IMAGE_NAME: ${{ inputs.dev-image-name }} DEV_IMAGE_TAG: latest-dev ENABLE_SINGLEARCH_PUSH: ${{ inputs.enable-singlearch-push }} + ROS_DISTRO: ${{ inputs.ros-distro }} GIT_HTTPS_SERVER: ${{ inputs.git-https-server }} GIT_HTTPS_USER: ${{ inputs.git-https-user }} GIT_HTTPS_PASSWORD: ${{ inputs.git-https-password }} diff --git a/scripts/build.sh b/scripts/build.sh index dc0530d..435ef22 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -17,6 +17,7 @@ build_image() { $(if [[ "${_ENABLE_IMAGE_PUSH}" == "true" ]]; then echo "--push"; else echo "--load"; fi) \ --build-arg BASE_IMAGE="${BASE_IMAGE}" \ --build-arg COMMAND="${COMMAND}" \ + $(if [[ -n "${ROS_DISTRO}" ]]; then echo "--build-arg ROS_DISTRO=${ROS_DISTRO}"; fi) \ --build-arg GIT_HTTPS_SERVER="${GIT_HTTPS_SERVER}" \ --build-arg GIT_HTTPS_USER="${GIT_HTTPS_USER}" \ --build-arg GIT_HTTPS_PASSWORD="${GIT_HTTPS_PASSWORD}" \ diff --git a/scripts/ci.sh b/scripts/ci.sh index a4bf62f..532dc18 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -20,6 +20,7 @@ DEV_IMAGE_TAG="${DEV_IMAGE_TAG:-${IMAGE_TAG}-dev}" IMAGE="${IMAGE_NAME}:${IMAGE_TAG}" DEV_IMAGE="${DEV_IMAGE_NAME}:${DEV_IMAGE_TAG}" ENABLE_SINGLEARCH_PUSH="${ENABLE_SINGLEARCH_PUSH:-false}" +ROS_DISTRO="${ROS_DISTRO:-''}" GIT_HTTPS_SERVER="${GIT_HTTPS_SERVER:-''}" GIT_HTTPS_USER="${GIT_HTTPS_USER:-''}" GIT_HTTPS_PASSWORD="${GIT_HTTPS_PASSWORD:-''}" From 2023e2072c23ebd8839f38767130d640e62bfba0 Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Sat, 10 Jun 2023 20:20:39 +0200 Subject: [PATCH 12/31] fix destination of additional files in dockerfile --- README.md | 2 +- docker/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1141b6a..9e5c1b1 100644 --- a/README.md +++ b/README.md @@ -297,7 +297,7 @@ Create a script `custom.sh` in your `docker` folder (or configure a different `C If you need to have additional files present in the deployment image, you can use a special `additional-files` folder. The folder contents will be copied into the container before the custom installation script `custom.sh` is executed. -Create a folder `additional-files` in your `docker` folder (or configure a different `ADDITIONAL_FILES_DIR`) and place any files or directories in it. The contents will be copied to `/docker-ros` in the image. +Create a folder `additional-files` in your `docker` folder (or configure a different `ADDITIONAL_FILES_DIR`) and place any files or directories in it. The contents will be copied to `/docker-ros/additional-files` in the image. ## Configuration Variables diff --git a/docker/Dockerfile b/docker/Dockerfile index bbbedfd..0b2d07f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -155,7 +155,7 @@ RUN apt-get update && \ # copy contents of files-folder into image ARG ADDITIONAL_FILES_DIR="docker/additional-files" -ADD ${ADDITIONAL_FILES_DIR}* /docker-ros/$(basename ${ADDITIONAL_FILES_DIR})/ +ADD ${ADDITIONAL_FILES_DIR}* /docker-ros/additional-files/ # install essential ROS CLI tools RUN apt-get update && \ From 21c49723ef2ae12216458f50a9cae6bfe7dccd01 Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Sat, 10 Jun 2023 20:33:30 +0200 Subject: [PATCH 13/31] make if brackets consistent in dockerfile --- docker/Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 0b2d07f..aae6858 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -50,12 +50,12 @@ RUN shopt -s dotglob && \ ARG GIT_HTTPS_SERVER= ARG GIT_HTTPS_USER= ARG GIT_HTTPS_PASSWORD= -RUN if [ -n ${GIT_HTTPS_SERVER} ]; then \ +RUN if [[ -n ${GIT_HTTPS_SERVER} ]]; then \ git config --global url.https://${GIT_HTTPS_USER}:${GIT_HTTPS_PASSWORD}@${GIT_HTTPS_SERVER}.insteadOf https://${GIT_HTTPS_SERVER} ; \ fi ARG GIT_SSH_PRIVATE_KEY= ARG GIT_SSH_KNOWN_HOST_KEYS= -RUN if [ -n ${GIT_SSH_PRIVATE_KEY} ]; then \ +RUN if [[ -n ${GIT_SSH_PRIVATE_KEY} ]]; then \ echo -e ${GIT_SSH_PRIVATE_KEY} > /tmp/ssh_id && \ chmod 400 /tmp/ssh_id && \ git config --global core.sshCommand "ssh -i /.ssh_key" && \ @@ -164,10 +164,10 @@ RUN apt-get update && \ gosu \ python3-pip \ && source /opt/ros/$ROS_DISTRO/setup.bash && \ - if [ "$ROS_VERSION" == "1" ]; then \ + if [[ "$ROS_VERSION" == "1" ]]; then \ apt-get install -y \ python3-catkin-tools ; \ - elif [ "$ROS_VERSION" == "2" ]; then \ + elif [[ "$ROS_VERSION" == "2" ]]; then \ apt-get install -y \ python3-colcon-common-extensions ; \ fi \ @@ -200,10 +200,10 @@ CMD ["bash"] FROM dev as build # build ROS workspace -RUN if [ -x "$(command -v colcon)" ]; then \ +RUN if [[ -x "$(command -v colcon)" ]]; then \ source /opt/ros/${ROS_DISTRO}/setup.bash && \ colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release ; \ - elif [ -x "$(command -v catkin)" ]; then \ + elif [[ -x "$(command -v catkin)" ]]; then \ catkin config --install --extend /opt/ros/${ROS_DISTRO} && \ catkin build -DCMAKE_BUILD_TYPE=Release --force-color --no-status --summarize ; \ fi From 63b16f24e26f5adf414543f2731747886e8903dd Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Sat, 10 Jun 2023 21:47:09 +0200 Subject: [PATCH 14/31] fix path to special files if not recursive --- docker/Dockerfile | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index aae6858..78c2b8f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -82,39 +82,47 @@ RUN echo "set -e" >> $WORKSPACE/.install-dependencies.sh && \ rm -rf /var/lib/apt/lists/* # add additionally specified apt dependencies to install script +# TODO: if repository is top-level package, WORKDIR would need to be $WORKSPACE/src/target/ +WORKDIR $WORKSPACE/src/target ARG ADDITIONAL_DEBS_FILE="docker/additional-debs.txt" ARG ADDITIONAL_DEBS_RECURSIVE="false" RUN echo "apt-get install -y \\" >> $WORKSPACE/.install-dependencies.sh && \ set -o pipefail && \ if [[ $ADDITIONAL_DEBS_RECURSIVE == 'true' ]]; then \ - find . -type f -name $(basename {ADDITIONAL_DEBS_FILE}) -exec sed '$a\' {} \; | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh \ - else \ - test -f ${ADDITIONAL_DEBS_FILE} && cat ${ADDITIONAL_DEBS_FILE} | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh \ + find . -type f -name $(basename {ADDITIONAL_DEBS_FILE}) -exec sed '$a\' {} \; | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh ; \ + elif [[ -f ${ADDITIONAL_DEBS_FILE} ]]; then \ + cat ${ADDITIONAL_DEBS_FILE} | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh ; \ fi && \ echo ";" >> $WORKSPACE/.install-dependencies.sh # add additionally specified pip dependencies to install script +# TODO: if repository is top-level package, WORKDIR would need to be $WORKSPACE/src/target/ +WORKDIR $WORKSPACE/src/target ARG ADDITIONAL_PIP_FILE="docker/additional-pip-requirements.txt" ARG ADDITIONAL_PIP_RECURSIVE="false" -RUN echo "pip install \\" >> $WORKSPACE/.install-dependencies.sh && \ +RUN echo "pip install pip \\" >> $WORKSPACE/.install-dependencies.sh && \ set -o pipefail && \ if [[ $ADDITIONAL_PIP_RECURSIVE == 'true' ]]; then \ - find . -type f -name $(basename {ADDITIONAL_PIP_FILE}) -exec sed '$a\' {} \; | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh \ - else \ - test -f ${ADDITIONAL_PIP_FILE} && cat ${ADDITIONAL_PIP_FILE} | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh \ + find . -type f -name $(basename ${ADDITIONAL_PIP_FILE}) -exec sed '$a\' {} \; | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh ; \ + elif [[ -f ${ADDITIONAL_PIP_FILE} ]]; then \ + cat ${ADDITIONAL_PIP_FILE} | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh ; \ fi && \ echo ";" >> $WORKSPACE/.install-dependencies.sh # add custom installation commands to install script +# TODO: if repository is top-level package, WORKDIR would need to be $WORKSPACE/src/target/ +WORKDIR $WORKSPACE/src/target ARG CUSTOM_SCRIPT_FILE="docker/custom.sh" ARG CUSTOM_SCRIPT_RECURSIVE="false" RUN if [[ $CUSTOM_SCRIPT_RECURSIVE == 'true' ]]; then \ - find . -type f -name $(basename ${CUSTOM_SCRIPT_FILE}) -exec sed '$a\' {} >> $WORKSPACE/.install-dependencies.sh \; \ - else \ - test -f ${CUSTOM_SCRIPT_FILE} && cat ${CUSTOM_SCRIPT_FILE} >> $WORKSPACE/.install-dependencies.sh \ + find . -type f -name $(basename ${CUSTOM_SCRIPT_FILE}) -exec sed '$a\' {} >> $WORKSPACE/.install-dependencies.sh \; ; \ + elif [[ -f ${CUSTOM_SCRIPT_FILE} ]]; then \ + cat ${CUSTOM_SCRIPT_FILE} >> $WORKSPACE/.install-dependencies.sh ; \ fi # remove now obsolete docker folder from copied repository content to avoid redundancies +# TODO: there is no need for a docker folder, all could be stored elsewhere +WORKDIR $WORKSPACE RUN rm -rf src/target/docker ############ dependencies-install ############################################## @@ -162,6 +170,7 @@ RUN apt-get update && \ apt-get install -y \ build-essential \ gosu \ + python-is-python3 \ python3-pip \ && source /opt/ros/$ROS_DISTRO/setup.bash && \ if [[ "$ROS_VERSION" == "1" ]]; then \ From a60463cc7a3952d4426bde4d5448ec92d7beeb63 Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Sat, 10 Jun 2023 21:48:08 +0200 Subject: [PATCH 15/31] set build-args with defaults only if env vars are set --- scripts/build.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index 435ef22..a6f2e81 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -23,13 +23,13 @@ build_image() { --build-arg GIT_HTTPS_PASSWORD="${GIT_HTTPS_PASSWORD}" \ --build-arg GIT_SSH_PRIVATE_KEY="${GIT_SSH_PRIVATE_KEY}" \ --build-arg GIT_SSH_KNOWN_HOST_KEYS="${GIT_SSH_KNOWN_HOST_KEYS}" \ - --build-arg ADDITIONAL_DEBS_FILE="${ADDITIONAL_DEBS_FILE}" \ - --build-arg ADDITIONAL_DEBS_RECURSIVE="${ADDITIONAL_DEBS_RECURSIVE}" \ - --build-arg ADDITIONAL_FILES_DIR="${ADDITIONAL_FILES_DIR}" \ - --build-arg ADDITIONAL_PIP_FILE="${ADDITIONAL_PIP_FILE}" \ - --build-arg ADDITIONAL_PIP_RECURSIVE="${ADDITIONAL_PIP_RECURSIVE}" \ - --build-arg CUSTOM_SCRIPT_FILE="${CUSTOM_SCRIPT_FILE}" \ - --build-arg CUSTOM_SCRIPT_RECURSIVE="${CUSTOM_SCRIPT_RECURSIVE}" \ + $(if [[ -n "${ADDITIONAL_DEBS_FILE}" ]]; then echo "--build-arg ADDITIONAL_DEBS_FILE=${ADDITIONAL_DEBS_FILE}"; fi) \ + $(if [[ -n "${ADDITIONAL_DEBS_RECURSIVE}" ]]; then echo "--build-arg ADDITIONAL_DEBS_RECURSIVE=${ADDITIONAL_DEBS_RECURSIVE}"; fi) \ + $(if [[ -n "${ADDITIONAL_FILES_DIR}" ]]; then echo "--build-arg ADDITIONAL_FILES_DIR=${ADDITIONAL_FILES_DIR}"; fi) \ + $(if [[ -n "${ADDITIONAL_PIP_FILE}" ]]; then echo "--build-arg ADDITIONAL_PIP_FILE=${ADDITIONAL_PIP_FILE}"; fi) \ + $(if [[ -n "${ADDITIONAL_PIP_RECURSIVE}" ]]; then echo "--build-arg ADDITIONAL_PIP_RECURSIVE=${ADDITIONAL_PIP_RECURSIVE}"; fi) \ + $(if [[ -n "${CUSTOM_SCRIPT_FILE}" ]]; then echo "--build-arg CUSTOM_SCRIPT_FILE=${CUSTOM_SCRIPT_FILE}"; fi) \ + $(if [[ -n "${CUSTOM_SCRIPT_RECURSIVE}" ]]; then echo "--build-arg CUSTOM_SCRIPT_RECURSIVE=${CUSTOM_SCRIPT_RECURSIVE}"; fi) \ . echo "Successfully built stage '${TARGET}' for platform '${PLATFORM}' as '${IMAGE}'" } From 2acde8362e171254c0fbf50575db97df4088b18c Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Sat, 10 Jun 2023 21:50:34 +0200 Subject: [PATCH 16/31] fix ros-distro variable by unsetting default --- scripts/ci.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/ci.sh b/scripts/ci.sh index 532dc18..8b1d0c7 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -20,12 +20,12 @@ DEV_IMAGE_TAG="${DEV_IMAGE_TAG:-${IMAGE_TAG}-dev}" IMAGE="${IMAGE_NAME}:${IMAGE_TAG}" DEV_IMAGE="${DEV_IMAGE_NAME}:${DEV_IMAGE_TAG}" ENABLE_SINGLEARCH_PUSH="${ENABLE_SINGLEARCH_PUSH:-false}" -ROS_DISTRO="${ROS_DISTRO:-''}" -GIT_HTTPS_SERVER="${GIT_HTTPS_SERVER:-''}" -GIT_HTTPS_USER="${GIT_HTTPS_USER:-''}" -GIT_HTTPS_PASSWORD="${GIT_HTTPS_PASSWORD:-''}" -GIT_SSH_PRIVATE_KEY="${GIT_SSH_PRIVATE_KEY:-''}" -GIT_SSH_KNOWN_HOST_KEYS="${GIT_SSH_KNOWN_HOST_KEYS:-''}" +ROS_DISTRO="${ROS_DISTRO:-}" +GIT_HTTPS_SERVER="${GIT_HTTPS_SERVER:-}" +GIT_HTTPS_USER="${GIT_HTTPS_USER:-}" +GIT_HTTPS_PASSWORD="${GIT_HTTPS_PASSWORD:-}" +GIT_SSH_PRIVATE_KEY="${GIT_SSH_PRIVATE_KEY:-}" +GIT_SSH_KNOWN_HOST_KEYS="${GIT_SSH_KNOWN_HOST_KEYS:-}" ADDITIONAL_DEBS_FILE="${ADDITIONAL_DEBS_FILE:-'docker/additional-debs.txt'}" ADDITIONAL_DEBS_RECURSIVE="${ADDITIONAL_DEBS_RECURSIVE:-'false'}" ADDITIONAL_FILES_DIR="${ADDITIONAL_FILES_DIR:-'docker/additional-files'}" From 9a1e71c97d85551602b428f505e11d9d66433c3f Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Sat, 10 Jun 2023 21:57:55 +0200 Subject: [PATCH 17/31] only pass optional build-args if set --- action.yml | 1 + scripts/build.sh | 10 +++++----- scripts/ci.sh | 14 +++++++------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/action.yml b/action.yml index 61bf45f..834935d 100644 --- a/action.yml +++ b/action.yml @@ -68,6 +68,7 @@ inputs: git-ssh-known-host-keys: description: "Known SSH host keys for cloning private Git repositories via SSH (may be obtained using `ssh-keyscan`)" + # TODO: where to specify defaults? action.yml + docker-ros.yml vs ci.sh vs dockerfile # TODO: no default, instead only process if explicitly specified? additional-debs-file: description: "Relative filepath to file containing additional apt deb packages to install" diff --git a/scripts/build.sh b/scripts/build.sh index a6f2e81..65f4e56 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -18,11 +18,11 @@ build_image() { --build-arg BASE_IMAGE="${BASE_IMAGE}" \ --build-arg COMMAND="${COMMAND}" \ $(if [[ -n "${ROS_DISTRO}" ]]; then echo "--build-arg ROS_DISTRO=${ROS_DISTRO}"; fi) \ - --build-arg GIT_HTTPS_SERVER="${GIT_HTTPS_SERVER}" \ - --build-arg GIT_HTTPS_USER="${GIT_HTTPS_USER}" \ - --build-arg GIT_HTTPS_PASSWORD="${GIT_HTTPS_PASSWORD}" \ - --build-arg GIT_SSH_PRIVATE_KEY="${GIT_SSH_PRIVATE_KEY}" \ - --build-arg GIT_SSH_KNOWN_HOST_KEYS="${GIT_SSH_KNOWN_HOST_KEYS}" \ + $(if [[ -n "${GIT_HTTPS_SERVER}" ]]; then echo "--build-arg GIT_HTTPS_SERVER=${GIT_HTTPS_SERVER}"; fi) \ + $(if [[ -n "${GIT_HTTPS_USER}" ]]; then echo "--build-arg GIT_HTTPS_USER=${GIT_HTTPS_USER}"; fi) \ + $(if [[ -n "${GIT_HTTPS_PASSWORD}" ]]; then echo "--build-arg GIT_HTTPS_PASSWORD=${GIT_HTTPS_PASSWORD}"; fi) \ + $(if [[ -n "${GIT_SSH_PRIVATE_KEY}" ]]; then echo "--build-arg GIT_SSH_PRIVATE_KEY=${GIT_SSH_PRIVATE_KEY}"; fi) \ + $(if [[ -n "${GIT_SSH_KNOWN_HOST_KEYS}" ]]; then echo "--build-arg GIT_SSH_KNOWN_HOST_KEYS=${GIT_SSH_KNOWN_HOST_KEYS}"; fi) \ $(if [[ -n "${ADDITIONAL_DEBS_FILE}" ]]; then echo "--build-arg ADDITIONAL_DEBS_FILE=${ADDITIONAL_DEBS_FILE}"; fi) \ $(if [[ -n "${ADDITIONAL_DEBS_RECURSIVE}" ]]; then echo "--build-arg ADDITIONAL_DEBS_RECURSIVE=${ADDITIONAL_DEBS_RECURSIVE}"; fi) \ $(if [[ -n "${ADDITIONAL_FILES_DIR}" ]]; then echo "--build-arg ADDITIONAL_FILES_DIR=${ADDITIONAL_FILES_DIR}"; fi) \ diff --git a/scripts/ci.sh b/scripts/ci.sh index 8b1d0c7..8d0bd80 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -26,13 +26,13 @@ GIT_HTTPS_USER="${GIT_HTTPS_USER:-}" GIT_HTTPS_PASSWORD="${GIT_HTTPS_PASSWORD:-}" GIT_SSH_PRIVATE_KEY="${GIT_SSH_PRIVATE_KEY:-}" GIT_SSH_KNOWN_HOST_KEYS="${GIT_SSH_KNOWN_HOST_KEYS:-}" -ADDITIONAL_DEBS_FILE="${ADDITIONAL_DEBS_FILE:-'docker/additional-debs.txt'}" -ADDITIONAL_DEBS_RECURSIVE="${ADDITIONAL_DEBS_RECURSIVE:-'false'}" -ADDITIONAL_FILES_DIR="${ADDITIONAL_FILES_DIR:-'docker/additional-files'}" -ADDITIONAL_PIP_FILE="${ADDITIONAL_PIP_FILE:-'docker/additional-pip-requirements.txt'}" -ADDITIONAL_PIP_RECURSIVE="${ADDITIONAL_PIP_RECURSIVE:-'false'}" -CUSTOM_SCRIPT_FILE="${CUSTOM_SCRIPT_FILE:-'docker/custom.sh'}" -CUSTOM_SCRIPT_RECURSIVE="${CUSTOM_SCRIPT_RECURSIVE:-'false'}" +ADDITIONAL_DEBS_FILE="${ADDITIONAL_DEBS_FILE:-}" +ADDITIONAL_DEBS_RECURSIVE="${ADDITIONAL_DEBS_RECURSIVE:-}" +ADDITIONAL_FILES_DIR="${ADDITIONAL_FILES_DIR:-}" +ADDITIONAL_PIP_FILE="${ADDITIONAL_PIP_FILE:-}" +ADDITIONAL_PIP_RECURSIVE="${ADDITIONAL_PIP_RECURSIVE:-}" +CUSTOM_SCRIPT_FILE="${CUSTOM_SCRIPT_FILE:-}" +CUSTOM_SCRIPT_RECURSIVE="${CUSTOM_SCRIPT_RECURSIVE:-}" _ENABLE_IMAGE_PUSH="${_ENABLE_IMAGE_PUSH:-false}" _IMAGE_POSTFIX="${_IMAGE_POSTFIX:-""}" From 0c4e8b466c15a931ceaa01c592ce917a907d6e8b Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Sat, 10 Jun 2023 22:14:42 +0200 Subject: [PATCH 18/31] fix support of base images without ros --- docker/Dockerfile | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 78c2b8f..e09f04b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -165,21 +165,11 @@ RUN apt-get update && \ ARG ADDITIONAL_FILES_DIR="docker/additional-files" ADD ${ADDITIONAL_FILES_DIR}* /docker-ros/additional-files/ -# install essential ROS CLI tools +# install dependencies for install script RUN apt-get update && \ apt-get install -y \ - build-essential \ - gosu \ python-is-python3 \ python3-pip \ - && source /opt/ros/$ROS_DISTRO/setup.bash && \ - if [[ "$ROS_VERSION" == "1" ]]; then \ - apt-get install -y \ - python3-catkin-tools ; \ - elif [[ "$ROS_VERSION" == "2" ]]; then \ - apt-get install -y \ - python3-colcon-common-extensions ; \ - fi \ && rm -rf /var/lib/apt/lists/* # copy install script from dependencies stage @@ -190,6 +180,21 @@ RUN apt-get update && \ $WORKSPACE/.install-dependencies.sh && \ rm -rf /var/lib/apt/lists/* +# install essential build and ROS CLI tools +RUN apt-get update && \ + apt-get install -y \ + build-essential \ + gosu \ + && source /opt/ros/$ROS_DISTRO/setup.bash && \ + if [[ "$ROS_VERSION" == "1" ]]; then \ + apt-get install -y \ + python3-catkin-tools ; \ + elif [[ "$ROS_VERSION" == "2" ]]; then \ + apt-get install -y \ + python3-colcon-common-extensions ; \ + fi \ + && rm -rf /var/lib/apt/lists/* + # source ROS RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> ~/.bashrc From 03ab8c195a1359f5ab8f62c02a1cfc2bb17aad6e Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Sat, 10 Jun 2023 22:20:14 +0200 Subject: [PATCH 19/31] temporarily change docker-ros-ci test branch --- .github/workflows/github.yml | 6 ++++-- .github/workflows/gitlab.yml | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github.yml b/.github/workflows/github.yml index 92aad0e..295dd09 100644 --- a/.github/workflows/github.yml +++ b/.github/workflows/github.yml @@ -11,7 +11,8 @@ jobs: with: owner: ika-rwth-aachen repo: docker-ros-ci - ref: main + ref: improvement/naming-of-special-files + # TODO: restore ref=main workflow_file_name: ros.yml client_payload: '{"docker-ros-git-ref": "${{ github.sha }}"}' github_token: ${{ secrets.DOCKER_ROS_CI_TRIGGER_GITHUB_TOKEN }} @@ -23,7 +24,8 @@ jobs: with: owner: ika-rwth-aachen repo: docker-ros-ci - ref: main + ref: improvement/naming-of-special-files + # TODO: restore ref=main workflow_file_name: ros2.yml client_payload: '{"docker-ros-git-ref": "${{ github.sha }}"}' github_token: ${{ secrets.DOCKER_ROS_CI_TRIGGER_GITHUB_TOKEN }} diff --git a/.github/workflows/gitlab.yml b/.github/workflows/gitlab.yml index 45e7005..961cb8b 100644 --- a/.github/workflows/gitlab.yml +++ b/.github/workflows/gitlab.yml @@ -9,7 +9,8 @@ jobs: steps: - name: Trigger pipeline run: | - curl --silent --fail --request POST --form "token=${{ secrets.DOCKER_ROS_CI_TRIGGER_GITLAB_TOKEN }}" --form "ref=main" --form "variables[DOCKER_ROS_GIT_REF]=${{ github.sha }}" "https://gitlab.ika.rwth-aachen.de/api/v4/projects/1886/trigger/pipeline" | jq -r .id > id + curl --silent --fail --request POST --form "token=${{ secrets.DOCKER_ROS_CI_TRIGGER_GITLAB_TOKEN }}" --form "ref=improvement/naming-of-special-files" --form "variables[DOCKER_ROS_GIT_REF]=${{ github.sha }}" "https://gitlab.ika.rwth-aachen.de/api/v4/projects/1886/trigger/pipeline" | jq -r .id > id + # TODO: restore ref=main - name: Upload pipeline ID uses: actions/upload-artifact@v3 with: From 93054b8c0378feb65fd042fb8c4582e116e410c3 Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Sat, 10 Jun 2023 22:27:12 +0200 Subject: [PATCH 20/31] fix instructions for local build --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9e5c1b1..4023e56 100644 --- a/README.md +++ b/README.md @@ -261,14 +261,16 @@ jobs: 2. Configure the build using the same [environment variables](#configuration-variables) as used for GitLab CI and run [`build.sh`](scripts/build.sh), e.g.: ```bash # ros-repository/ - cd docker BASE_IMAGE="rwthika/ros2:humble" \ COMMAND="ros2 run my_pkg my_node" \ IMAGE="my-image:latest" \ - ./docker-ros/scripts/build.sh + ./docker/docker-ros/scripts/build.sh ``` > **Note** - > You can save your environment variable configuration in a `.env` file and source it before running the build script. + > You can store your environment variable configuration in a `.env` file and instead run: + > ```bash + > env $(cat .env) ./docker/docker-ros/scripts/build.sh + > ``` ## Advanced Dependencies From 20061f4aa7687ad1e5d4a93db8c68f8e6fd46bdf Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Mon, 12 Jun 2023 15:48:02 +0200 Subject: [PATCH 21/31] rename to registry-user --- .gitlab-ci/docker-ros.yml | 6 +++--- README.md | 2 +- action.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci/docker-ros.yml b/.gitlab-ci/docker-ros.yml index 3b7f8f5..d664192 100644 --- a/.gitlab-ci/docker-ros.yml +++ b/.gitlab-ci/docker-ros.yml @@ -19,7 +19,7 @@ variables: DEV_IMAGE_TAG: ${IMAGE_TAG}-dev # Image tag of dev image BUILD_CONTEXT: . # Build context of Docker build process REGISTRY: ${CI_REGISTRY} # Docker registry to push images to - REGISTRY_USERNAME: ${CI_REGISTRY_USER} # Docker registry username + REGISTRY_USER: ${CI_REGISTRY_USER} # Docker registry username REGISTRY_PASSWORD: ${CI_REGISTRY_PASSWORD} # Docker registry password ENABLE_INDUSTRIAL_CI: 'false' # Enable industrial_ci ENABLE_SINGLEARCH_PUSH: 'false' # Enable push of single arch images with [-amd64|-arm64] postfix @@ -89,7 +89,7 @@ default: git checkout FETCH_HEAD cd - fi - - docker login -u ${REGISTRY_USERNAME} -p ${REGISTRY_PASSWORD} ${REGISTRY} + - docker login -u ${REGISTRY_USER} -p ${REGISTRY_PASSWORD} ${REGISTRY} - docker context create buildx-context - docker buildx create --use buildx-context - echo -e "section_end:`date +%s`:section\r\e[0K" @@ -172,7 +172,7 @@ run-arm64: AFTER_INIT_EMBED: git config --global url.https://${GIT_HTTPS_USER}:${GIT_HTTPS_PASSWORD}@${GIT_HTTPS_SERVER}.insteadOf https://${GIT_HTTPS_SERVER} DOCKER_RUN_OPTS: -u root:root before_script: - - docker login -u ${REGISTRY_USERNAME} -p ${REGISTRY_PASSWORD} ${REGISTRY} + - docker login -u ${REGISTRY_USER} -p ${REGISTRY_PASSWORD} ${REGISTRY} - apk add --update bash coreutils grep tar - |- if [[ ${CI_RUNNER_EXECUTABLE_ARCH} != ${_PLATFORM} && ${CI_RUNNER_EXECUTABLE_ARCH} != linux/${_PLATFORM} ]]; then diff --git a/README.md b/README.md index 4023e56..ba95eef 100644 --- a/README.md +++ b/README.md @@ -384,7 +384,7 @@ Create a folder `additional-files` in your `docker` folder (or configure a diffe - **`registry-password` | `REGISTRY_PASSWORD`** Docker registry password *default:* `${{ github.token }}` | `$CI_REGISTRY_PASSWORD` -- **`registry-username` | `REGISTRY_USERNAME`** +- **`registry-user` | `REGISTRY_USER`** Docker registry username *default:* `${{ github.actor }}` | `$CI_REGISTRY_USER` - **`ros-distro` | `ROS_DISTRO`** diff --git a/action.yml b/action.yml index 834935d..ea037f0 100644 --- a/action.yml +++ b/action.yml @@ -39,7 +39,7 @@ inputs: description: "Docker registry to push images to" default: ghcr.io - registry-username: # TODO: rename to user or rename git-https-username to user + registry-user: description: "Docker registry username" default: ${{ github.actor }} @@ -149,7 +149,7 @@ runs: uses: docker/login-action@v2 with: registry: ${{ inputs.registry }} - username: ${{ inputs.registry-username }} + username: ${{ inputs.registry-user }} password: ${{ inputs.registry-password }} - name: Set up Docker buildx From 96a16d0e3fb1e7cd1d5a7a3bcaa6666f7c22fedf Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Mon, 12 Jun 2023 15:49:19 +0200 Subject: [PATCH 22/31] use runner arch as default platform for gitlab-ci --- .gitlab-ci/docker-ros.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci/docker-ros.yml b/.gitlab-ci/docker-ros.yml index d664192..6da5efc 100644 --- a/.gitlab-ci/docker-ros.yml +++ b/.gitlab-ci/docker-ros.yml @@ -10,7 +10,7 @@ workflow: variables: TARGET: run # Target stage of Dockerfile (comma-separated list) [dev|run] - PLATFORM: '' # Target platform architecture (comma-separated list) [amd64|arm64|...] + PLATFORM: ${CI_RUNNER_EXECUTABLE_ARCH} # Target platform architecture (comma-separated list) [amd64|arm64|...] BASE_IMAGE: '' # Base image name:tag (required) COMMAND: '' # Launch command of run image (required if target=run) IMAGE_NAME: ${CI_REGISTRY_IMAGE} # Image name of run image From 72958203275bd0585ff8cd9016d669fcba3981e0 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Mon, 12 Jun 2023 15:50:15 +0200 Subject: [PATCH 23/31] also place single package to `~/ws/src/target` --- docker/Dockerfile | 40 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index e09f04b..e12901f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -33,18 +33,7 @@ RUN apt-get update && \ && rm -rf /var/lib/apt/lists/* # copy contents of repository -COPY . src/repository - -# if repository is a top-level package, move contents to folder -RUN shopt -s dotglob && \ - if [[ -f "src/repository/package.xml" ]]; then \ - PACKAGE_NAME=$(sed -n 's/.*\(.*\)<\/name>.*/\1/p' src/repository/package.xml) && \ - mkdir -p src/target/${PACKAGE_NAME} && \ - mv src/repository/* src/target/${PACKAGE_NAME} ; \ - else \ - mv src/repository/* src/target ; \ - fi && \ - rm -r src/repository +COPY . src/target # clone .repos upstream dependencies ARG GIT_HTTPS_SERVER= @@ -82,48 +71,41 @@ RUN echo "set -e" >> $WORKSPACE/.install-dependencies.sh && \ rm -rf /var/lib/apt/lists/* # add additionally specified apt dependencies to install script -# TODO: if repository is top-level package, WORKDIR would need to be $WORKSPACE/src/target/ -WORKDIR $WORKSPACE/src/target ARG ADDITIONAL_DEBS_FILE="docker/additional-debs.txt" ARG ADDITIONAL_DEBS_RECURSIVE="false" RUN echo "apt-get install -y \\" >> $WORKSPACE/.install-dependencies.sh && \ set -o pipefail && \ if [[ $ADDITIONAL_DEBS_RECURSIVE == 'true' ]]; then \ find . -type f -name $(basename {ADDITIONAL_DEBS_FILE}) -exec sed '$a\' {} \; | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh ; \ - elif [[ -f ${ADDITIONAL_DEBS_FILE} ]]; then \ - cat ${ADDITIONAL_DEBS_FILE} | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh ; \ + elif [[ -f src/target/${ADDITIONAL_DEBS_FILE} ]]; then \ + cat src/target/${ADDITIONAL_DEBS_FILE} | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh ; \ fi && \ echo ";" >> $WORKSPACE/.install-dependencies.sh # add additionally specified pip dependencies to install script -# TODO: if repository is top-level package, WORKDIR would need to be $WORKSPACE/src/target/ -WORKDIR $WORKSPACE/src/target ARG ADDITIONAL_PIP_FILE="docker/additional-pip-requirements.txt" ARG ADDITIONAL_PIP_RECURSIVE="false" RUN echo "pip install pip \\" >> $WORKSPACE/.install-dependencies.sh && \ set -o pipefail && \ if [[ $ADDITIONAL_PIP_RECURSIVE == 'true' ]]; then \ find . -type f -name $(basename ${ADDITIONAL_PIP_FILE}) -exec sed '$a\' {} \; | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh ; \ - elif [[ -f ${ADDITIONAL_PIP_FILE} ]]; then \ - cat ${ADDITIONAL_PIP_FILE} | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh ; \ + elif [[ -f src/target/${ADDITIONAL_PIP_FILE} ]]; then \ + cat src/target/${ADDITIONAL_PIP_FILE} | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh ; \ fi && \ echo ";" >> $WORKSPACE/.install-dependencies.sh # add custom installation commands to install script -# TODO: if repository is top-level package, WORKDIR would need to be $WORKSPACE/src/target/ -WORKDIR $WORKSPACE/src/target ARG CUSTOM_SCRIPT_FILE="docker/custom.sh" ARG CUSTOM_SCRIPT_RECURSIVE="false" RUN if [[ $CUSTOM_SCRIPT_RECURSIVE == 'true' ]]; then \ find . -type f -name $(basename ${CUSTOM_SCRIPT_FILE}) -exec sed '$a\' {} >> $WORKSPACE/.install-dependencies.sh \; ; \ - elif [[ -f ${CUSTOM_SCRIPT_FILE} ]]; then \ - cat ${CUSTOM_SCRIPT_FILE} >> $WORKSPACE/.install-dependencies.sh ; \ + elif [[ -f src/target/${CUSTOM_SCRIPT_FILE} ]]; then \ + cat src/target/${CUSTOM_SCRIPT_FILE} >> $WORKSPACE/.install-dependencies.sh ; \ fi -# remove now obsolete docker folder from copied repository content to avoid redundancies -# TODO: there is no need for a docker folder, all could be stored elsewhere -WORKDIR $WORKSPACE -RUN rm -rf src/target/docker +# remove additional-files folder from copied repository content to avoid redundancies +ARG ADDITIONAL_FILES_DIR="docker/additional-files" +RUN rm -rf src/target/${ADDITIONAL_FILES_DIR} ############ dependencies-install ############################################## FROM ${BASE_IMAGE} AS dependencies-install @@ -162,7 +144,7 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* # copy contents of files-folder into image -ARG ADDITIONAL_FILES_DIR="docker/additional-files" +ARG ADDITIONAL_FILES_DIR ADD ${ADDITIONAL_FILES_DIR}* /docker-ros/additional-files/ # install dependencies for install script From 4309691c232911cf08e69309e2e826e101ac06e8 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Mon, 12 Jun 2023 16:10:01 +0200 Subject: [PATCH 24/31] rename recurse flags to enable-* --- .gitlab-ci/docker-ros.yml | 6 +++--- README.md | 18 +++++++++--------- action.yml | 27 ++++++++++++--------------- docker/Dockerfile | 12 ++++++------ scripts/build.sh | 6 +++--- scripts/ci.sh | 6 +++--- 6 files changed, 36 insertions(+), 39 deletions(-) diff --git a/.gitlab-ci/docker-ros.yml b/.gitlab-ci/docker-ros.yml index 6da5efc..22c0c01 100644 --- a/.gitlab-ci/docker-ros.yml +++ b/.gitlab-ci/docker-ros.yml @@ -31,12 +31,12 @@ variables: GIT_SSH_PRIVATE_KEY: '' # SSH private key for cloning private Git repositories via SSH GIT_SSH_KNOWN_HOST_KEYS: '' # Known SSH host keys for cloning private Git repositories via SSH (may be obtained using `ssh-keyscan`) ADDITIONAL_DEBS_FILE: docker/additional-debs.txt # Relative filepath to file containing additional apt deb packages to install - ADDITIONAL_DEBS_RECURSIVE: 'false' # Enable recursive discovery of files named `additional-debs-file` + ENABLE_RECURSIVE_ADDITIONAL_DEBS: 'false' # Enable recursive discovery of files named `additional-debs-file` ADDITIONAL_FILES_DIR: docker/additional-files # Relative path to directory containing additional files to copy into image" ADDITIONAL_PIP_FILE: docker/additional-pip-requirements.txt # Relative filepath to file containing additional pip packages to install - ADDITIONAL_PIP_RECURSIVE: 'false' # Enable recursive discovery of files named `additional-pip-file` + ENABLE_RECURSIVE_ADDITIONAL_PIP: 'false' # Enable recursive discovery of files named `additional-pip-file` CUSTOM_SCRIPT_FILE: docker/custom.sh # Relative filepath to script containing custom installation commands - CUSTOM_SCRIPT_RECURSIVE: 'false' # Enable recursive discovery of files named `custom-script-file` + ENABLE_RECURSIVE_CUSTOM_SCRIPT: 'false' # Enable recursive discovery of files named `custom-script-file` # ----- DOCKER_ROS_GIT_REF: main diff --git a/README.md b/README.md index ba95eef..4fbfb30 100644 --- a/README.md +++ b/README.md @@ -310,18 +310,12 @@ Create a folder `additional-files` in your `docker` folder (or configure a diffe - **`additional-debs-file` | `ADDITIONAL_DEBS_FILE`** Relative filepath to file containing additional apt deb packages to install *default:* `docker/additional-debs.txt` -- **`additional-debs-recursive` | `ADDITIONAL_DEBS_RECURSIVE`** - Enable recursive discovery of files named `additional-debs-file` - *default:* `false` - **`additional-files-dir` | `ADDITIONAL_FILES_DIR`** Relative path to directory containing additional files to copy into image *default:* `docker/additional-files` - **`additional-pip-file` | `ADDITIONAL_PIP_FILE`** Relative filepath to file containing additional pip packages to install *default:* `docker/additional-pip-requirements.txt` -- **`additional-pip-recursive` | `ADDITIONAL_PIP_RECURSIVE`** - Enable recursive discovery of files named `additional-pip-file` - *default:* `false` - **`base-image` | `BASE_IMAGE`** Base image `name:tag` *required* @@ -334,9 +328,6 @@ Create a folder `additional-files` in your `docker` folder (or configure a diffe - **`custom-script-file` | `CUSTOM_SCRIPT_FILE`** Relative filepath to script containing custom installation commands *default:* `docker/custom.sh` -- **`custom-script-recursive` | `CUSTOM_SCRIPT_RECURSIVE`** - Enable recursive discovery of files named `custom-script-file` - *default:* `false` - **`dev-image-name` | `DEV_IMAGE_NAME`** Image name of dev image *default:* `` @@ -364,6 +355,15 @@ Create a folder `additional-files` in your `docker` folder (or configure a diffe - **`git-https-user` | `GIT_HTTPS_USER`** Username for cloning private Git repositories via HTTPS *default:* `${{ github.actor }}` | `gitlab-ci-token` +- **`enable-recursive-additional-debs` | `ENABLE_RECURSIVE_ADDITIONAL_DEBS`** + Enable recursive discovery of files named `additional-debs-file` + *default:* `false` +- **`enable-recursive-additional-pip` | `ENABLE_RECURSIVE_ADDITIONAL_PIP`** + Enable recursive discovery of files named `additional-pip-file` + *default:* `false` +- **`enable-recursive-custom-script` | `ENABLE_RECURSIVE_CUSTOM_SCRIPT`** + Enable recursive discovery of files named `custom-script-file` + *default:* `false` - **`git-ssh-known-host-keys` | `GIT_SSH_KNOWN_HOST_KEYS`** Known SSH host keys for cloning private Git repositories via SSH (may be obtained using `ssh-keyscan`) - **`git-ssh-private-key` | `GIT_SSH_PRIVATE_KEY`** diff --git a/action.yml b/action.yml index ea037f0..a4ace3c 100644 --- a/action.yml +++ b/action.yml @@ -74,8 +74,7 @@ inputs: description: "Relative filepath to file containing additional apt deb packages to install" default: docker/additional-debs.txt - # TODO: rename to enable_*? - additional-debs-recursive: + enable-recursive-additional-debs: description: "Enable recursive discovery of files named `additional-debs-file`" default: false @@ -89,8 +88,7 @@ inputs: description: "Relative filepath to file containing additional pip packages to install" default: docker/additional-pip-requirements.txt - # TODO: rename to enable_*? - additional-pip-recursive: + enable-recursive-additional-pip: description: "Enable recursive discovery of files named `additional-pip-file`" default: false @@ -99,8 +97,7 @@ inputs: description: "Relative filepath to script containing custom installation commands" default: docker/custom.sh - # TODO: rename to enable_*? - custom-script-recursive: + enable-recursive-custom-script: description: "Enable recursive discovery of files named `custom-script-file`" default: false @@ -176,12 +173,12 @@ runs: GIT_SSH_PRIVATE_KEY: ${{ inputs.git-ssh-private-key }} GIT_SSH_KNOWN_HOST_KEYS: ${{ inputs.git-ssh-known-host-keys }} ADDITIONAL_DEBS_FILE: ${{ inputs.additional-debs-file }} - ADDITIONAL_DEBS_RECURSIVE: ${{ inputs.additional-debs-recursive }} + ENABLE_RECURSIVE_ADDITIONAL_DEBS: ${{ inputs.enable-recursive-additional-debs }} ADDITIONAL_FILES_DIR: ${{ inputs.additional-files-dir }} ADDITIONAL_PIP_FILE: ${{ inputs.additional-pip-file }} - ADDITIONAL_PIP_RECURSIVE: ${{ inputs.additional-pip-recursive }} + ENABLE_RECURSIVE_ADDITIONAL_PIP: ${{ inputs.enable-recursive-additional-pip }} CUSTOM_SCRIPT_FILE: ${{ inputs.custom-script-file }} - CUSTOM_SCRIPT_RECURSIVE: ${{ inputs.custom-script-recursive }} + ENABLE_RECURSIVE_CUSTOM_SCRIPT: ${{ inputs.enable-recursive-custom-script }} - name: Set up industrial_ci if: ${{ inputs.enable-industrial-ci == 'true' }} @@ -229,12 +226,12 @@ runs: GIT_SSH_PRIVATE_KEY: ${{ inputs.git-ssh-private-key }} GIT_SSH_KNOWN_HOST_KEYS: ${{ inputs.git-ssh-known-host-keys }} ADDITIONAL_DEBS_FILE: ${{ inputs.additional-debs-file }} - ADDITIONAL_DEBS_RECURSIVE: ${{ inputs.additional-debs-recursive }} + ENABLE_RECURSIVE_ADDITIONAL_DEBS: ${{ inputs.enable-recursive-additional-debs }} ADDITIONAL_FILES_DIR: ${{ inputs.additional-files-dir }} ADDITIONAL_PIP_FILE: ${{ inputs.additional-pip-file }} - ADDITIONAL_PIP_RECURSIVE: ${{ inputs.additional-pip-recursive }} + ENABLE_RECURSIVE_ADDITIONAL_PIP: ${{ inputs.enable-recursive-additional-pip }} CUSTOM_SCRIPT_FILE: ${{ inputs.custom-script-file }} - CUSTOM_SCRIPT_RECURSIVE: ${{ inputs.custom-script-recursive }} + ENABLE_RECURSIVE_CUSTOM_SCRIPT: ${{ inputs.enable-recursive-custom-script }} _ENABLE_IMAGE_PUSH: true _IMAGE_POSTFIX: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) && format('_{0}_ci', steps.slugify-ref-name.outputs.slug) || '' }} @@ -260,11 +257,11 @@ runs: GIT_SSH_PRIVATE_KEY: ${{ inputs.git-ssh-private-key }} GIT_SSH_KNOWN_HOST_KEYS: ${{ inputs.git-ssh-known-host-keys }} ADDITIONAL_DEBS_FILE: ${{ inputs.additional-debs-file }} - ADDITIONAL_DEBS_RECURSIVE: ${{ inputs.additional-debs-recursive }} + ENABLE_RECURSIVE_ADDITIONAL_DEBS: ${{ inputs.enable-recursive-additional-debs }} ADDITIONAL_FILES_DIR: ${{ inputs.additional-files-dir }} ADDITIONAL_PIP_FILE: ${{ inputs.additional-pip-file }} - ADDITIONAL_PIP_RECURSIVE: ${{ inputs.additional-pip-recursive }} + ENABLE_RECURSIVE_ADDITIONAL_PIP: ${{ inputs.enable-recursive-additional-pip }} CUSTOM_SCRIPT_FILE: ${{ inputs.custom-script-file }} - CUSTOM_SCRIPT_RECURSIVE: ${{ inputs.custom-script-recursive }} + ENABLE_RECURSIVE_CUSTOM_SCRIPT: ${{ inputs.enable-recursive-custom-script }} _ENABLE_IMAGE_PUSH: true _IMAGE_POSTFIX: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) && format('_{0}_ci', steps.slugify-ref-name.outputs.slug) || '' }} \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index e12901f..6eb8d48 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -72,10 +72,10 @@ RUN echo "set -e" >> $WORKSPACE/.install-dependencies.sh && \ # add additionally specified apt dependencies to install script ARG ADDITIONAL_DEBS_FILE="docker/additional-debs.txt" -ARG ADDITIONAL_DEBS_RECURSIVE="false" +ARG ENABLE_RECURSIVE_ADDITIONAL_DEBS="false" RUN echo "apt-get install -y \\" >> $WORKSPACE/.install-dependencies.sh && \ set -o pipefail && \ - if [[ $ADDITIONAL_DEBS_RECURSIVE == 'true' ]]; then \ + if [[ $ENABLE_RECURSIVE_ADDITIONAL_DEBS == 'true' ]]; then \ find . -type f -name $(basename {ADDITIONAL_DEBS_FILE}) -exec sed '$a\' {} \; | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh ; \ elif [[ -f src/target/${ADDITIONAL_DEBS_FILE} ]]; then \ cat src/target/${ADDITIONAL_DEBS_FILE} | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh ; \ @@ -84,10 +84,10 @@ RUN echo "apt-get install -y \\" >> $WORKSPACE/.install-dependencies.sh && \ # add additionally specified pip dependencies to install script ARG ADDITIONAL_PIP_FILE="docker/additional-pip-requirements.txt" -ARG ADDITIONAL_PIP_RECURSIVE="false" +ARG ENABLE_RECURSIVE_ADDITIONAL_PIP="false" RUN echo "pip install pip \\" >> $WORKSPACE/.install-dependencies.sh && \ set -o pipefail && \ - if [[ $ADDITIONAL_PIP_RECURSIVE == 'true' ]]; then \ + if [[ $ENABLE_RECURSIVE_ADDITIONAL_PIP == 'true' ]]; then \ find . -type f -name $(basename ${ADDITIONAL_PIP_FILE}) -exec sed '$a\' {} \; | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh ; \ elif [[ -f src/target/${ADDITIONAL_PIP_FILE} ]]; then \ cat src/target/${ADDITIONAL_PIP_FILE} | awk '{print " " $0 " \\"}' >> $WORKSPACE/.install-dependencies.sh ; \ @@ -96,8 +96,8 @@ RUN echo "pip install pip \\" >> $WORKSPACE/.install-dependencies.sh && \ # add custom installation commands to install script ARG CUSTOM_SCRIPT_FILE="docker/custom.sh" -ARG CUSTOM_SCRIPT_RECURSIVE="false" -RUN if [[ $CUSTOM_SCRIPT_RECURSIVE == 'true' ]]; then \ +ARG ENABLE_RECURSIVE_CUSTOM_SCRIPT="false" +RUN if [[ $ENABLE_RECURSIVE_CUSTOM_SCRIPT == 'true' ]]; then \ find . -type f -name $(basename ${CUSTOM_SCRIPT_FILE}) -exec sed '$a\' {} >> $WORKSPACE/.install-dependencies.sh \; ; \ elif [[ -f src/target/${CUSTOM_SCRIPT_FILE} ]]; then \ cat src/target/${CUSTOM_SCRIPT_FILE} >> $WORKSPACE/.install-dependencies.sh ; \ diff --git a/scripts/build.sh b/scripts/build.sh index 65f4e56..f561c6e 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -24,12 +24,12 @@ build_image() { $(if [[ -n "${GIT_SSH_PRIVATE_KEY}" ]]; then echo "--build-arg GIT_SSH_PRIVATE_KEY=${GIT_SSH_PRIVATE_KEY}"; fi) \ $(if [[ -n "${GIT_SSH_KNOWN_HOST_KEYS}" ]]; then echo "--build-arg GIT_SSH_KNOWN_HOST_KEYS=${GIT_SSH_KNOWN_HOST_KEYS}"; fi) \ $(if [[ -n "${ADDITIONAL_DEBS_FILE}" ]]; then echo "--build-arg ADDITIONAL_DEBS_FILE=${ADDITIONAL_DEBS_FILE}"; fi) \ - $(if [[ -n "${ADDITIONAL_DEBS_RECURSIVE}" ]]; then echo "--build-arg ADDITIONAL_DEBS_RECURSIVE=${ADDITIONAL_DEBS_RECURSIVE}"; fi) \ + $(if [[ -n "${ENABLE_RECURSIVE_ADDITIONAL_DEBS}" ]]; then echo "--build-arg ENABLE_RECURSIVE_ADDITIONAL_DEBS=${ENABLE_RECURSIVE_ADDITIONAL_DEBS}"; fi) \ $(if [[ -n "${ADDITIONAL_FILES_DIR}" ]]; then echo "--build-arg ADDITIONAL_FILES_DIR=${ADDITIONAL_FILES_DIR}"; fi) \ $(if [[ -n "${ADDITIONAL_PIP_FILE}" ]]; then echo "--build-arg ADDITIONAL_PIP_FILE=${ADDITIONAL_PIP_FILE}"; fi) \ - $(if [[ -n "${ADDITIONAL_PIP_RECURSIVE}" ]]; then echo "--build-arg ADDITIONAL_PIP_RECURSIVE=${ADDITIONAL_PIP_RECURSIVE}"; fi) \ + $(if [[ -n "${ENABLE_RECURSIVE_ADDITIONAL_PIP}" ]]; then echo "--build-arg ENABLE_RECURSIVE_ADDITIONAL_PIP=${ENABLE_RECURSIVE_ADDITIONAL_PIP}"; fi) \ $(if [[ -n "${CUSTOM_SCRIPT_FILE}" ]]; then echo "--build-arg CUSTOM_SCRIPT_FILE=${CUSTOM_SCRIPT_FILE}"; fi) \ - $(if [[ -n "${CUSTOM_SCRIPT_RECURSIVE}" ]]; then echo "--build-arg CUSTOM_SCRIPT_RECURSIVE=${CUSTOM_SCRIPT_RECURSIVE}"; fi) \ + $(if [[ -n "${ENABLE_RECURSIVE_CUSTOM_SCRIPT}" ]]; then echo "--build-arg ENABLE_RECURSIVE_CUSTOM_SCRIPT=${ENABLE_RECURSIVE_CUSTOM_SCRIPT}"; fi) \ . echo "Successfully built stage '${TARGET}' for platform '${PLATFORM}' as '${IMAGE}'" } diff --git a/scripts/ci.sh b/scripts/ci.sh index 8d0bd80..12690f3 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -27,12 +27,12 @@ GIT_HTTPS_PASSWORD="${GIT_HTTPS_PASSWORD:-}" GIT_SSH_PRIVATE_KEY="${GIT_SSH_PRIVATE_KEY:-}" GIT_SSH_KNOWN_HOST_KEYS="${GIT_SSH_KNOWN_HOST_KEYS:-}" ADDITIONAL_DEBS_FILE="${ADDITIONAL_DEBS_FILE:-}" -ADDITIONAL_DEBS_RECURSIVE="${ADDITIONAL_DEBS_RECURSIVE:-}" +ENABLE_RECURSIVE_ADDITIONAL_DEBS="${ENABLE_RECURSIVE_ADDITIONAL_DEBS:-}" ADDITIONAL_FILES_DIR="${ADDITIONAL_FILES_DIR:-}" ADDITIONAL_PIP_FILE="${ADDITIONAL_PIP_FILE:-}" -ADDITIONAL_PIP_RECURSIVE="${ADDITIONAL_PIP_RECURSIVE:-}" +ENABLE_RECURSIVE_ADDITIONAL_PIP="${ENABLE_RECURSIVE_ADDITIONAL_PIP:-}" CUSTOM_SCRIPT_FILE="${CUSTOM_SCRIPT_FILE:-}" -CUSTOM_SCRIPT_RECURSIVE="${CUSTOM_SCRIPT_RECURSIVE:-}" +ENABLE_RECURSIVE_CUSTOM_SCRIPT="${ENABLE_RECURSIVE_CUSTOM_SCRIPT:-}" _ENABLE_IMAGE_PUSH="${_ENABLE_IMAGE_PUSH:-false}" _IMAGE_POSTFIX="${_IMAGE_POSTFIX:-""}" From 87ae78a36b9bd51098af63dd14a0c1304726153d Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Mon, 12 Jun 2023 16:11:38 +0200 Subject: [PATCH 25/31] remove ToDos in action.yml --- action.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/action.yml b/action.yml index a4ace3c..1377565 100644 --- a/action.yml +++ b/action.yml @@ -35,7 +35,7 @@ inputs: description: "Build context of Docker build process" default: ${{ github.workspace }} - registry: # TODO: infer from image name + registry: description: "Docker registry to push images to" default: ghcr.io @@ -68,8 +68,6 @@ inputs: git-ssh-known-host-keys: description: "Known SSH host keys for cloning private Git repositories via SSH (may be obtained using `ssh-keyscan`)" - # TODO: where to specify defaults? action.yml + docker-ros.yml vs ci.sh vs dockerfile - # TODO: no default, instead only process if explicitly specified? additional-debs-file: description: "Relative filepath to file containing additional apt deb packages to install" default: docker/additional-debs.txt @@ -78,12 +76,10 @@ inputs: description: "Enable recursive discovery of files named `additional-debs-file`" default: false - # TODO: no default, instead only process if explicitly specified? additional-files-dir: description: "Relative path to directory containing additional files to copy into image" default: docker/additional-files - # TODO: no default, instead only process if explicitly specified? additional-pip-file: description: "Relative filepath to file containing additional pip packages to install" default: docker/additional-pip-requirements.txt @@ -92,7 +88,6 @@ inputs: description: "Enable recursive discovery of files named `additional-pip-file`" default: false - # TODO: no default, instead only process if explicitly specified? custom-script-file: description: "Relative filepath to script containing custom installation commands" default: docker/custom.sh From 43f0dac2c9dd539226df303bbb6be189d1d5cea2 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Mon, 12 Jun 2023 16:26:53 +0200 Subject: [PATCH 26/31] use unique section ids for gitlab-ci collapsable sections --- .gitlab-ci/docker-ros.yml | 8 ++++---- scripts/utils.sh | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci/docker-ros.yml b/.gitlab-ci/docker-ros.yml index 22c0c01..f2d1987 100644 --- a/.gitlab-ci/docker-ros.yml +++ b/.gitlab-ci/docker-ros.yml @@ -77,7 +77,7 @@ default: - privileged - amd64 before_script: - - echo -e "section_start:`date +%s`:section[collapsed=true]\r\e[0K[docker-ros] Setup docker-ros" + - echo -e "section_start:`date +%s`:setup_section[collapsed=true]\r\e[0K[docker-ros] Setup docker-ros" - apk add bash - cd ${BUILD_CONTEXT} - |- @@ -92,7 +92,7 @@ default: - docker login -u ${REGISTRY_USER} -p ${REGISTRY_PASSWORD} ${REGISTRY} - docker context create buildx-context - docker buildx create --use buildx-context - - echo -e "section_end:`date +%s`:section\r\e[0K" + - echo -e "section_end:`date +%s`:setup_section\r\e[0K" .build: script: @@ -101,9 +101,9 @@ default: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes fi - TARGET=${_TARGET} PLATFORM=${_PLATFORM} ./docker/docker-ros/scripts/ci.sh - - echo -e "section_start:`date +%s`:section[collapsed=true]\r\e[0K[docker-ros] Push ${IMAGE}" + - echo -e "section_start:`date +%s`:push_section[collapsed=true]\r\e[0K[docker-ros] Push ${IMAGE}" - docker push ${IMAGE} - - echo -e "section_end:`date +%s`:section\r\e[0K" + - echo -e "section_end:`date +%s`:push_section\r\e[0K" dev-amd64: stage: Build dev Images diff --git a/scripts/utils.sh b/scripts/utils.sh index 9eee182..38df0fd 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -9,7 +9,7 @@ require_var() { open_log_group() { if [[ -n "${GITLAB_CI}" ]]; then - echo -e "section_start:`date +%s`:section[collapsed=true]\r\e[0K[docker-ros] ${1}" + echo -e "section_start:`date +%s`:build_section[collapsed=true]\r\e[0K[docker-ros] ${1}" elif [[ -n "${GITHUB_ACTIONS}" ]]; then echo "::group::[docker-ros] ${1}" fi @@ -17,7 +17,7 @@ open_log_group() { close_log_group() { if [[ -n "${GITLAB_CI}" ]]; then - echo -e "section_end:`date +%s`:section\r\e[0K" + echo -e "section_end:`date +%s`:build_section\r\e[0K" elif [[ -n "${GITHUB_ACTIONS}" ]]; then echo "::endgroup::" fi From b88e2d5072dd38e1c6b01e7da8c257ea458ddddf Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Mon, 12 Jun 2023 16:30:40 +0200 Subject: [PATCH 27/31] gitlab-ci use quotes for if with variable --- .gitlab-ci/docker-ros.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci/docker-ros.yml b/.gitlab-ci/docker-ros.yml index f2d1987..5b84159 100644 --- a/.gitlab-ci/docker-ros.yml +++ b/.gitlab-ci/docker-ros.yml @@ -227,19 +227,19 @@ Test dev-arm64: when: never script: - |- - if [[ ${PLATFORM} =~ amd64 && ${PLATFORM} =~ arm64 ]]; then - [[ ${TARGET} =~ dev ]] && docker manifest create ${IMG_DEV} --amend ${_IMAGE_DEV_CI_AMD64} --amend ${_IMAGE_DEV_CI_ARM64} - [[ ${TARGET} =~ run ]] && docker manifest create ${IMG_RUN} --amend ${_IMAGE_RUN_CI_AMD64} --amend ${_IMAGE_RUN_CI_ARM64} - elif [[ ${PLATFORM} == amd64 ]]; then - [[ ${TARGET} =~ dev ]] && docker manifest create ${IMG_DEV} --amend ${_IMAGE_DEV_CI_AMD64} - [[ ${TARGET} =~ run ]] && docker manifest create ${IMG_RUN} --amend ${_IMAGE_RUN_CI_AMD64} - elif [[ ${PLATFORM} == arm64 ]]; then - [[ ${TARGET} =~ dev ]] && docker manifest create ${IMG_DEV} --amend ${_IMAGE_DEV_CI_ARM64} - [[ ${TARGET} =~ run ]] && docker manifest create ${IMG_RUN} --amend ${_IMAGE_RUN_CI_ARM64} + if [[ "${PLATFORM}" =~ amd64 && "${PLATFORM}" =~ arm64 ]]; then + [[ "${TARGET}" =~ dev ]] && docker manifest create ${IMG_DEV} --amend ${_IMAGE_DEV_CI_AMD64} --amend ${_IMAGE_DEV_CI_ARM64} + [[ "${TARGET}" =~ run ]] && docker manifest create ${IMG_RUN} --amend ${_IMAGE_RUN_CI_AMD64} --amend ${_IMAGE_RUN_CI_ARM64} + elif [[ "${PLATFORM}" == amd64 ]]; then + [[ "${TARGET}" =~ dev ]] && docker manifest create ${IMG_DEV} --amend ${_IMAGE_DEV_CI_AMD64} + [[ "${TARGET}" =~ run ]] && docker manifest create ${IMG_RUN} --amend ${_IMAGE_RUN_CI_AMD64} + elif [[ "${PLATFORM}" == arm64 ]]; then + [[ "${TARGET}" =~ dev ]] && docker manifest create ${IMG_DEV} --amend ${_IMAGE_DEV_CI_ARM64} + [[ "${TARGET}" =~ run ]] && docker manifest create ${IMG_RUN} --amend ${_IMAGE_RUN_CI_ARM64} fi - |- - [[ ${TARGET} =~ dev ]] && docker manifest push ${IMG_DEV} - [[ ${TARGET} =~ run ]] && docker manifest push ${IMG_RUN} + [[ "${TARGET}" =~ dev ]] && docker manifest push ${IMG_DEV} + [[ "${TARGET}" =~ run ]] && docker manifest push ${IMG_RUN} Push CI: stage: Push Multi-Arch Images From 2c3791cdf6143ea67ab6b2ee9e60168109509c9d Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Mon, 12 Jun 2023 18:44:22 +0200 Subject: [PATCH 28/31] restore docker-ros-ci ref to main --- .github/workflows/github.yml | 6 ++---- .github/workflows/gitlab.yml | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/github.yml b/.github/workflows/github.yml index 295dd09..92aad0e 100644 --- a/.github/workflows/github.yml +++ b/.github/workflows/github.yml @@ -11,8 +11,7 @@ jobs: with: owner: ika-rwth-aachen repo: docker-ros-ci - ref: improvement/naming-of-special-files - # TODO: restore ref=main + ref: main workflow_file_name: ros.yml client_payload: '{"docker-ros-git-ref": "${{ github.sha }}"}' github_token: ${{ secrets.DOCKER_ROS_CI_TRIGGER_GITHUB_TOKEN }} @@ -24,8 +23,7 @@ jobs: with: owner: ika-rwth-aachen repo: docker-ros-ci - ref: improvement/naming-of-special-files - # TODO: restore ref=main + ref: main workflow_file_name: ros2.yml client_payload: '{"docker-ros-git-ref": "${{ github.sha }}"}' github_token: ${{ secrets.DOCKER_ROS_CI_TRIGGER_GITHUB_TOKEN }} diff --git a/.github/workflows/gitlab.yml b/.github/workflows/gitlab.yml index 961cb8b..45e7005 100644 --- a/.github/workflows/gitlab.yml +++ b/.github/workflows/gitlab.yml @@ -9,8 +9,7 @@ jobs: steps: - name: Trigger pipeline run: | - curl --silent --fail --request POST --form "token=${{ secrets.DOCKER_ROS_CI_TRIGGER_GITLAB_TOKEN }}" --form "ref=improvement/naming-of-special-files" --form "variables[DOCKER_ROS_GIT_REF]=${{ github.sha }}" "https://gitlab.ika.rwth-aachen.de/api/v4/projects/1886/trigger/pipeline" | jq -r .id > id - # TODO: restore ref=main + curl --silent --fail --request POST --form "token=${{ secrets.DOCKER_ROS_CI_TRIGGER_GITLAB_TOKEN }}" --form "ref=main" --form "variables[DOCKER_ROS_GIT_REF]=${{ github.sha }}" "https://gitlab.ika.rwth-aachen.de/api/v4/projects/1886/trigger/pipeline" | jq -r .id > id - name: Upload pipeline ID uses: actions/upload-artifact@v3 with: From f558a09faaf26b73001b1f91e8d861558a04cbe8 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Tue, 13 Jun 2023 11:22:14 +0200 Subject: [PATCH 29/31] update "About" section in README --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 495e40a..7d3168f 100644 --- a/README.md +++ b/README.md @@ -39,11 +39,12 @@ We recommend to use *docker-ros* in combination with our other tools for Docker The Dockerfile performs the following steps to build these images: 1. All dependency repositories that are defined in a `.repos` file anywhere in the repository are cloned using [*vcstool*](https://github.com/dirk-thomas/vcstool). 2. The ROS dependencies listed in each package's `package.xml` are installed by [*rosdep*](https://docs.ros.org/en/independent/api/rosdep/html/). -3. *(optional)* Additional dependencies from a special file `additional.apt-dependencies` are installed, if needed (see [*Advanced Dependencies*](#extra-system-dependencies-apt)). -4. *(optional)* A special folder `files/` is copied into the images, if needed (see [*Advanced Dependencies*](#extra-image-files)). -5. *(optional)* A special script `custom.sh` is executed to perform further arbitrary installation commands, if needed (see [*Advanced Dependencies*](#custom-installation-script)). -6. *(deployment)* All ROS packages are built using `catkin` (ROS) or `colcon` (ROS2). -7. *(deployment)* A custom launch command is configured to run on container start. +3. *(optional)* Additional apt dependencies from a special file `additional-debs.txt` are installed, if needed (see [*Advanced Dependencies*](#extra-system-dependencies-apt)). +4. *(optional)* Additional pip requirements from a special file `additional-pip-requirements.txt` are installed, if needed (see [*Advanced Dependencies*](#extra-system-dependencies-pip)). +5. *(optional)* A special folder `additional-files/` is copied into the images, if needed (see [*Advanced Dependencies*](#extra-image-files)). +6. *(optional)* A special script `custom.sh` is executed to perform further arbitrary installation commands, if needed (see [*Advanced Dependencies*](#custom-installation-script)). +7. *(deployment)* All ROS packages are built using `catkin` (ROS) or `colcon` (ROS2). +8. *(deployment)* A custom launch command is configured to run on container start. ### Prerequisites From 80354183cc1f633492f73fec616a39ce3d2dddd5 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Tue, 13 Jun 2023 11:25:06 +0200 Subject: [PATCH 30/31] change version to 1.1.0 --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7d3168f..2af2ce6 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ jobs: docker-ros: runs-on: ubuntu-latest steps: - - uses: ika-rwth-aachen/docker-ros@v1.0.0 + - uses: ika-rwth-aachen/docker-ros@v1.1.0 with: base-image: rwthika/ros2:humble command: ros2 run my_pkg my_node @@ -110,7 +110,7 @@ jobs: ```yml include: - - remote: https://raw.githubusercontent.com/ika-rwth-aachen/docker-ros/v1.0.0/.gitlab-ci/docker-ros.yml + - remote: https://raw.githubusercontent.com/ika-rwth-aachen/docker-ros/v1.1.0/.gitlab-ci/docker-ros.yml variables: BASE_IMAGE: rwthika/ros2:humble @@ -129,7 +129,7 @@ jobs: docker-ros: runs-on: ubuntu-latest steps: - - uses: ika-rwth-aachen/docker-ros@v1.0.0 + - uses: ika-rwth-aachen/docker-ros@v1.1.0 with: base-image: rwthika/ros2:humble command: ros2 run my_pkg my_node @@ -142,7 +142,7 @@ jobs: ```yml include: - - remote: https://raw.githubusercontent.com/ika-rwth-aachen/docker-ros/v1.0.0/.gitlab-ci/docker-ros.yml + - remote: https://raw.githubusercontent.com/ika-rwth-aachen/docker-ros/v1.1.0/.gitlab-ci/docker-ros.yml variables: BASE_IMAGE: rwthika/ros2:humble @@ -162,7 +162,7 @@ jobs: docker-ros: runs-on: ubuntu-latest steps: - - uses: ika-rwth-aachen/docker-ros@v1.0.0 + - uses: ika-rwth-aachen/docker-ros@v1.1.0 with: base-image: rwthika/ros2:humble command: ros2 run my_pkg my_node @@ -176,7 +176,7 @@ jobs: ```yml include: - - remote: https://raw.githubusercontent.com/ika-rwth-aachen/docker-ros/v1.0.0/.gitlab-ci/docker-ros.yml + - remote: https://raw.githubusercontent.com/ika-rwth-aachen/docker-ros/v1.1.0/.gitlab-ci/docker-ros.yml variables: BASE_IMAGE: rwthika/ros2:humble @@ -197,7 +197,7 @@ jobs: docker-ros: runs-on: ubuntu-latest steps: - - uses: ika-rwth-aachen/docker-ros@v1.0.0 + - uses: ika-rwth-aachen/docker-ros@v1.1.0 with: base-image: rwthika/ros2:humble command: ros2 run my_pkg my_node @@ -210,7 +210,7 @@ jobs: ```yml include: - - remote: https://raw.githubusercontent.com/ika-rwth-aachen/docker-ros/v1.0.0/.gitlab-ci/docker-ros.yml + - remote: https://raw.githubusercontent.com/ika-rwth-aachen/docker-ros/v1.1.0/.gitlab-ci/docker-ros.yml variables: BASE_IMAGE: rwthika/ros2:humble @@ -234,7 +234,7 @@ jobs: platform: [amd64, arm64] runs-on: [self-hosted, "${{ matrix.platform }}"] steps: - - uses: ika-rwth-aachen/docker-ros@v1.0.0 + - uses: ika-rwth-aachen/docker-ros@v1.1.0 with: base-image: rwthika/ros2:humble command: ros2 run my_pkg my_node From 0769e8f3461b4cd2bdb6e3c4cc1a7642f059efba Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Tue, 13 Jun 2023 11:37:26 +0200 Subject: [PATCH 31/31] mv build-essentials before custom.sh --- docker/Dockerfile | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 6eb8d48..9d322ab 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -147,9 +147,11 @@ RUN apt-get update && \ ARG ADDITIONAL_FILES_DIR ADD ${ADDITIONAL_FILES_DIR}* /docker-ros/additional-files/ -# install dependencies for install script +# install essential build tools and dependencies for install script RUN apt-get update && \ apt-get install -y \ + build-essential \ + gosu \ python-is-python3 \ python3-pip \ && rm -rf /var/lib/apt/lists/* @@ -162,12 +164,9 @@ RUN apt-get update && \ $WORKSPACE/.install-dependencies.sh && \ rm -rf /var/lib/apt/lists/* -# install essential build and ROS CLI tools -RUN apt-get update && \ - apt-get install -y \ - build-essential \ - gosu \ - && source /opt/ros/$ROS_DISTRO/setup.bash && \ +# install ROS CLI tools +RUN source /opt/ros/$ROS_DISTRO/setup.bash && \ + apt-get update && \ if [[ "$ROS_VERSION" == "1" ]]; then \ apt-get install -y \ python3-catkin-tools ; \