diff --git a/.github/workflows/reusable-build-push.yml b/.github/workflows/reusable-build-push.yml index 62a8463..184fa79 100644 --- a/.github/workflows/reusable-build-push.yml +++ b/.github/workflows/reusable-build-push.yml @@ -67,17 +67,21 @@ jobs: - id: tags run: | - BUILD_FLAGS=() + BUILD_FLAGS=() + BASE_TAG=${{ inputs.ros_distro }} BUILD_FLAGS+=(--build-arg BASE_TAG=${BASE_TAG}) - echo "::debug::Using base image tag ${BASE_TAG}" - echo "build_flags=${BUILD_FLAGS[@]}" >> $GITHUB_OUTPUT VERSION_TAG="v${{ needs.check-version.outputs.version }}" IMAGE_TAGS="${VERSION_TAG},${VERSION_TAG}-${{ inputs.ros_distro}}","${{ inputs.ros_distro}}" GIT_TAG="${VERSION_TAG}-${{ inputs.ros_distro}}" + BUILD_FLAGS+=(--build-arg VERSION=${GIT_TAG}) + + echo "::debug::Using base image tag ${BASE_TAG}" + echo "Build flags: ${BUILD_FLAGS[@]}" echo "Image tags: ${IMAGE_TAGS}" echo "Git tag: ${GIT_TAG}" + echo "build_flags=${BUILD_FLAGS[@]}" >> $GITHUB_OUTPUT echo "image_tags=${IMAGE_TAGS}" >> $GITHUB_OUTPUT echo "git_tag=${GIT_TAG}" >> $GITHUB_OUTPUT diff --git a/ros2_control/Dockerfile.galactic b/ros2_control/Dockerfile.galactic deleted file mode 100644 index fdfc26b..0000000 --- a/ros2_control/Dockerfile.galactic +++ /dev/null @@ -1,25 +0,0 @@ -ARG BASE_IMAGE=ghcr.io/aica-technology/ros2-ws -ARG BASE_TAG=humble -FROM ${BASE_IMAGE}:${BASE_TAG} as ros2-control-build - -RUN mkdir -p ${ROS2_WORKSPACE}/src/ros2_control -WORKDIR ${ROS2_WORKSPACE}/src/ros2_control - -RUN git clone -b 1.0.0 --depth 1 https://github.com/ros-controls/ros2_control.git -RUN git clone -b 1.0.0 --depth 1 https://github.com/ros-controls/ros2_controllers.git - -# get additional interface dependencies manually -RUN git clone -b galactic-devel --depth 1 https://github.com/ros-controls/control_msgs.git -RUN git clone -b ros2-master --depth 1 https://github.com/ros-controls/control_toolbox.git -RUN git clone -b 2.1.1 --depth 1 https://github.com/ros-controls/realtime_tools.git -RUN git clone -b galactic --depth 1 https://github.com/ros2/rcl_interfaces.git -RUN git clone -b galactic --depth 1 https://github.com/ros2/test_interface_files.git -RUN git clone -b ros2 --depth 1 https://github.com/ros/angles.git - -WORKDIR ${ROS2_WORKSPACE} -RUN /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; colcon build" -RUN rm -rf ./src - - -FROM ${BASE_IMAGE}:${BASE_TAG} as final -COPY --from=ros2-control-build ${ROS2_WORKSPACE} ${ROS2_WORKSPACE} diff --git a/ros2_control/Dockerfile.humble b/ros2_control/Dockerfile.humble deleted file mode 100644 index c7ffc14..0000000 --- a/ros2_control/Dockerfile.humble +++ /dev/null @@ -1,26 +0,0 @@ -ARG BASE_IMAGE=ghcr.io/aica-technology/ros2-ws -ARG BASE_TAG=humble -FROM ${BASE_IMAGE}:${BASE_TAG} as ros2-control-build - -RUN mkdir -p ${ROS2_WORKSPACE}/src/ros2_control -WORKDIR ${ROS2_WORKSPACE}/src/ros2_control - -RUN git clone -b 2.11.0 --depth 1 https://github.com/ros-controls/ros2_control.git -RUN git clone -b 2.11.0 --depth 1 https://github.com/ros-controls/ros2_controllers.git - -# get additional interface dependencies manually -RUN git clone -b humble --depth 1 https://github.com/ros-controls/control_msgs.git -RUN git clone -b 3.1.0 --depth 1 https://github.com/ros-controls/control_toolbox.git -RUN git clone -b 2.2.0 --depth 1 https://github.com/ros-controls/realtime_tools.git -RUN git clone -b humble --depth 1 https://github.com/ros2/rcl_interfaces.git -RUN git clone -b humble --depth 1 https://github.com/ros2/test_interface_files.git -RUN git clone -b ros2 --depth 1 https://github.com/ros/angles.git -RUN git clone -b ros2 --depth 1 https://github.com/ros-drivers/ackermann_msgs.git - -WORKDIR ${ROS2_WORKSPACE} -RUN /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; colcon build" -RUN rm -rf ./src - - -FROM ${BASE_IMAGE}:${BASE_TAG} as final -COPY --from=ros2-control-build ${ROS2_WORKSPACE} ${ROS2_WORKSPACE} diff --git a/ros2_control/Dockerfile.iron b/ros2_control/Dockerfile.iron deleted file mode 100644 index 329e68b..0000000 --- a/ros2_control/Dockerfile.iron +++ /dev/null @@ -1,38 +0,0 @@ -ARG BASE_IMAGE=ghcr.io/aica-technology/ros2-ws -ARG BASE_TAG=iron -FROM ${BASE_IMAGE}:${BASE_TAG} as ros2-control-build - -RUN sudo apt-get update && sudo apt-get install --no-install-recommends -y \ - doxygen \ - librange-v3-dev \ - python3-jinja2 \ - python3-typeguard \ - && sudo rm -rf /var/lib/apt/lists/* - -RUN mkdir -p ${ROS2_WORKSPACE}/src/ros2_control -WORKDIR ${ROS2_WORKSPACE}/src/ros2_control - -RUN git clone -b 3.18.0 --depth 1 https://github.com/ros-controls/ros2_control.git -RUN git clone -b 3.14.0 --depth 1 https://github.com/ros-controls/ros2_controllers.git -# get additional interface dependencies manually -RUN git clone -b 5.0.0 --depth 1 https://github.com/ros-controls/control_msgs.git -RUN git clone -b 1.0.2 --depth 1 https://github.com/pal-robotics/backward_ros.git -RUN git clone -b 3.1.2 --depth 1 https://github.com/ros/diagnostics.git -RUN git clone -b 2.5.0 --depth 1 https://github.com/ros-controls/realtime_tools.git -RUN git clone -b 1.7.0 --depth 1 https://github.com/ros2/rcl_interfaces.git -RUN git clone -b 0.11.0 --depth 1 https://github.com/ros2/test_interface_files.git -RUN git clone -b 1.16.0 --depth 1 https://github.com/ros/angles.git -RUN git clone -b ros2 --depth 1 https://github.com/ros-drivers/ackermann_msgs.git -RUN git clone -b 0.3.3 --depth 1 https://github.com/PickNikRobotics/generate_parameter_library.git -RUN git clone -b 0.2.2 --depth 1 https://github.com/PickNikRobotics/RSL.git -RUN git clone -b 1.0.2 --depth 1 https://github.com/PickNikRobotics/cpp_polyfills.git -RUN git clone -b 3.1.0 --depth 1 https://github.com/ros-controls/control_toolbox.git -RUN git clone -b 0.1.0 --depth 1 https://github.com/ros-controls/kinematics_interface.git - -WORKDIR ${ROS2_WORKSPACE} -RUN /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; colcon build" -RUN rm -rf ./src - - -FROM ${BASE_IMAGE}:${BASE_TAG} as final -COPY --from=ros2-control-build / / diff --git a/ros2_control/build.sh b/ros2_control/build.sh deleted file mode 100755 index 8c80bac..0000000 --- a/ros2_control/build.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash - -IMAGE_NAME=aica-technology/ros2-control - -LOCAL_BASE_IMAGE=false -BASE_IMAGE=ghcr.io/aica-technology/ros2-ws -BASE_TAG=humble -OUTPUT_TAG="" - -BUILD_FLAGS=() -while [ "$#" -gt 0 ]; do - case "$1" in - --local-base) - LOCAL_BASE_IMAGE=true - shift 1 - ;; - --base-tag) - BASE_TAG=$2 - shift 2 - ;; - --output-tag) - OUTPUT_TAG=$2 - shift 2 - ;; - -r | --rebuild) - BUILD_FLAGS+=(--no-cache) - shift 1 - ;; - -v | --verbose) - BUILD_FLAGS+=(--progress=plain) - shift 1 - ;; - *) - echo "Unknown option: $1" >&2 - exit 1 - ;; - esac -done - -if [ -z "${OUTPUT_TAG}" ]; then - echo "Output tag is empty, using the base tag as output tag." - OUTPUT_TAG="${BASE_TAG}" -fi - -if [ "${LOCAL_BASE_IMAGE}" = true ]; then - BUILD_FLAGS+=(--build-arg BASE_IMAGE=aica-technology/ros2-ws) -else - docker pull "${BASE_IMAGE}:${BASE_TAG}" -fi - -BUILD_FLAGS+=(--build-arg BASE_TAG="${BASE_TAG}") -BUILD_FLAGS+=(-t "${IMAGE_NAME}:${OUTPUT_TAG}") - -if [[ "${BASE_TAG}" == *"galactic"* ]]; then - DOCKERFILE=Dockerfile.galactic -elif [[ "${BASE_TAG}" == *"humble"* ]]; then - DOCKERFILE=Dockerfile.humble -elif [[ "${BASE_TAG}" == *"iron"* ]]; then - DOCKERFILE=Dockerfile.iron -else - echo "Invalid base tag. Base tag needs to contain either 'galactic', 'humble' or 'iron'." - exit 1 -fi - -DOCKER_BUILDKIT=1 docker build -f "${DOCKERFILE}" "${BUILD_FLAGS[@]}" . diff --git a/ros2_ws/Dockerfile b/ros2_ws/Dockerfile index a1bd983..604211b 100644 --- a/ros2_ws/Dockerfile +++ b/ros2_ws/Dockerfile @@ -1,108 +1,10 @@ -ARG BASE_TAG=humble -FROM ros:${BASE_TAG} as environment-variables -ENV DEBIAN_FRONTEND=noninteractive -ENV PYTHONWARNINGS=ignore:::setuptools.command.install,ignore:::setuptools.command.easy_install,ignore:::pkg_resources -ENV PIP_NO_CACHE_DIR 1 -ENV USER ros2 -ENV HOME /home/${USER} -ENV ROS2_WORKSPACE /home/${USER}/ros2_ws -ENV COLCON_HOME ${HOME}/.colcon -ENV COLCON_DEFAULTS_FILE ${COLCON_HOME}/defaults.yaml -ENV COLCON_WORKSPACE=${ROS2_WORKSPACE} -ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib - - -FROM environment-variables as base-dependencies - -# disable suggested and recommended install -RUN apt-config dump | grep -we Recommends -e Suggests | sed s/1/0/ \ - | sudo tee /etc/apt/apt.conf.d/999norecommend - -# install base dependencies -RUN apt-get update && apt-get install --no-install-recommends -y \ - autoconf \ - automake \ - curl \ - featherpad \ - gdb \ - git \ - iputils-ping \ - libboost-all-dev \ - libtool \ - mesa-utils \ - nano \ - python3-pip \ - ros-${ROS_DISTRO}-xacro \ - ros-${ROS_DISTRO}-robot-state-publisher \ - ros-${ROS_DISTRO}-rviz2 \ - rsync \ - software-properties-common \ - ssh \ - unzip \ - wget \ - && rm -rf /var/lib/apt/lists/* - -RUN echo "Set disable_coredump false" >> /etc/sudo.conf - -# configure sshd server settings -RUN ( \ - echo 'LogLevel DEBUG2'; \ - echo 'PubkeyAuthentication yes'; \ - echo 'Subsystem sftp /usr/lib/openssh/sftp-server'; \ - ) > /etc/ssh/sshd_config_development \ - && mkdir /run/sshd - - -FROM base-dependencies as base-workspace - -# create and configure a new user -ARG UID=1000 -ARG GID=1000 -RUN addgroup --gid ${GID} ${USER} -RUN adduser --gecos "ROS2 User" --uid ${UID} --gid ${GID} ${USER} && yes | passwd ${USER} -RUN usermod -a -G dialout ${USER} -RUN echo "${USER} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/99_aptget -RUN chmod 0440 /etc/sudoers.d/99_aptget && chown root:root /etc/sudoers.d/99_aptget - -# configure sshd entrypoint to authorise the new user for ssh access and -# optionally update UID and GID when invoking the container with the entrypoint script -COPY ./config/sshd_entrypoint.sh /sshd_entrypoint.sh -RUN chmod 744 /sshd_entrypoint.sh - -# crete user group with realtime permissions and add user to it -RUN groupadd -g 3719 realtime && usermod -aG realtime ${USER} -RUN echo "@realtime soft rtprio 99\n@realtime hard rtprio 99\n" > \ - /etc/security/limits.d/realtime.conf - -# configure colcon defaults and utilities -USER ${USER} -WORKDIR ${HOME} -RUN wget https://raw.githubusercontent.com/aica-technology/.github/v0.9.0/guidelines/.clang-format -RUN mkdir -p ${COLCON_HOME} -COPY --chown=${USER}:${USER} ./config/colcon ${COLCON_HOME} -RUN /bin/bash ${COLCON_HOME}/setup.sh - -# build ROS workspace -RUN mkdir -p ${ROS2_WORKSPACE}/src -WORKDIR ${ROS2_WORKSPACE} -RUN rosdep update -RUN /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; colcon build --symlink-install" - -# prepend the environment sourcing to bashrc (appending will fail for non-interactive sessions) -RUN echo "source /opt/ros/${ROS_DISTRO}/setup.bash; \ -source ${ROS2_WORKSPACE}/install/setup.bash" | cat - ${HOME}/.bashrc > tmp && mv tmp ${HOME}/.bashrc -# enable colorized output from ros logging -RUN echo "export RCUTILS_COLORIZED_OUTPUT=1" >> ${HOME}/.bashrc - -# create the credentials to be able to pull private repos using ssh -USER root -RUN mkdir /root/.ssh/ && ssh-keyscan github.com | tee -a /root/.ssh/known_hosts -RUN echo "session required pam_limits.so" | tee --append /etc/pam.d/common-session > /dev/null - - -FROM environment-variables as final -COPY --from=base-workspace / / - -# start as ROS user -USER ${USER} -WORKDIR ${ROS2_WORKSPACE} +ARG BASE_TAG=iron +FROM ghcr.io/aica-technology/ros2-control:${BASE_TAG} + +ARG VERSION=v0.0.0 +ARG BASE_TAG=iron +LABEL org.opencontainers.image.title="AICA ROS 2 image" +LABEL org.opencontainers.image.description="AICA base ROS 2 image (includes ros2_control)" +LABEL org.opencontainers.image.version="${VERSION}" +LABEL org.opencontainers.image.base.name="docker.io/library/ros:${BASE_TAG}" +LABEL tech.aica.image.metadata='{"type":"base/ws","base":{"name":"docker.io/library/ros","version":"'${BASE_TAG}'"}}' \ No newline at end of file diff --git a/ros2_ws/build.sh b/ros2_ws/build.sh index 09b599a..266e061 100755 --- a/ros2_ws/build.sh +++ b/ros2_ws/build.sh @@ -1,7 +1,7 @@ #!/bin/bash -IMAGE_NAME=aica-technology/ros2-ws -BASE_TAG=humble +IMAGE_NAME=ghcr.io/aica-technology/ros2-ws +BASE_TAG=iron SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" if [[ ! -f "${SCRIPT_DIR}"/config/sshd_entrypoint.sh ]]; then @@ -31,16 +31,5 @@ while [ "$#" -gt 0 ]; do esac done -docker pull "ros:${BASE_TAG}" -BUILD_FLAGS+=(--build-arg BASE_TAG="${BASE_TAG}") - -if [[ "$OSTYPE" != "darwin"* ]]; then - USER_ID="$(id -u "${USER}")" - GROUP_ID="$(id -g "${USER}")" - BUILD_FLAGS+=(--build-arg UID="${USER_ID}") - BUILD_FLAGS+=(--build-arg GID="${GROUP_ID}") -fi - -BUILD_FLAGS+=(-t "${IMAGE_NAME}":"${BASE_TAG}") - -DOCKER_BUILDKIT=1 docker build "${BUILD_FLAGS[@]}" . +BUILD_FLAGS+=(--build-arg=BASE_TAG=${BASE_TAG}) +docker buildx build -t "${IMAGE_NAME}":"${BASE_TAG}" "${BUILD_FLAGS[@]}" .