diff --git a/.gitlab-ci/docker-ros.yml b/.gitlab-ci/docker-ros.yml index cc55018..4f71a3e 100644 --- a/.gitlab-ci/docker-ros.yml +++ b/.gitlab-ci/docker-ros.yml @@ -25,7 +25,7 @@ variables: 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_ARGUMENTS: '--sensor-ipc-mode proxy --continue-after=10 --show-clogs --http-probe=false' # Arguments to `slim build` (except for `--target` and `--tag`) + 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) @@ -250,7 +250,7 @@ Test run-arm64: - docker login -u ${REGISTRY_USER} -p ${REGISTRY_PASSWORD} ${REGISTRY} - docker pull ${FAT_IMAGE} script: - - ./slim build --target ${FAT_IMAGE} --tag ${SLIM_IMAGE} ${SLIM_BUILD_ARGUMENTS} + - ./slim build --target ${FAT_IMAGE} --tag ${SLIM_IMAGE} ${SLIM_BUILD_ARGS} - docker push ${SLIM_IMAGE} Slim run-amd64: diff --git a/action.yml b/action.yml index 0f1cd58..882c82c 100644 --- a/action.yml +++ b/action.yml @@ -126,7 +126,7 @@ inputs: description: "Enable an extra slimmed run image via slim (only if run stage is targeted)" default: true - slim-build-arguments: + 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' @@ -222,6 +222,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 }} @@ -260,16 +264,6 @@ runs: DOCKER_IMAGE: ${{ steps.build-images.outputs.INDUSTRIAL_CI_IMAGE }} DOCKER_PULL: false - - name: Slim images - if: ${{ inputs.enable-slim == 'true' && contains(inputs.target, 'run') }} - shell: bash - working-directory: ${{ inputs.build-context }} - run: | - 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 - cd dist_linux* - ./slim build --target ${{ steps.image-name.outputs.lowercase }}:${{ inputs.image-tag }} --tag ${{ steps.slim-image-name.outputs.lowercase }}:${{ inputs.slim-image-tag }} ${{ inputs.slim-build-arguments }} - - name: Slugify ref name id: slugify-ref-name uses: gacts/github-slug@v1 @@ -292,6 +286,7 @@ runs: 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 }} @@ -331,6 +326,7 @@ runs: 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 52b869f..0a0209f 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -23,6 +23,7 @@ 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:-}" @@ -68,6 +69,10 @@ fi unset TARGET unset PLATFORM +# prepare slim +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 + # loop over targets and platforms to build images for PLATFORM in "${PLATFORMS[@]}"; do for TARGET in "${TARGETS[@]}"; do @@ -79,11 +84,23 @@ for PLATFORM in "${PLATFORMS[@]}"; do IMAGE="${image}" build_image close_log_group done -done -# push slim images -if [[ "${ENABLE_SLIM}" == "true" && "${_ENABLE_IMAGE_PUSH}" == "true" && "${TARGET}" == *"run"* ]]; then - open_log_group "Push slim image" - docker push "${SLIM_IMAGE}" - close_log_group -fi + # 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 + 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