diff --git a/.gitlab-ci/docker-ros.yml b/.gitlab-ci/docker-ros.yml index 3f22462..0123469 100644 --- a/.gitlab-ci/docker-ros.yml +++ b/.gitlab-ci/docker-ros.yml @@ -17,11 +17,15 @@ variables: 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 + SLIM_IMAGE_NAME: ${IMAGE_NAME} # Image name of slim run image + SLIM_IMAGE_TAG: ${IMAGE_TAG}-slim # Image tag of slim run image BUILD_CONTEXT: . # Build context of Docker build process REGISTRY: ${CI_REGISTRY} # Docker registry to push images to REGISTRY_USER: ${CI_REGISTRY_USER} # Docker registry username REGISTRY_PASSWORD: ${CI_REGISTRY_PASSWORD} # Docker registry password ENABLE_INDUSTRIAL_CI: 'false' # Enable industrial_ci + ENABLE_SLIM: 'true' # Enable an extra slimmed run image via slim (only if run stage is targeted) + SLIM_BUILD_ARGS: '--sensor-ipc-mode proxy --continue-after=10 --show-clogs --http-probe=false' # Arguments to `slim build` (except for `--target` and `--tag`) 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 RMW_IMPLEMENTATION: 'rmw_cyclonedds_cpp' # RMW implementation to use (only for ROS 2) @@ -47,19 +51,26 @@ variables: _RUN_IMAGE: ${IMAGE_NAME}:${IMAGE_TAG} _DEV_IMAGE: ${DEV_IMAGE_NAME}:${DEV_IMAGE_TAG} + _SLIM_IMAGE: ${SLIM_IMAGE_NAME}:${SLIM_IMAGE_TAG} _IMAGE_DEV_CI: ${_DEV_IMAGE}_${CI_COMMIT_REF_SLUG}_ci _IMAGE_RUN_CI: ${_RUN_IMAGE}_${CI_COMMIT_REF_SLUG}_ci + _IMAGE_SLIM_CI: ${_SLIM_IMAGE}_${CI_COMMIT_REF_SLUG}_ci _IMAGE_DEV_CI_AMD64: ${_IMAGE_DEV_CI}-amd64 _IMAGE_DEV_CI_ARM64: ${_IMAGE_DEV_CI}-arm64 _IMAGE_RUN_CI_AMD64: ${_IMAGE_RUN_CI}-amd64 _IMAGE_RUN_CI_ARM64: ${_IMAGE_RUN_CI}-arm64 + _IMAGE_SLIM_CI_AMD64: ${_IMAGE_SLIM_CI}-amd64 + _IMAGE_SLIM_CI_ARM64: ${_IMAGE_SLIM_CI}-arm64 _IMAGE_DEV_LATEST: ${DEV_IMAGE_NAME}:latest-dev _IMAGE_RUN_LATEST: ${IMAGE_NAME}:latest + _IMAGE_SLIM_LATEST: ${SLIM_IMAGE_NAME}:latest-slim _IMAGE_DEV_TARGET_TAG: ${_DEV_IMAGE}-${CI_COMMIT_TAG} _IMAGE_RUN_TARGET_TAG: ${_RUN_IMAGE}-${CI_COMMIT_TAG} + _IMAGE_SLIM_TARGET_TAG: ${_SLIM_IMAGE}-${CI_COMMIT_TAG} _IMAGE_DEV_TAG: ${DEV_IMAGE_NAME}:${CI_COMMIT_TAG}-dev _IMAGE_RUN_TAG: ${IMAGE_NAME}:${CI_COMMIT_TAG} + _IMAGE_SLIM_TAG: ${SLIM_IMAGE_NAME}:${CI_COMMIT_TAG}-slim GIT_SUBMODULE_STRATEGY: recursive DOCKER_DRIVER: overlay2 @@ -71,6 +82,7 @@ stages: - Build dev Images - Build run Images - Test ROS Industrial CI + - Slim Images - Push Multi-Arch Images @@ -83,7 +95,7 @@ default: - amd64 before_script: - echo -e "section_start:`date +%s`:setup_section[collapsed=true]\r\e[0K[docker-ros] Setup docker-ros" - - apk add bash + - apk add --update bash - cd ${BUILD_CONTEXT} - |- if [[ ! -d docker/docker-ros ]]; then @@ -120,6 +132,7 @@ dev-amd64: _TARGET: dev IMAGE: ${_IMAGE_DEV_CI_AMD64} ENABLE_SINGLEARCH_PUSH: 'true' + ENABLE_SLIM: 'false' _IMAGE_POSTFIX: _${CI_COMMIT_REF_SLUG}_ci dev-arm64: @@ -133,6 +146,7 @@ dev-arm64: _TARGET: dev IMAGE: ${_IMAGE_DEV_CI_ARM64} ENABLE_SINGLEARCH_PUSH: 'true' + ENABLE_SLIM: 'false' _IMAGE_POSTFIX: _${CI_COMMIT_REF_SLUG}_ci run-amd64: @@ -148,6 +162,7 @@ run-amd64: _TARGET: run IMAGE: ${_IMAGE_RUN_CI_AMD64} ENABLE_SINGLEARCH_PUSH: 'true' + ENABLE_SLIM: 'false' _IMAGE_POSTFIX: _${CI_COMMIT_REF_SLUG}_ci run-arm64: @@ -164,10 +179,12 @@ run-arm64: _TARGET: run IMAGE: ${_IMAGE_RUN_CI_ARM64} ENABLE_SINGLEARCH_PUSH: 'true' + ENABLE_SLIM: 'false' _IMAGE_POSTFIX: _${CI_COMMIT_REF_SLUG}_ci .test: + stage: Test ROS Industrial CI variables: UPSTREAM_WORKSPACE: ${BUILD_CONTEXT}/.repos TARGET_WORKSPACE: ${BUILD_CONTEXT} @@ -186,7 +203,6 @@ run-arm64: script: .industrial_ci/gitlab.sh Test dev-amd64: - stage: Test ROS Industrial CI extends: .test needs: - job: dev-amd64 @@ -197,7 +213,6 @@ Test dev-amd64: _PLATFORM: amd64 Test dev-arm64: - stage: Test ROS Industrial CI extends: .test tags: [privileged, arm64] needs: @@ -209,7 +224,6 @@ Test dev-arm64: _PLATFORM: arm64 Test run-amd64: - stage: Test ROS Industrial CI extends: .test needs: - job: run-amd64 @@ -220,7 +234,6 @@ Test run-amd64: _PLATFORM: amd64 Test run-arm64: - stage: Test ROS Industrial CI extends: .test needs: - job: run-arm64 @@ -231,6 +244,51 @@ Test run-arm64: _PLATFORM: arm64 +.slim: + stage: Slim Images + before_script: + - apk add --update --upgrade curl tar + - curl -L -o ds.tar.gz ${SLIM_DOWNLOAD_URL} + - tar -xvf ds.tar.gz + - cd dist_linux* + - docker login -u ${REGISTRY_USER} -p ${REGISTRY_PASSWORD} ${REGISTRY} + - docker pull ${FAT_IMAGE} + script: + - ./slim build --target ${FAT_IMAGE} --tag ${SLIM_IMAGE} ${SLIM_BUILD_ARGS} + - docker push ${SLIM_IMAGE} + +Slim run-amd64: + stage: Slim Images + extends: .slim + needs: + - job: run-amd64 + optional: true + - job: Test run-amd64 + optional: true + rules: + - if: $ENABLE_SLIM == 'true' && $PLATFORM =~ /.*amd64.*/ && $TARGET =~ /.*run.*/ + variables: + FAT_IMAGE: ${_IMAGE_RUN_CI_AMD64} + SLIM_IMAGE: ${_IMAGE_SLIM_CI_AMD64} + SLIM_DOWNLOAD_URL: "https://github.com/slimtoolkit/slim/releases/download/1.40.11/dist_linux.tar.gz" + +Slim run-arm64: + stage: Slim Images + extends: .slim + tags: [privileged, arm64] + needs: + - job: run-arm64 + optional: true + - job: Test run-arm64 + optional: true + rules: + - if: $ENABLE_SLIM == 'true' && $PLATFORM =~ /.*arm64.*/ && $TARGET =~ /.*run.*/ + variables: + FAT_IMAGE: ${_IMAGE_RUN_CI_ARM64} + SLIM_IMAGE: ${_IMAGE_SLIM_CI_ARM64} + SLIM_DOWNLOAD_URL: "https://github.com/slimtoolkit/slim/releases/download/1.40.11/dist_linux_arm64.tar.gz" + + .push: needs: - job: dev-amd64 @@ -249,6 +307,10 @@ Test run-arm64: optional: true - job: Test run-arm64 optional: true + - job: Slim run-amd64 + optional: true + - job: Slim run-arm64 + optional: true rules: - if: $PLATFORM == '' || $TARGET == '' when: never @@ -263,6 +325,10 @@ Test run-arm64: docker manifest create ${IMG_RUN} --amend ${_IMAGE_RUN_CI_AMD64} --amend ${_IMAGE_RUN_CI_ARM64} docker manifest push ${IMG_RUN} fi + if [[ "${ENABLE_SLIM}" == 'true' && "${TARGET}" =~ run ]]; then + docker manifest create ${IMG_SLIM} --amend ${_IMAGE_SLIM_CI_AMD64} --amend ${_IMAGE_SLIM_CI_ARM64} + docker manifest push ${IMG_SLIM} + fi elif [[ "${PLATFORM}" =~ amd64 ]]; then if [[ "${TARGET}" =~ dev ]]; then docker pull ${_IMAGE_DEV_CI_AMD64} @@ -274,6 +340,11 @@ Test run-arm64: docker tag ${_IMAGE_RUN_CI_AMD64} ${IMG_RUN} docker push ${IMG_RUN} fi + if [[ "${ENABLE_SLIM}" == 'true' && "${TARGET}" =~ run ]]; then + docker pull ${_IMAGE_SLIM_CI_AMD64} + docker tag ${_IMAGE_SLIM_CI_AMD64} ${IMG_SLIM} + docker push ${IMG_SLIM} + fi elif [[ "${PLATFORM}" =~ arm64 ]]; then if [[ "${TARGET}" =~ dev ]]; then docker pull ${_IMAGE_DEV_CI_ARM64} @@ -285,6 +356,11 @@ Test run-arm64: docker tag ${_IMAGE_RUN_CI_ARM64} ${IMG_RUN} docker push ${IMG_RUN} fi + if [[ "${ENABLE_SLIM}" == 'true' && "${TARGET}" =~ run ]]; then + docker pull ${_IMAGE_SLIM_CI_ARM64} + docker tag ${_IMAGE_SLIM_CI_ARM64} ${IMG_SLIM} + docker push ${IMG_SLIM} + fi fi Push CI: @@ -298,6 +374,7 @@ Push CI: variables: IMG_DEV: ${_IMAGE_DEV_CI} IMG_RUN: ${_IMAGE_RUN_CI} + IMG_SLIM: ${_IMAGE_SLIM_CI} Push: stage: Push Multi-Arch Images @@ -308,6 +385,7 @@ Push: variables: IMG_DEV: ${_DEV_IMAGE} IMG_RUN: ${_RUN_IMAGE} + IMG_SLIM: ${_SLIM_IMAGE} Push latest: stage: Push Multi-Arch Images @@ -318,6 +396,7 @@ Push latest: variables: IMG_DEV: ${_IMAGE_DEV_LATEST} IMG_RUN: ${_IMAGE_RUN_LATEST} + IMG_SLIM: ${_IMAGE_SLIM_LATEST} Push target tag: stage: Push Multi-Arch Images @@ -328,6 +407,7 @@ Push target tag: variables: IMG_DEV: ${_IMAGE_DEV_TARGET_TAG} IMG_RUN: ${_IMAGE_RUN_TARGET_TAG} + IMG_SLIM: ${_IMAGE_SLIM_TARGET_TAG} Push tag: stage: Push Multi-Arch Images @@ -338,3 +418,4 @@ Push tag: variables: IMG_DEV: ${_IMAGE_DEV_TAG} IMG_RUN: ${_IMAGE_RUN_TAG} + IMG_SLIM: ${_IMAGE_SLIM_TAG} diff --git a/README.md b/README.md index 41dcfb1..98657b7 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ We recommend to use *docker-ros* in combination with our other tools for Docker ## About -*docker-ros* provides a generic [Dockerfile](docker/Dockerfile) that can be used to build development and deployment Docker images for arbitrary ROS packages or package stacks. Building such images can easily be automated by integrating *docker-ros* into CI through the provided [GitHub action](action.yml) or [GitLab CI template](.gitlab-ci/docker-ros.yml). The development image built by *docker-ros* contains all required dependencies and the source code of your ROS-based repository. The deployment image only contains dependencies and the compiled binaries created by building the ROS packages in the repository. *docker-ros* is also able to build multi-arch Docker images for *amd64* and *arm64* architectures. +*docker-ros* provides a generic [Dockerfile](docker/Dockerfile) that can be used to build development and deployment Docker images for arbitrary ROS packages or package stacks. Building such images can easily be automated by integrating *docker-ros* into CI through the provided [GitHub action](action.yml) or [GitLab CI template](.gitlab-ci/docker-ros.yml). The development image built by *docker-ros* contains all required dependencies and the source code of your ROS-based repository. The deployment image only contains dependencies and the compiled binaries created by building the ROS packages in the repository. *docker-ros* is also able to build multi-arch Docker images for *amd64* and *arm64* architectures. In addition, [*slim*](https://github.com/slimtoolkit/slim) is integrated for slimming Docker image size of the deployment image by up to 30x (see [*Slim Deployment Image*](#slim-deployment-image)). 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). @@ -73,7 +73,7 @@ Note that GitHub is currently only offering Linux runners based on the *amd64* a
GitLab -> **Note** +> [!NOTE] > - GitLab runners must be based on the Docker executor, [see here](https://docs.gitlab.com/runner/executors/docker.html) > - GitLab runners must run in privileged mode for Docker-in-Docker, [see here](https://docs.gitlab.com/runner/executors/docker.html#use-docker-in-docker-with-privileged-mode) > - GitLab runners must be tagged with tags `privileged` and either `amd64` or `arm64` depending on their architecture @@ -111,7 +111,7 @@ jobs: docker-ros: runs-on: ubuntu-latest steps: - - uses: ika-rwth-aachen/docker-ros@v1.3.1 + - uses: ika-rwth-aachen/docker-ros@v1.6.0 with: base-image: rwthika/ros2:humble command: ros2 run my_pkg my_node @@ -123,7 +123,7 @@ jobs: ```yml include: - - remote: https://raw.githubusercontent.com/ika-rwth-aachen/docker-ros/v1.3.1/.gitlab-ci/docker-ros.yml + - remote: https://raw.githubusercontent.com/ika-rwth-aachen/docker-ros/v1.6.0/.gitlab-ci/docker-ros.yml variables: BASE_IMAGE: rwthika/ros2:humble @@ -142,7 +142,7 @@ jobs: docker-ros: runs-on: ubuntu-latest steps: - - uses: ika-rwth-aachen/docker-ros@v1.3.1 + - uses: ika-rwth-aachen/docker-ros@v1.6.0 with: base-image: rwthika/ros2:humble command: ros2 run my_pkg my_node @@ -155,7 +155,7 @@ jobs: ```yml include: - - remote: https://raw.githubusercontent.com/ika-rwth-aachen/docker-ros/v1.3.1/.gitlab-ci/docker-ros.yml + - remote: https://raw.githubusercontent.com/ika-rwth-aachen/docker-ros/v1.6.0/.gitlab-ci/docker-ros.yml variables: BASE_IMAGE: rwthika/ros2:humble @@ -175,7 +175,7 @@ jobs: docker-ros: runs-on: ubuntu-latest steps: - - uses: ika-rwth-aachen/docker-ros@v1.3.1 + - uses: ika-rwth-aachen/docker-ros@v1.6.0 with: base-image: rwthika/ros2:humble command: ros2 run my_pkg my_node @@ -189,7 +189,7 @@ jobs: ```yml include: - - remote: https://raw.githubusercontent.com/ika-rwth-aachen/docker-ros/v1.3.1/.gitlab-ci/docker-ros.yml + - remote: https://raw.githubusercontent.com/ika-rwth-aachen/docker-ros/v1.6.0/.gitlab-ci/docker-ros.yml variables: BASE_IMAGE: rwthika/ros2:humble @@ -210,7 +210,7 @@ jobs: docker-ros: runs-on: ubuntu-latest steps: - - uses: ika-rwth-aachen/docker-ros@v1.3.1 + - uses: ika-rwth-aachen/docker-ros@v1.6.0 with: base-image: rwthika/ros2:humble command: ros2 run my_pkg my_node @@ -223,7 +223,7 @@ jobs: ```yml include: - - remote: https://raw.githubusercontent.com/ika-rwth-aachen/docker-ros/v1.3.1/.gitlab-ci/docker-ros.yml + - remote: https://raw.githubusercontent.com/ika-rwth-aachen/docker-ros/v1.6.0/.gitlab-ci/docker-ros.yml variables: BASE_IMAGE: rwthika/ros2:humble @@ -247,7 +247,7 @@ jobs: platform: [amd64, arm64] runs-on: [self-hosted, "${{ matrix.platform }}"] steps: - - uses: ika-rwth-aachen/docker-ros@v1.3.1 + - uses: ika-rwth-aachen/docker-ros@v1.6.0 with: base-image: rwthika/ros2:humble command: ros2 run my_pkg my_node @@ -285,7 +285,7 @@ jobs: IMAGE="my-image:latest" \ ./docker/docker-ros/scripts/build.sh ``` - > **Note** + > [!NOTE] > You can alternatively store your environment variable configuration in a `.env` file: > ```bash > # .env @@ -346,10 +346,14 @@ docker run --rm -it -e DOCKER_UID=$(id -u) -e DOCKER_GID=$(id -g) -e DOCKER_USER The password of the custom user is set to its username (`dockeruser:dockeruser` by default). +### Slim Deployment Image + +*docker-ros* integrates the [*slim*](https://github.com/slimtoolkit/slim) toolkit for minifying container images. *slim* is enabled by default and will, in addition to the `run` deployment image, produce an additional `:latest-slim`-tagged minified image. Note that the slimmed deployment image is stripped of every single thing not needed for executing the default launch command. The slimming process can be controlled via the `SLIM_BUILD_ARGS` configuration variable. + ## Configuration Variables -> **Note** +> [!NOTE] > *GitHub Action input* | *GitLab CI environment variable* - **`additional-debs-file` | `ADDITIONAL_DEBS_FILE`** @@ -403,15 +407,6 @@ The password of the custom user is set to its username (`dockeruser:dockeruser` - **`enable-singlearch-push` | `ENABLE_SINGLEARCH_PUSH`** Enable push of single arch images with `-amd64`/`-arm64` postfix *default:* `false` -- **`git-https-password` | `GIT_HTTPS_PASSWORD`** - Password for cloning private Git repositories via HTTPS - *default:* `${{ github.token }}` | `$CI_JOB_TOKEN` -- **`git-https-server` | `GIT_HTTPS_SERVER`** - Server URL (without protocol) for cloning private Git repositories via HTTPS - *default:* `github.com` | `$CI_SERVER_HOST:$CI_SERVER_PORT` -- **`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` @@ -427,6 +422,18 @@ The password of the custom user is set to its username (`dockeruser:dockeruser` - **`enable-recursive-vcs-import` | `ENABLE_RECURSIVE_VCS_IMPORT`** Enable recursive discovery of files named `*.repos` *default:* `true` +- **`enable-slim` | `ENABLE_SLIM`** + Enable an extra slimmed run image via [slim](https://github.com/slimtoolkit/slim) (only if `run` stage is targeted) + *default:* `true` +- **`git-https-password` | `GIT_HTTPS_PASSWORD`** + Password for cloning private Git repositories via HTTPS + *default:* `${{ github.token }}` | `$CI_JOB_TOKEN` +- **`git-https-server` | `GIT_HTTPS_SERVER`** + Server URL (without protocol) for cloning private Git repositories via HTTPS + *default:* `github.com` | `$CI_SERVER_HOST:$CI_SERVER_PORT` +- **`git-https-user` | `GIT_HTTPS_USER`** + Username for cloning private Git repositories via HTTPS + *default:* `${{ github.actor }}` | `gitlab-ci-token` - **`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`** @@ -458,6 +465,15 @@ The password of the custom user is set to its username (`dockeruser:dockeruser` ROS Distro *required if ROS is not installed in `base-image`* *supported values:* `rolling`, ..., `noetic`, ... +- **`slim-build-args` | `SLIM_BUILD_ARGS`** + [Arguments to `slim build`](https://github.com/slimtoolkit/slim?tab=readme-ov-file#build-command-options) (except for `--target` and `--tag`) + *default:* `--sensor-ipc-mode proxy --continue-after=10 --show-clogs --http-probe=false` +- **`slim-image-name` | `SLIM_IMAGE_NAME`** + Image name of slim run image + *default:* `` +- **`slim-image-tag` | `SLIM_IMAGE_TAG`** + Image tag of slim run image + *default:* `-slim` - **`target` | `TARGET`** Target stage of Dockerfile (comma-separated list) *default:* `run` diff --git a/action.yml b/action.yml index 6dbbd89..4421e54 100644 --- a/action.yml +++ b/action.yml @@ -27,10 +27,18 @@ inputs: dev-image-name: description: "Image name of dev image" + default: ghcr.io/${{ github.repository }} dev-image-tag: description: "Image tag of dev image" + slim-image-name: + description: "Image name of slim run image" + default: ghcr.io/${{ github.repository }} + + slim-image-tag: + description: "Image tag of slim run image" + build-context: description: "Build context of Docker build process" default: ${{ github.workspace }} @@ -112,6 +120,14 @@ inputs: description: "Enable industrial_ci" default: false + enable-slim: + description: "Enable an extra slimmed run image via slim (only if run stage is targeted)" + default: true + + slim-build-args: + description: "Arguments to `slim build` (except for `--target` and `--tag`)" + default: '--sensor-ipc-mode proxy --continue-after=10 --show-clogs --http-probe=false' + enable-singlearch-push: description: "Enable push of single arch images with [-amd64|-arm64] postfix" default: false @@ -184,6 +200,12 @@ runs: with: string: ${{ inputs.dev-image-name }} + - name: Enforce lower-case slim image name + id: slim-image-name + uses: ASzc/change-string-case-action@v6 + with: + string: ${{ inputs.slim-image-name }} + - name: Build images id: build-images shell: bash @@ -198,6 +220,10 @@ runs: IMAGE_TAG: ${{ inputs.image-tag }} DEV_IMAGE_NAME: ${{ steps.dev-image-name.outputs.lowercase }} DEV_IMAGE_TAG: ${{ inputs.dev-image-tag }} + SLIM_IMAGE_NAME: ${{ steps.slim-image-name.outputs.lowercase }} + SLIM_IMAGE_TAG: ${{ inputs.slim-image-tag }} + ENABLE_SLIM: ${{ inputs.enable-slim }} + SLIM_BUILD_ARGS: ${{ inputs.slim-build-args }} RMW_IMPLEMENTATION: ${{ inputs.rmw-implementation }} ROS_DISTRO: ${{ inputs.ros-distro }} GIT_HTTPS_SERVER: ${{ inputs.git-https-server }} @@ -253,8 +279,12 @@ runs: COMMAND: ${{ inputs.command }} IMAGE_NAME: ${{ steps.image-name.outputs.lowercase }} IMAGE_TAG: ${{ inputs.image-tag }} - DEV_IMAGE_NAME: ${{ inputs.dev-image-name }} + DEV_IMAGE_NAME: ${{ steps.dev-image-name.outputs.lowercase }} DEV_IMAGE_TAG: ${{ inputs.dev-image-tag }} + SLIM_IMAGE_NAME: ${{ steps.slim-image-name.outputs.lowercase }} + SLIM_IMAGE_TAG: ${{ inputs.slim-image-tag }} + ENABLE_SLIM: ${{ inputs.enable-slim }} + SLIM_BUILD_ARGS: ${{ inputs.slim-build-args }} ENABLE_SINGLEARCH_PUSH: ${{ inputs.enable-singlearch-push }} RMW_IMPLEMENTATION: ${{ inputs.rmw-implementation }} ROS_DISTRO: ${{ inputs.ros-distro }} @@ -289,8 +319,12 @@ runs: COMMAND: ${{ inputs.command }} IMAGE_NAME: ${{ steps.image-name.outputs.lowercase }} IMAGE_TAG: latest - DEV_IMAGE_NAME: ${{ inputs.dev-image-name }} + DEV_IMAGE_NAME: ${{ steps.dev-image-name.outputs.lowercase }} DEV_IMAGE_TAG: latest-dev + SLIM_IMAGE_NAME: ${{ steps.slim-image-name.outputs.lowercase }} + SLIM_IMAGE_TAG: latest-slim + ENABLE_SLIM: ${{ inputs.enable-slim }} + SLIM_BUILD_ARGS: ${{ inputs.slim-build-args }} ENABLE_SINGLEARCH_PUSH: ${{ inputs.enable-singlearch-push }} RMW_IMPLEMENTATION: ${{ inputs.rmw-implementation }} ROS_DISTRO: ${{ inputs.ros-distro }} diff --git a/scripts/ci.sh b/scripts/ci.sh index 8f76fd4..82d4ff8 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -16,9 +16,14 @@ IMAGE_TAG="${IMAGE_TAG:-latest}" [[ "${TARGET}" == *"run"* ]] && require_var "COMMAND" DEV_IMAGE_NAME="${DEV_IMAGE_NAME:-${IMAGE_NAME}}" DEV_IMAGE_TAG="${DEV_IMAGE_TAG:-${IMAGE_TAG}-dev}" +SLIM_IMAGE_NAME="${SLIM_IMAGE_NAME:-${IMAGE_NAME}}" +SLIM_IMAGE_TAG="${SLIM_IMAGE_TAG:-${IMAGE_TAG}-slim}" IMAGE="${IMAGE_NAME}:${IMAGE_TAG}" DEV_IMAGE="${DEV_IMAGE_NAME}:${DEV_IMAGE_TAG}" +SLIM_IMAGE="${SLIM_IMAGE_NAME}:${SLIM_IMAGE_TAG}" +ENABLE_SLIM="${ENABLE_SLIM:-true}" +SLIM_BUILD_ARGS="${SLIM_BUILD_ARGS:-'--sensor-ipc-mode proxy --continue-after=10 --show-clogs --http-probe=false'}" ENABLE_SINGLEARCH_PUSH="${ENABLE_SINGLEARCH_PUSH:-false}" RMW_IMPLEMENTATION="${RMW_IMPLEMENTATION:-}" ROS_DISTRO="${ROS_DISTRO:-}" @@ -64,6 +69,12 @@ fi unset TARGET unset PLATFORM +# prepare slim +if [[ "${ENABLE_SLIM}" == "true" ]]; then + curl -L -o ds.tar.gz https://github.com/slimtoolkit/slim/releases/download/1.40.11/dist_linux.tar.gz + tar -xvf ds.tar.gz +fi + # loop over targets and platforms to build images for PLATFORM in "${PLATFORMS[@]}"; do for TARGET in "${TARGETS[@]}"; do @@ -75,4 +86,24 @@ for PLATFORM in "${PLATFORMS[@]}"; do IMAGE="${image}" build_image close_log_group done + + # slim image + if [[ "${ENABLE_SLIM}" == "true" && "${TARGET}" == "run" ]]; then + open_log_group "Slim image (${PLATFORM})" + image="${IMAGE}" + slim_image="${SLIM_IMAGE}" + [[ -n "${_IMAGE_POSTFIX}" ]] && image="${image}${_IMAGE_POSTFIX}" + [[ -n "${_IMAGE_POSTFIX}" ]] && slim_image="${slim_image}${_IMAGE_POSTFIX}" + [[ "${_ENABLE_IMAGE_PUSH}" != "true" || "${ENABLE_SINGLEARCH_PUSH}" == "true" ]] && image="${image}-${PLATFORM}" + [[ "${_ENABLE_IMAGE_PUSH}" != "true" || "${ENABLE_SINGLEARCH_PUSH}" == "true" ]] && slim_image="${slim_image}-${PLATFORM}" + if [[ "${_ENABLE_IMAGE_PUSH}" == "true" || "${ENABLE_SINGLEARCH_PUSH}" == "true" ]]; then + [[ "${ENABLE_SINGLEARCH_PUSH}" != "true" ]] && docker tag "${slim_image}-${PLATFORM}" "${slim_image}" + docker push "${slim_image}" + else + cd dist_linux* + ./slim build --target "${image}" --tag "${slim_image}" ${SLIM_BUILD_ARGS} + cd - + fi + close_log_group + fi done diff --git a/templates/README.template.md b/templates/README.template.md deleted file mode 100644 index 3b364b3..0000000 --- a/templates/README.template.md +++ /dev/null @@ -1,105 +0,0 @@ -# \ - -\ - -- [Nodes](#nodes) - - [\/\](#packagenode) -- [Usage of docker-ros Images](#usage-of-docker-ros-images) - - [Available Images](#available-images) - - [Default Command](#default-command) - - [Environment Variables](#environment-variables) - - [Launch Files](#launch-files) - - [Configuration Files](#configuration-files) - - [Additional Remarks](#additional-remarks) -- [Official Documentation](#official-documentation) - - -## Nodes - -| Package | Node | Description | -| --- | --- | --- | -| `` | `` | \ | - -### \/\ - -#### Subscribed Topics - - - -| Topic | Type | Description | -| --- | --- | --- | -| `` | `/msg/` | \ | - -#### Published Topics - - - -| Topic | Type | Description | -| --- | --- | --- | -| `` | `/msg/` | \ | - -#### Services - - - -| Service | Type | Description | -| --- | --- | --- | -| `` | `/srv/` | \ | - -#### Actions - - - -| Action | Type | Description | -| --- | --- | --- | -| `` | `/action/` | \ | - -#### Parameters - - - -| Parameter | Type | Description | -| --- | --- | --- | -| `` | `` | \ | - - -## Usage of docker-ros Images - -### Available Images - -| Tag | Description | -| --- | --- | -| `latest` | latest version | - -### Default Command - -```bash - -``` - -### Environment Variables - -| Variable | Description | -| --- | --- | -| `` | \ | - -### Launch Files - -| Package | File | Path | Description | -| --- | --- | --- | --- | -| `` | `.` | `` | \ | - -### Configuration Files - -| Package | File | Path | Description | -| --- | --- | --- | --- | -| `` | `.` | `` | \ | - -### Additional Remarks - -\- - - -## Official Documentation - -- \ diff --git a/templates/docker-compose.template.yml b/templates/docker-compose.template.yml deleted file mode 100644 index 54280bf..0000000 --- a/templates/docker-compose.template.yml +++ /dev/null @@ -1,43 +0,0 @@ -x-base-image: &base-image BASE_IMAGE # e.g. rwthika/ros2:humble -x-dev-image: &dev-image DEV_IMAGE # e.g. my-image:latest-dev -x-run-image: &run-image RUN_IMAGE # e.g. my-image:latest -x-command: &command COMMAND # e.g. ros2 run my_pkg my_node - -# ============================================================================== - -x-build: &build - dockerfile: ./docker/docker-ros/docker/Dockerfile - context: ../ - args: - BASE_IMAGE: *base-image - COMMAND: *command - ADDITIONAL_DEBS_FILE: $ADDITIONAL_DEBS_FILE - ADDITIONAL_FILES_DIR: $ADDITIONAL_FILES_DIR - ADDITIONAL_PIP_FILE: $ADDITIONAL_PIP_FILE - BLACKLISTED_PACKAGES_FILE: $BLACKLISTED_PACKAGES_FILE - VCS_IMPORT_FILE: $VCS_IMPORT_FILE - CUSTOM_SCRIPT_FILE: $CUSTOM_SCRIPT_FILE - ENABLE_RECURSIVE_ADDITIONAL_DEBS: $ENABLE_RECURSIVE_ADDITIONAL_DEBS - ENABLE_RECURSIVE_ADDITIONAL_PIP: $ENABLE_RECURSIVE_ADDITIONAL_PIP - ENABLE_RECURSIVE_BLACKLISTED_PACKAGES: $ENABLE_RECURSIVE_BLACKLISTED_PACKAGES - ENABLE_RECURSIVE_CUSTOM_SCRIPT: $ENABLE_RECURSIVE_CUSTOM_SCRIPT - ENABLE_RECURSIVE_VCS_IMPORT: $ENABLE_RECURSIVE_VCS_IMPORT - GIT_HTTPS_PASSWORD: $GIT_HTTPS_PASSWORD - GIT_HTTPS_SERVER: $GIT_HTTPS_SERVER - GIT_HTTPS_USER: $GIT_HTTPS_USER - GIT_SSH_KNOWN_HOST_KEYS: $GIT_SSH_KNOWN_HOST_KEYS - GIT_SSH_PRIVATE_KEY: $GIT_SSH_PRIVATE_KEY - RMW_IMPLEMENTATION: $RMW_IMPLEMENTATION - ROS_DISTRO: $ROS_DISTRO - -services: - dev: - image: *dev-image - build: - target: dev - <<: *build - run: - image: *run-image - build: - target: run - <<: *build \ No newline at end of file