diff --git a/.github/workflows/docker-focal.yml b/.github/workflows/docker-focal.yml new file mode 100644 index 0000000..2827e9a --- /dev/null +++ b/.github/workflows/docker-focal.yml @@ -0,0 +1,15 @@ +# This workflow will only build for Pull Requests which are opened, changed , merged +# that has changes in focal folder or related files +name: Docker Focal build +on: + pull_request: + types: [opened, synchronize, reopened] + paths: + - '**' + - '!jammy/**' # Exclude jammy folder +jobs: + # Focal 20.04 (ROS1 Noetic/ ROS2 Foxy) + docker-build-focal: + uses: usdot-fhwa-stol/actions/.github/workflows/docker.yml@main + with: + file: ./focal/Dockerfile diff --git a/.github/workflows/docker-jammy.yml b/.github/workflows/docker-jammy.yml new file mode 100644 index 0000000..732ecf1 --- /dev/null +++ b/.github/workflows/docker-jammy.yml @@ -0,0 +1,15 @@ +# This workflow will only build for Pull Requests which are opened, changed , merged +# that has changes in jammy folder or related files +name: Docker Jammy build +on: + pull_request: + types: [opened, synchronize, reopened] + paths: + - '**' + - '!focal/**' # Exclude focal folder +jobs: + # Jammy 22.04 (ROS2 Humble) + docker-build-jammy: + uses: usdot-fhwa-stol/actions/.github/workflows/docker.yml@main + with: + file: ./jammy/Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index d71952d..0000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,9 +0,0 @@ -# This workflow will only build for Pull Requests which are opened, changed , merged -name: Docker build -on: - pull_request: - types: [opened, synchronize, reopened] - -jobs: - docker: - uses: usdot-fhwa-stol/actions/.github/workflows/docker.yml@main \ No newline at end of file diff --git a/.github/workflows/dockerhub-focal.yml b/.github/workflows/dockerhub-focal.yml new file mode 100644 index 0000000..2f698a1 --- /dev/null +++ b/.github/workflows/dockerhub-focal.yml @@ -0,0 +1,25 @@ +# This workflow will build and push official docker images for Focal OS when new push occurs +# to develop, master, release branches but doesn't run any unit test or sonar scanner +name: Docker Hub Focal build +on: + push: + branches: + - develop + - master + - "release/*" + tags: + - "carma-system-*" + paths: + - '**' # Build when there are changes in focal folder or related files + - '!jammy/**' # Exclude jammy folder +jobs: + # Focal 20.04 (ROS1 Noetic/ ROS2 Foxy) + dockerhub-focal: + uses: usdot-fhwa-stol/actions/.github/workflows/dockerhub.yml@main + secrets: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + with: + file: ./focal/Dockerfile + # TODO: add focal suffix when humble is migrated + #tag_name_suffix: focal https://usdot-carma.atlassian.net/browse/ARC-227 \ No newline at end of file diff --git a/.github/workflows/dockerhub-jammy.yml b/.github/workflows/dockerhub-jammy.yml new file mode 100644 index 0000000..bfadf15 --- /dev/null +++ b/.github/workflows/dockerhub-jammy.yml @@ -0,0 +1,24 @@ +# This workflow will build and push official docker images for Focal OS when new push occurs +# to develop, master, release branches but doesn't run any unit test or sonar scanner +name: Docker Hub Jammy build +on: + push: + branches: + - develop + - master + - "release/*" + tags: + - "carma-system-*" + paths: + - '**' # Build when there are changes in jammy folder or related files + - '!focal/**' # Exclude focal folder +jobs: + # Jammy 22.04 (ROS2 Humble) + dockerhub-jammy: + uses: usdot-fhwa-stol/actions/.github/workflows/dockerhub.yml@main + secrets: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + with: + file: ./jammy/Dockerfile + tag_name_suffix: jammy \ No newline at end of file diff --git a/.github/workflows/dockerhub.yml b/.github/workflows/dockerhub.yml deleted file mode 100644 index 388fe1d..0000000 --- a/.github/workflows/dockerhub.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This workflow will build and push official docker images when new push occurs to develop, master, release branches but doesn't run any unit test or sonar scanner -name: Docker Hub build -on: - push: - branches: - - develop - - master - - "release/*" - tags: - - "carma-system-*" -jobs: - dockerhub: - uses: usdot-fhwa-stol/actions/.github/workflows/dockerhub.yml@main - secrets: - DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} \ No newline at end of file diff --git a/docker/build-image.sh b/docker/build-image.sh index 4157a4a..85b1b6f 100755 --- a/docker/build-image.sh +++ b/docker/build-image.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (C) 2018-2021 LEIDOS. +# Copyright (C) 2018-2024 LEIDOS. # # Licensed under the Apache License, Version 2.0 (the "License"); you may not # use this file except in compliance with the License. You may obtain a copy of @@ -13,10 +13,11 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under # the License. -set -x USERNAME=usdotfhwastol BRANCH=$(git rev-parse --abbrev-ref HEAD) +BUILD_FOCAL=false +BUILD_JAMMY=false cd "$(dirname "$0")" IMAGE=$(basename `git rev-parse --show-toplevel`) @@ -34,7 +35,8 @@ while [[ $# -gt 0 ]]; do shift ;; --system-release) - SYSTEM_RELEASE=true + USERNAME=usdotfhwastol + COMPONENT_VERSION_STRING=$("./get-system-version.sh") shift ;; -p|--push) @@ -56,6 +58,14 @@ while [[ $# -gt 0 ]]; do fi shift ;; + --focal) + BUILD_FOCAL=true + shift + ;; + --jammy) + BUILD_JAMMY=true + shift + ;; esac done @@ -63,32 +73,54 @@ if [[ -z "$COMPONENT_VERSION_STRING" ]]; then COMPONENT_VERSION_STRING=$("./get-component-version.sh") fi -echo "Building docker image for $IMAGE version: $COMPONENT_VERSION_STRING" -echo "Final image name: $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING" +build_image() { + local dockerfile_path=$1 + local tag_suffix=$2 -cd .. -docker build --network=host --no-cache -t $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING \ - --build-arg VERSION="$COMPONENT_VERSION_STRING" \ - --build-arg VCS_REF=`git rev-parse --short HEAD` \ - --build-arg BUILD_DATE=`date -u +”%Y-%m-%dT%H:%M:%SZ”` . + echo "Building docker image for $IMAGE version: $COMPONENT_VERSION_STRING using Dockerfile: $dockerfile_path" + echo "Final image name: $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING$tag_suffix" + + DOCKER_BUILDKIT=1 docker build --network=host -t $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING$tag_suffix \ + --build-arg VERSION="$COMPONENT_VERSION_STRING" \ + --build-arg VCS_REF=`git rev-parse --short HEAD` \ + --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ + -f $dockerfile_path . + + TAGS+=("$USERNAME/$IMAGE:$COMPONENT_VERSION_STRING$tag_suffix") + + docker tag $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING$tag_suffix $USERNAME/$IMAGE:latest$tag_suffix + TAGS+=("$USERNAME/$IMAGE:latest$tag_suffix") + + echo "Tagged $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING$tag_suffix as $USERNAME/$IMAGE:latest$tag_suffix" +} TAGS=() -TAGS+=("$USERNAME/$IMAGE:$COMPONENT_VERSION_STRING") -docker tag $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING $USERNAME/$IMAGE:latest -TAGS+=("$USERNAME/$IMAGE:latest") +cd .. + +# If neither --focal nor --jammy is specified, build only focal for now. +# Once all humble related changes are merged into develop, jammy should be enabled. +# https://usdot-carma.atlassian.net/browse/ARC-227 +if [ "$BUILD_FOCAL" = false ] && [ "$BUILD_JAMMY" = false ]; then + BUILD_FOCAL=true + BUILD_JAMMY=false +fi -echo "Tagged $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING as $USERNAME/$IMAGE:latest" +# TODO, distinguish with suffix when Humble is fully integrated +# until then focal will have no suffix and be the main image +# https://usdot-carma.atlassian.net/browse/ARC-227 +if [ "$BUILD_FOCAL" = true ]; then + echo "Building carma-base focal image" + build_image "focal/Dockerfile" "" #replace with "-focal" +fi -if [ "$SYSTEM_RELEASE" = true ]; then - SYSTEM_VERSION_STRING=$("./get-system-version.sh") - docker tag $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING $USERNAME/$IMAGE:$SYSTEM_VERSION_STRING - echo "Tagged $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING as $USERNAME/$IMAGE:$SYSTEM_VERSION_STRING" - TAGS+=("$USERNAME/$IMAGE:$SYSTEM_VERSION_STRING") +if [ "$BUILD_JAMMY" = true ]; then + echo "Building carma-base jammy image" + build_image "jammy/Dockerfile" "-jammy" fi if [ "$PUSH" = true ]; then - for tag in $TAGS; do + for tag in "${TAGS[@]}"; do docker push "${tag}" done fi diff --git a/docker/get-component-version.sh b/docker/get-component-version.sh index e5979fe..321fa55 100755 --- a/docker/get-component-version.sh +++ b/docker/get-component-version.sh @@ -1,21 +1,35 @@ -#!/bin/bash - -# Copyright (C) 2018-2021 LEIDOS. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - -cd "$(dirname "$0")" -cd .. -COMPONENT_TAG_PREFIX="${PWD##*/}" -git describe --all --match="$COMPONENT_TAG_PREFIX*" --always --dirty="-SNAPSHOT" | awk -F "/" '{print $NF}' | sed "s/$COMPONENT_TAG_PREFIX\_//" - +# Copyright (C) 2018-2024 LEIDOS. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +# Change to the directory containing the script +cd "$(dirname "$0")" + +# Move up one directory (likely to the root of the project) +cd .. + +# Get the last commit message +COMMIT_MSG=$(git log -1 --pretty=%B) + +# Remove newlines and special characters, replace spaces with underscores +VERSION=$(echo "$COMMIT_MSG" | tr -d '\n' | tr -dc '[:alnum:][:space:]' | tr '[:space:]' '_') + +# Limit the length of the version string (e.g., to 50 characters) +VERSION="${VERSION:0:50}" + +# Append -SNAPSHOT if there are uncommitted changes +if [[ -n $(git status -s) ]]; then + VERSION="${VERSION}-SNAPSHOT" +fi + +echo "$VERSION" \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh old mode 100755 new mode 100644 index 179db01..8264aa8 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,28 +1,28 @@ -#!/bin/bash - -# Copyright (C) 2018-2021 LEIDOS. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - -# Intialize the CARMA environment by sourcing the necessary ROS shell scripts -# then run whatever string is passed as argument to this script in that -# initialized context. E.g. "entrypoint.sh roslaunch carma carma_docker.launch" -# runs "roslaunch carma carma_docker.launch" after setting up the environment -# such that ROS and CARMA are on the user's PATH - -if [ $# -eq 0 ]; then - # If no other command is passed to this script, run bash - source ~/.base-image/init-env.sh; exec "bash" -else - source ~/.base-image/init-env.sh; exec "$@" -fi +#!/bin/bash + +# Copyright (C) 2018-2021 LEIDOS. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +# Intialize the CARMA environment by sourcing the necessary ROS shell scripts +# then run whatever string is passed as argument to this script in that +# initialized context. E.g. "entrypoint.sh roslaunch carma carma_docker.launch" +# runs "roslaunch carma carma_docker.launch" after setting up the environment +# such that ROS and CARMA are on the user's PATH + +if [ $# -eq 0 ]; then + # If no other command is passed to this script, run bash + source ~/.base-image/init-env.sh; exec "bash" +else + source ~/.base-image/init-env.sh; exec "$@" +fi diff --git a/CATKIN_IGNORE b/focal/CATKIN_IGNORE similarity index 100% rename from CATKIN_IGNORE rename to focal/CATKIN_IGNORE diff --git a/Dockerfile b/focal/Dockerfile similarity index 95% rename from Dockerfile rename to focal/Dockerfile index 6e0bec7..92cb789 100644 --- a/Dockerfile +++ b/focal/Dockerfile @@ -1,271 +1,274 @@ -# Copyright (C) 2018-2024 LEIDOS. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - -# CARMA Base Image Docker Configuration Script - -# The parent docker image has CUDA support since some modules use GPU-based acceleration -FROM nvidia/cudagl:11.2.0-devel-ubuntu20.04 - -# Define arguments which are used in the following metadata definition -ARG BUILD_DATE="NULL" -ARG VERSION="NULL" -ARG VCS_REF="NULL" - -# Specify docker image metadata -LABEL org.label-schema.schema-version="1.0" -LABEL org.label-schema.name="carma-base" -LABEL org.label-schema.description="Base operating system install for the CARMA Platform" -LABEL org.label-schema.vendor="Leidos" -LABEL org.label-schema.version=${VERSION} -LABEL org.label-schema.url="https://highways.dot.gov/research/research-programs/operations/CARMA" -LABEL org.label-schema.vcs-url="https://github.com/usdot-fhwa-stol/carma-platform" -LABEL org.label-schema.vcs-ref=${VCS_REF} -LABEL org.label-schema.build-date=${BUILD_DATE} - -# Specify which platform GPUs are available inside the container -ENV NVIDIA_VISIBLE_DEVICES=${NVIDIA_VISIBLE_DEVICES:-all} \ - # Specify which driver libraries/binaries will be mounted inside the container - NVIDIA_DRIVER_CAPABILITIES=${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics - -# Avoid interactive prompts during the building of this docker image -ARG DEBIAN_FRONTEND="noninteractive" - -ARG AUTOWAREAUTO_DEPS="coinor-libipopt-dev \ - coinor-libipopt1v5 \ - libarmadillo-dev \ - libcgal-dev \ - libmumps-5.2.1 \ - libmumps-dev \ - libmumps-seq-5.2.1 \ - libmumps-seq-dev \ - libproj-dev \ - libscalapack-mpi-dev \ - libscalapack-openmpi-dev \ - libscalapack-openmpi2.1 \ - libscotch-6.0 \ - ros-foxy-acado-vendor \ - ros-foxy-ament-cmake-google-benchmark \ - ros-foxy-apex-test-tools \ - ros-foxy-automotive-platform-msgs \ - ros-foxy-casadi-vendor \ - ros-foxy-diagnostic-updater \ - ros-foxy-gps-msgs \ - ros-foxy-joy-linux \ - ros-foxy-lgsvl-msgs \ - ros-foxy-osqp-vendor \ - ros-foxy-osrf-testing-tools-cpp \ - ros-foxy-point-cloud-msg-wrapper \ - ros-foxy-ros-testing \ - ros-foxy-rosapi \ - ros-foxy-rosapi-msgs \ - ros-foxy-rosbridge-library \ - ros-foxy-rosbridge-msgs \ - ros-foxy-rosbridge-server \ - ros-foxy-tvm-vendor \ - ros-foxy-udp-driver \ - ros-foxy-udp-msgs \ - ros-foxy-velodyne-pointcloud \ - ros-foxy-yaml-cpp-vendor" - -ARG BASE_DEPS="ca-certificates \ - curl \ - gnupg2 \ - locales \ - lsb-release \ - openssl \ - python3-rosinstall \ - ros-noetic-desktop-full \ - xterm \ - libmsgsl-dev" - -ARG ROS_DEPS="apt-transport-https \ - apt-utils \ - automake \ - autotools-dev \ - dialog \ - gcovr \ - gdb \ - git \ - gnuplot-qt \ - jq \ - less \ - libboost-python-dev \ - libfftw3-dev \ - libgeographic-dev \ - libgmock-dev \ - libnl-genl-3-dev \ - libopenblas-dev \ - libpcap-dev \ - libpugixml-dev \ - lttng-tools \ - lttng-modules-dkms \ - liblttng-ust-dev \ - mesa-utils \ - nano \ - nodejs \ - python3-babeltrace \ - python3-catkin-pkg \ - python3-catkin-tools \ - python3-colcon-common-extensions \ - python3-future \ - python3-lttng \ - python3-pip \ - python3-rosdep \ - python3-setuptools \ - python3-testresources \ - python3-vcstool \ - python3-pybind11 \ - ros-foxy-desktop \ - ros-foxy-rmw-cyclonedds-cpp \ - ros-foxy-pcl-ros \ - ros-foxy-test-msgs \ - ros-foxy-nmea-msgs \ - ros-foxy-gps-tools \ - ros-foxy-rosbag2-storage-mcap \ - ros-noetic-costmap-2d \ - ros-noetic-dataspeed-can \ - ros-noetic-dbw-mkz \ - ros-noetic-geodesy \ - ros-noetic-grid-map \ - ros-noetic-lusb \ - ros-noetic-rosserial \ - ros-noetic-rosserial-arduino \ - ros-noetic-velodyne-pcl \ - software-properties-common \ - sqlite3 \ - ssh \ - sudo \ - tmux \ - unzip \ - vim \ - wait-for-it \ - x-window-system" - -SHELL ["/bin/bash", "-o", "pipefail", "-c"] - -# Add carma user -RUN useradd -m carma && \ - echo "carma:carma" | chpasswd && \ - usermod --shell /bin/bash carma && \ - usermod -aG sudo carma && \ - mkdir -p /etc/sudoers.d && \ - echo "carma ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/carma && \ - chmod 0440 /etc/sudoers.d/carma && \ - usermod --uid 1000 carma && \ - groupmod --gid 1000 carma && \ - mkdir -p /opt/carma/{launch,logs,routes} && \ - chown carma:carma -R /opt/carma - -COPY --chown=carma package.xml /home/carma/.base-image/workspace/src/carma_base/ -COPY --chown=carma entrypoint.sh init-env.sh /home/carma/.base-image/ -COPY --chown=carma ./code_coverage /home/carma/.ci-image/engineering_tools/code_coverage - -# Install ROS Noetic -ARG ROS_DISTRO=noetic -RUN sed -i 's|http://archive.ubuntu.com|http://us.archive.ubuntu.com|g' /etc/apt/sources.list && \ - # Add ROS 1 repo - apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 && \ - sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(grep -oP "UBUNTU_CODENAME\=\K.*" /etc/os-release) main" > /etc/apt/sources.list.d/ros-latest.list' && \ - # Add ROS 2 repo - apt-key adv --fetch-keys https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc && \ - sh -c 'echo "deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(grep -oP "UBUNTU_CODENAME\=\K.*" /etc/os-release) main" > /etc/apt/sources.list.d/ros2-latest.list' && \ - apt update && \ - apt-get install --no-install-recommends --yes ${BASE_DEPS} && \ - # Prepare for ROS 2 Foxy installation - locale-gen en_US en_US.UTF-8 && \ - update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ - export LANG=en_US.UTF-8 && \ - # Install Sonar dependency nodejs - curl -sL https://deb.nodesource.com/setup_16.x | bash - && \ - # Install ROS 2 Foxy - apt-get install --no-install-recommends --yes ${AUTOWAREAUTO_DEPS} ${ROS_DEPS} && \ - # Install AutonomouStuff dependencies - sh -c 'echo "deb [trusted=yes] https://s3.amazonaws.com/autonomoustuff-repo/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/autonomoustuff-public.list' && \ - apt-get update && \ - apt-get install --no-install-recommends --yes libas-common && \ - # Vimba Deps - add-apt-repository --update --yes ppa:rock-core/qt4 && \ - apt-get install --fix-missing --no-install-recommends --yes libqtcore4 libqt4-network libqt4-qt3support && \ - # Install KVaser CAN - add-apt-repository --update --yes ppa:astuff/kvaser-linux && \ - apt-get install --no-install-recommends --yes kvaser-canlib-dev can-utils && \ - # Download a cmake module for PROJ, needed for lanelet2_extension, autoware_lanelet2_ros_interface, and maybe more - curl --output /usr/share/cmake-3.16/Modules/FindPROJ4.cmake https://raw.githubusercontent.com/mloskot/cmake-modules/master/modules/FindPROJ4.cmake && \ - # Install version 45.2.0 for setuptools since that is the latest version available for ubuntu focal - # Version match is needed to build some of the packages - pip3 install --no-cache-dir setuptools==45.2.0 simple-pid && \ - ### - # TODO: The following sequence of commands make -j a local update to ament_cmake to resolve an issue - # with the default xml parsing. Once the PR https://github.com/ament/ament_cmake/pull/287 is - # backported to ROS 2 Foxy, this can be removed. - ### - curl https://raw.githubusercontent.com/ament/ament_cmake/efcbe328d001c9ade93a06bd8035642e37dd6f2a/ament_cmake_core/cmake/core/package_xml_2_cmake.py > /opt/ros/foxy/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py && \ - # Vimba source - curl -L -o Vimba_v5.0_Linux.tgz https://github.com/usdot-fhwa-stol/avt_vimba_camera/raw/fix/update_vimba_sdk/Vimba_v5.0_Linux.tgz && \ - tar -xzf ./Vimba_v5.0_Linux.tgz -C /opt && \ - ./opt/Vimba_5_0/VimbaGigETL/Install.sh && \ - rm Vimba_v5.0_Linux.tgz && \ - # Set environment variable for SonarQube Binaries. Two binaries will go in this directory: - # - The Build Wrapper which executes a code build to capture C++ - # - The Sonar Scanner which uploads the results to SonarCloud - SONAR_DIR=/opt/sonarqube && \ - # Pull scanner from internet - mkdir $SONAR_DIR && \ - curl -o $SONAR_DIR/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip && \ - curl -o $SONAR_DIR/build-wrapper.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip && \ - # Unzip scanner - unzip $SONAR_DIR/sonar-scanner.zip -d "$SONAR_DIR"/ && \ - unzip $SONAR_DIR/build-wrapper.zip -d "$SONAR_DIR"/ && \ - # Remove zip files - rm $SONAR_DIR/sonar-scanner.zip && \ - rm $SONAR_DIR/build-wrapper.zip && \ - # Rename files - mv "$SONAR_DIR"/sonar-scanner-* "$SONAR_DIR"/sonar-scanner/ && \ - mv "$SONAR_DIR"/build-wrapper-* "$SONAR_DIR"/build-wrapper/ && \ - # FIXME: The following symlink will no longer be required once images - # that depend on carma-base change from wait-for-it.sh to wait-for-it - ln -s /usr/bin/wait-for-it /usr/bin/wait-for-it.sh && \ - # Install non-ros1 dependant version of catkin - # This can be used without issue for ROS2 builds wheras the noetic version has compatability issues - # install catkin_pkg - sudo -u carma mkdir /home/carma/catkin_ros2_ws && \ - sudo -u carma git clone https://github.com/ros-infrastructure/catkin_pkg.git /home/carma/catkin_ros2_ws/catkin_pkg && \ - cd /home/carma/catkin_ros2_ws/catkin_pkg && \ - # Checkout a known working commit - sudo -u carma git checkout 60096f4b4a0975774651122b7e2d346545f8098a && \ - sudo -u carma python3 setup.py install --prefix /home/carma/catkin --single-version-externally-managed --record foo --install-layout deb && \ - # install catkin - sudo -u carma git clone https://github.com/ros/catkin.git /home/carma/catkin_ros2_ws/catkin && \ - cd /home/carma/catkin_ros2_ws/catkin && \ - # Checkout a known working commit - sudo -u carma git checkout 085e8950cafa3eb979edff1646b9e3fe55a7053a && \ - sudo -u carma mkdir build && \ - cd build && \ - PYTHONPATH=/home/carma/catkin/lib/python3/dist-packages/ sudo -u carma cmake .. -DCMAKE_INSTALL_PREFIX=/home/carma/catkin -DPYTHON_EXECUTABLE=/usr/bin/python3 && \ - sudo -u carma make -j install && \ - # Result is installation under ~/catkin so use with - # source ~/cakin/setup.bash - rosdep --rosdistro noetic init && \ - sudo -u carma rosdep --rosdistro noetic update && \ - sudo -u carma rosdep --rosdistro noetic install --from-paths /home/carma/.base-image/workspace/src --ignore-src -y && \ - sudo -u carma echo "source ~/.base-image/init-env.sh" >> /home/carma/.bashrc && \ - sudo -u carma echo "cd /opt/carma" >> /home/carma/.bashrc && \ - # Install Java 17 - apt-get install -y openjdk-17-jdk && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -USER carma - -ENTRYPOINT [ "/home/carma/.base-image/entrypoint.sh" ] +# Copyright (C) 2018-2024 LEIDOS. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +# CARMA Base Image Docker Configuration Script + +# The parent docker image has CUDA support since some modules use GPU-based acceleration +FROM nvidia/cudagl:11.2.0-devel-ubuntu20.04 + +# Dockerfile directory relative to root +ARG DOCKERFILE_DIR="focal" + +# Define arguments which are used in the following metadata definition +ARG BUILD_DATE="NULL" +ARG VERSION="NULL" +ARG VCS_REF="NULL" + +# Specify docker image metadata +LABEL org.label-schema.schema-version="1.0" +LABEL org.label-schema.name="carma-base" +LABEL org.label-schema.description="Base operating system install for the CARMA Platform" +LABEL org.label-schema.vendor="Leidos" +LABEL org.label-schema.version=${VERSION} +LABEL org.label-schema.url="https://highways.dot.gov/research/research-programs/operations/CARMA" +LABEL org.label-schema.vcs-url="https://github.com/usdot-fhwa-stol/carma-base" +LABEL org.label-schema.vcs-ref=${VCS_REF} +LABEL org.label-schema.build-date=${BUILD_DATE} + +# Specify which platform GPUs are available inside the container +ENV NVIDIA_VISIBLE_DEVICES=${NVIDIA_VISIBLE_DEVICES:-all} \ + # Specify which driver libraries/binaries will be mounted inside the container + NVIDIA_DRIVER_CAPABILITIES=${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics + +# Avoid interactive prompts during the building of this docker image +ARG DEBIAN_FRONTEND="noninteractive" + +ARG AUTOWAREAUTO_DEPS="coinor-libipopt-dev \ + coinor-libipopt1v5 \ + libarmadillo-dev \ + libcgal-dev \ + libmumps-5.2.1 \ + libmumps-dev \ + libmumps-seq-5.2.1 \ + libmumps-seq-dev \ + libproj-dev \ + libscalapack-mpi-dev \ + libscalapack-openmpi-dev \ + libscalapack-openmpi2.1 \ + libscotch-6.0 \ + ros-foxy-acado-vendor \ + ros-foxy-ament-cmake-google-benchmark \ + ros-foxy-apex-test-tools \ + ros-foxy-automotive-platform-msgs \ + ros-foxy-casadi-vendor \ + ros-foxy-diagnostic-updater \ + ros-foxy-gps-msgs \ + ros-foxy-joy-linux \ + ros-foxy-lgsvl-msgs \ + ros-foxy-osqp-vendor \ + ros-foxy-osrf-testing-tools-cpp \ + ros-foxy-point-cloud-msg-wrapper \ + ros-foxy-ros-testing \ + ros-foxy-rosapi \ + ros-foxy-rosapi-msgs \ + ros-foxy-rosbridge-library \ + ros-foxy-rosbridge-msgs \ + ros-foxy-rosbridge-server \ + ros-foxy-tvm-vendor \ + ros-foxy-udp-driver \ + ros-foxy-udp-msgs \ + ros-foxy-velodyne-pointcloud \ + ros-foxy-yaml-cpp-vendor" + +ARG BASE_DEPS="ca-certificates \ + curl \ + gnupg2 \ + locales \ + lsb-release \ + openssl \ + python3-rosinstall \ + ros-noetic-desktop-full \ + xterm \ + libmsgsl-dev" + +ARG ROS_DEPS="apt-transport-https \ + apt-utils \ + automake \ + autotools-dev \ + dialog \ + gcovr \ + gdb \ + git \ + gnuplot-qt \ + jq \ + less \ + libboost-python-dev \ + libfftw3-dev \ + libgeographic-dev \ + libgmock-dev \ + libnl-genl-3-dev \ + libopenblas-dev \ + libpcap-dev \ + libpugixml-dev \ + lttng-tools \ + lttng-modules-dkms \ + liblttng-ust-dev \ + mesa-utils \ + nano \ + nodejs \ + python3-babeltrace \ + python3-catkin-pkg \ + python3-catkin-tools \ + python3-colcon-common-extensions \ + python3-future \ + python3-lttng \ + python3-pip \ + python3-rosdep \ + python3-setuptools \ + python3-testresources \ + python3-vcstool \ + python3-pybind11 \ + ros-foxy-desktop \ + ros-foxy-rmw-cyclonedds-cpp \ + ros-foxy-pcl-ros \ + ros-foxy-test-msgs \ + ros-foxy-nmea-msgs \ + ros-foxy-gps-tools \ + ros-foxy-rosbag2-storage-mcap \ + ros-noetic-costmap-2d \ + ros-noetic-dataspeed-can \ + ros-noetic-dbw-mkz \ + ros-noetic-geodesy \ + ros-noetic-grid-map \ + ros-noetic-lusb \ + ros-noetic-rosserial \ + ros-noetic-rosserial-arduino \ + ros-noetic-velodyne-pcl \ + software-properties-common \ + sqlite3 \ + ssh \ + sudo \ + tmux \ + unzip \ + vim \ + wait-for-it \ + x-window-system" + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +# Add carma user +RUN useradd -m carma && \ + echo "carma:carma" | chpasswd && \ + usermod --shell /bin/bash carma && \ + usermod -aG sudo carma && \ + mkdir -p /etc/sudoers.d && \ + echo "carma ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/carma && \ + chmod 0440 /etc/sudoers.d/carma && \ + usermod --uid 1000 carma && \ + groupmod --gid 1000 carma && \ + mkdir -p /opt/carma/{launch,logs,routes} && \ + chown carma:carma -R /opt/carma + +COPY --chown=carma ${DOCKERFILE_DIR}/package.xml /home/carma/.base-image/workspace/src/carma_base/ +COPY --chown=carma ./entrypoint.sh ${DOCKERFILE_DIR}/init-env.sh /home/carma/.base-image/ +COPY --chown=carma ./code_coverage /home/carma/.ci-image/engineering_tools/code_coverage + +# Install ROS Noetic +ARG ROS_DISTRO=noetic +RUN sed -i 's|http://archive.ubuntu.com|http://us.archive.ubuntu.com|g' /etc/apt/sources.list && \ + # Add ROS 1 repo + apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 && \ + sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(grep -oP "UBUNTU_CODENAME\=\K.*" /etc/os-release) main" > /etc/apt/sources.list.d/ros-latest.list' && \ + # Add ROS 2 repo + apt-key adv --fetch-keys https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc && \ + sh -c 'echo "deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(grep -oP "UBUNTU_CODENAME\=\K.*" /etc/os-release) main" > /etc/apt/sources.list.d/ros2-latest.list' && \ + apt update && \ + apt-get install --no-install-recommends --yes ${BASE_DEPS} && \ + # Prepare for ROS 2 Foxy installation + locale-gen en_US en_US.UTF-8 && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + export LANG=en_US.UTF-8 && \ + # Install Sonar dependency nodejs + curl -sL https://deb.nodesource.com/setup_16.x | bash - && \ + # Install ROS 2 Foxy + apt-get install --no-install-recommends --yes ${AUTOWAREAUTO_DEPS} ${ROS_DEPS} && \ + # Install AutonomouStuff dependencies + sh -c 'echo "deb [trusted=yes] https://s3.amazonaws.com/autonomoustuff-repo/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/autonomoustuff-public.list' && \ + apt-get update && \ + apt-get install --no-install-recommends --yes libas-common && \ + # Vimba Deps + add-apt-repository --update --yes ppa:rock-core/qt4 && \ + apt-get install --fix-missing --no-install-recommends --yes libqtcore4 libqt4-network libqt4-qt3support && \ + # Install KVaser CAN + add-apt-repository --update --yes ppa:astuff/kvaser-linux && \ + apt-get install --no-install-recommends --yes kvaser-canlib-dev can-utils && \ + # Download a cmake module for PROJ, needed for lanelet2_extension, autoware_lanelet2_ros_interface, and maybe more + curl --output /usr/share/cmake-3.16/Modules/FindPROJ4.cmake https://raw.githubusercontent.com/mloskot/cmake-modules/master/modules/FindPROJ4.cmake && \ + # Install version 45.2.0 for setuptools since that is the latest version available for ubuntu focal + # Version match is needed to build some of the packages + pip3 install --no-cache-dir setuptools==45.2.0 simple-pid && \ + ### + # TODO: The following sequence of commands make -j a local update to ament_cmake to resolve an issue + # with the default xml parsing. Once the PR https://github.com/ament/ament_cmake/pull/287 is + # backported to ROS 2 Foxy, this can be removed. + ### + curl https://raw.githubusercontent.com/ament/ament_cmake/efcbe328d001c9ade93a06bd8035642e37dd6f2a/ament_cmake_core/cmake/core/package_xml_2_cmake.py > /opt/ros/foxy/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py && \ + # Vimba source + curl -L -o Vimba_v5.0_Linux.tgz https://github.com/usdot-fhwa-stol/avt_vimba_camera/raw/fix/update_vimba_sdk/Vimba_v5.0_Linux.tgz && \ + tar -xzf ./Vimba_v5.0_Linux.tgz -C /opt && \ + ./opt/Vimba_5_0/VimbaGigETL/Install.sh && \ + rm Vimba_v5.0_Linux.tgz && \ + # Set environment variable for SonarQube Binaries. Two binaries will go in this directory: + # - The Build Wrapper which executes a code build to capture C++ + # - The Sonar Scanner which uploads the results to SonarCloud + SONAR_DIR=/opt/sonarqube && \ + # Pull scanner from internet + mkdir $SONAR_DIR && \ + curl -o $SONAR_DIR/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip && \ + curl -o $SONAR_DIR/build-wrapper.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip && \ + # Unzip scanner + unzip $SONAR_DIR/sonar-scanner.zip -d "$SONAR_DIR"/ && \ + unzip $SONAR_DIR/build-wrapper.zip -d "$SONAR_DIR"/ && \ + # Remove zip files + rm $SONAR_DIR/sonar-scanner.zip && \ + rm $SONAR_DIR/build-wrapper.zip && \ + # Rename files + mv "$SONAR_DIR"/sonar-scanner-* "$SONAR_DIR"/sonar-scanner/ && \ + mv "$SONAR_DIR"/build-wrapper-* "$SONAR_DIR"/build-wrapper/ && \ + # FIXME: The following symlink will no longer be required once images + # that depend on carma-base change from wait-for-it.sh to wait-for-it + ln -s /usr/bin/wait-for-it /usr/bin/wait-for-it.sh && \ + # Install non-ros1 dependant version of catkin + # This can be used without issue for ROS2 builds wheras the noetic version has compatability issues + # install catkin_pkg + sudo -u carma mkdir /home/carma/catkin_ros2_ws && \ + sudo -u carma git clone https://github.com/ros-infrastructure/catkin_pkg.git /home/carma/catkin_ros2_ws/catkin_pkg && \ + cd /home/carma/catkin_ros2_ws/catkin_pkg && \ + # Checkout a known working commit + sudo -u carma git checkout 60096f4b4a0975774651122b7e2d346545f8098a && \ + sudo -u carma python3 setup.py install --prefix /home/carma/catkin --single-version-externally-managed --record foo --install-layout deb && \ + # install catkin + sudo -u carma git clone https://github.com/ros/catkin.git /home/carma/catkin_ros2_ws/catkin && \ + cd /home/carma/catkin_ros2_ws/catkin && \ + # Checkout a known working commit + sudo -u carma git checkout 085e8950cafa3eb979edff1646b9e3fe55a7053a && \ + sudo -u carma mkdir build && \ + cd build && \ + PYTHONPATH=/home/carma/catkin/lib/python3/dist-packages/ sudo -u carma cmake .. -DCMAKE_INSTALL_PREFIX=/home/carma/catkin -DPYTHON_EXECUTABLE=/usr/bin/python3 && \ + sudo -u carma make -j install && \ + # Result is installation under ~/catkin so use with + # source ~/cakin/setup.bash + rosdep --rosdistro noetic init && \ + sudo -u carma rosdep --rosdistro noetic update && \ + sudo -u carma rosdep --rosdistro noetic install --from-paths /home/carma/.base-image/workspace/src --ignore-src -y && \ + sudo -u carma echo "source ~/.base-image/init-env.sh" >> /home/carma/.bashrc && \ + sudo -u carma echo "cd /opt/carma" >> /home/carma/.bashrc && \ + # Install Java 17 + apt-get install -y openjdk-17-jdk && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +USER carma + +ENTRYPOINT [ "/home/carma/.base-image/entrypoint.sh" ] diff --git a/focal/README.md b/focal/README.md new file mode 100644 index 0000000..accc79c --- /dev/null +++ b/focal/README.md @@ -0,0 +1,28 @@ +| DockerHub Release | DockerHub Release Candidate | DockerHub Develop | +|------|-----|-----| +[![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/usdotfhwastol/carma-base?label=Docker%20Build&logo=232496ED)](https://hub.docker.com/repository/docker/usdotfhwastol/carma-base) | [![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/usdotfhwastolcandidate/carma-base?label=Docker%20Build&logo=232496ED)](https://hub.docker.com/repository/docker/usdotfhwastolcandidate/carma-base) | [![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/usdotfhwastoldev/carma-base?label=Docker%20Build&logo=232496ED)](https://hub.docker.com/repository/docker/usdotfhwastoldev/carma-base) + + +# CARMABase +CARMA Base is the Docker base image for Dockerized releases and deployments of the CARMA Platform. All CARMA images should inherit from this and any dependencies of those images should be instaled in this base image to minimize system build time and final image size. + +# CARMAPlatform +The primary CARMAPlatform repository can be found [here](https://github.com/usdot-fhwa-stol/carma-platform) and is part of the [USDOT FHWA STOL](https://github.com/usdot-fhwa-stol/) +github organization. Documentation on how the CARMAPlatform functions, how it will evolve over time, and how you can contribute can be found at the above links as well + +## Contribution +Welcome to the CARMA contributing guide. Please read this guide to learn about our development process, how to propose pull requests and improvements, and how to build and test your changes to this project. [CARMA Contributing Guide](https://github.com/usdot-fhwa-stol/carma-platform/blob/develop/Contributing.md) + +## Code of Conduct +Please read our [CARMA Code of Conduct](https://github.com/usdot-fhwa-stol/carma-platform/blob/develop/Code_of_Conduct.md) which outlines our expectations for participants within the CARMA community, as well as steps to reporting unacceptable behavior. We are committed to providing a welcoming and inspiring community for all and expect our code of conduct to be honored. Anyone who violates this code of conduct may be banned from the community. + +## Attribution +The development team would like to acknowledge the people who have made direct contributions to the design and code in this repository. [CARMA Attribution](https://github.com/usdot-fhwa-stol/carma-platform/blob/develop/ATTRIBUTION.txt) + +## License +By contributing to the Federal Highway Administration (FHWA) Connected Automated Research Mobility Applications (CARMA), you agree that your contributions will be licensed under its Apache License 2.0 license. [CARMA License](https://github.com/usdot-fhwa-stol/carma-platform/blob/develop/docs/License.md) + +## Contact +Please click on the CARMA logo below to visit the Federal Highway Adminstration(FHWA) CARMA website. + +[![CARMA Image](https://raw.githubusercontent.com/usdot-fhwa-stol/carma-platform/develop/docs/image/CARMA_icon.png)](https://highways.dot.gov/research/research-programs/operations/CARMA) diff --git a/init-env.sh b/focal/init-env.sh old mode 100755 new mode 100644 similarity index 97% rename from init-env.sh rename to focal/init-env.sh index 5704307..1060287 --- a/init-env.sh +++ b/focal/init-env.sh @@ -1,58 +1,58 @@ -#!/bin/bash - -# Copyright (C) 2018-2021 LEIDOS. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - - -# Sets all environment variables and sources scripts necessary for CARMA to operate - -export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/ - -# Export QT X11 Forwarding variables -export QT_X11_NO_MITSHM=1 - -# Set Cyclone DDS as default RMW implementation -export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp - -# Add scanner and wrapper to PATH -export PATH=$PATH:/opt/sonarqube/sonar-scanner/bin/:/opt/sonarqube/build-wrapper/ - -# Add code_coverage script folder to path for gcovr -export PATH=$PATH:/home/carma/.ci-image/engineering_tools/code_coverage/ - -# Add CUDA paths -export CUDA_BIN_PATH=/usr/local/cuda -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64 -export PATH=$PATH:/usr/local/cuda/bin - -# Vimba -export GENICAM_GENTL32_PATH=$GENICAM_GENTL32_PATH:"/opt/Vimba_5_0/VimbaGigETL/CTI/x86_32bit/" -export GENICAM_GENTL64_PATH=$GENICAM_GENTL64_PATH:"/opt/Vimba_5_0/VimbaGigETL/CTI/x86_64bit/" - -if [ -f "/opt/ros/noetic/setup.bash" ]; then - source /opt/ros/noetic/setup.bash -fi - -if [ -f "/opt/autoware.ai/ros/install/setup.bash" ]; then - source /opt/autoware.ai/ros/install/setup.bash -fi - -if [ -f "/opt/carma/install/setup.bash" ]; then - source /opt/carma/install/setup.bash -fi - -# Always source environment variables as last step -if [ -f "/opt/carma/vehicle/config/carma.env" ]; then - source /opt/carma/vehicle/config/carma.env -fi +#!/bin/bash + +# Copyright (C) 2018-2021 LEIDOS. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + + +# Sets all environment variables and sources scripts necessary for CARMA to operate + +export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/ + +# Export QT X11 Forwarding variables +export QT_X11_NO_MITSHM=1 + +# Set Cyclone DDS as default RMW implementation +export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp + +# Add scanner and wrapper to PATH +export PATH=$PATH:/opt/sonarqube/sonar-scanner/bin/:/opt/sonarqube/build-wrapper/ + +# Add code_coverage script folder to path for gcovr +export PATH=$PATH:/home/carma/.ci-image/engineering_tools/code_coverage/ + +# Add CUDA paths +export CUDA_BIN_PATH=/usr/local/cuda +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64 +export PATH=$PATH:/usr/local/cuda/bin + +# Vimba +export GENICAM_GENTL32_PATH=$GENICAM_GENTL32_PATH:"/opt/Vimba_5_0/VimbaGigETL/CTI/x86_32bit/" +export GENICAM_GENTL64_PATH=$GENICAM_GENTL64_PATH:"/opt/Vimba_5_0/VimbaGigETL/CTI/x86_64bit/" + +if [ -f "/opt/ros/noetic/setup.bash" ]; then + source /opt/ros/noetic/setup.bash +fi + +if [ -f "/opt/autoware.ai/ros/install/setup.bash" ]; then + source /opt/autoware.ai/ros/install/setup.bash +fi + +if [ -f "/opt/carma/install/setup.bash" ]; then + source /opt/carma/install/setup.bash +fi + +# Always source environment variables as last step +if [ -f "/opt/carma/vehicle/config/carma.env" ]; then + source /opt/carma/vehicle/config/carma.env +fi diff --git a/package.xml b/focal/package.xml similarity index 100% rename from package.xml rename to focal/package.xml diff --git a/jammy/Dockerfile b/jammy/Dockerfile new file mode 100644 index 0000000..6201a40 --- /dev/null +++ b/jammy/Dockerfile @@ -0,0 +1,96 @@ +# CARMA Base Image Docker Configuration Script + +FROM nvidia/cuda:11.7.1-devel-ubuntu22.04 + +# Avoid interactive prompts during the building of this docker image +ARG DEBIAN_FRONTEND="noninteractive" + +# Dockerfile directory relative to root +ARG DOCKERFILE_DIR="jammy" + +# Define arguments which are used in the following metadata definition +ARG BUILD_DATE="NULL" +ARG VERSION="NULL" +ARG VCS_REF="NULL" + +# Specify docker image metadata +LABEL org.label-schema.schema-version="1.0" +LABEL org.label-schema.name="carma-base" +LABEL org.label-schema.description="Base operating system install for the CARMA Platform" +LABEL org.label-schema.vendor="Leidos" +LABEL org.label-schema.version=${VERSION} +LABEL org.label-schema.url="https://highways.dot.gov/research/research-programs/operations/CARMA" +LABEL org.label-schema.vcs-url="https://github.com/usdot-fhwa-stol/carma-base" +LABEL org.label-schema.vcs-ref=${VCS_REF} +LABEL org.label-schema.build-date=${BUILD_DATE} + +# Specify which platform GPUs are available inside the container +ENV NVIDIA_VISIBLE_DEVICES=${NVIDIA_VISIBLE_DEVICES:-all} +ENV NVIDIA_DRIVER_CAPABILITIES=${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics + +# Copy package lists early +COPY ${DOCKERFILE_DIR}/ros_packages.txt ${DOCKERFILE_DIR}/additional_packages.txt /tmp/ + +# Install basic dependencies +RUN apt-get update && apt-get install -y \ + ca-certificates curl gnupg2 lsb-release + +# Set up ROS2 repository +RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg && \ + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null + +# Install ROS2 packages +RUN apt-get update && \ + apt-get install -y $(cat /tmp/ros_packages.txt) + +# Install additional packages +RUN apt-get update && \ + apt-get install -y $(cat /tmp/additional_packages.txt) + +# Install Python packages +RUN apt-get update && apt-get install -y python3-pip +RUN pip3 install --no-cache-dir vcstool setuptools pybind11 + +# Install Java 17 +RUN apt-get update && apt-get install -y openjdk-17-jdk + +# Clean +RUN rm -rf /var/lib/apt/lists/* + +# Install SonarQube scanner +RUN SONAR_DIR=/opt/sonarqube \ + && mkdir $SONAR_DIR \ + && curl -o $SONAR_DIR/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip \ + && curl -o $SONAR_DIR/build-wrapper.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip \ + && unzip $SONAR_DIR/sonar-scanner.zip -d "$SONAR_DIR"/ \ + && unzip $SONAR_DIR/build-wrapper.zip -d "$SONAR_DIR"/ \ + && rm $SONAR_DIR/sonar-scanner.zip $SONAR_DIR/build-wrapper.zip \ + && mv "$SONAR_DIR"/sonar-scanner-* "$SONAR_DIR"/sonar-scanner/ \ + && mv "$SONAR_DIR"/build-wrapper-* "$SONAR_DIR"/build-wrapper/ + +# Set up ROS 2 environment +RUN echo "source /opt/ros/humble/setup.bash" >> /etc/bash.bashrc + +# Add carma user +RUN useradd -m carma && \ + echo "carma:carma" | chpasswd && \ + usermod --shell /bin/bash carma && \ + usermod -aG sudo carma && \ + mkdir -p /etc/sudoers.d && \ + echo "carma ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/carma && \ + chmod 0440 /etc/sudoers.d/carma && \ + usermod --uid 1000 carma && \ + groupmod --gid 1000 carma && \ + mkdir -p /opt/carma/{launch,logs,routes} && \ + chown carma:carma -R /opt/carma + +# Copy files for carma user +COPY --chown=carma ${DOCKERFILE_DIR}/package.xml /home/carma/.base-image/workspace/src/carma_base/ +COPY --chown=carma ./entrypoint.sh ${DOCKERFILE_DIR}/init-env.sh /home/carma/.base-image/ +COPY --chown=carma ./code_coverage /home/carma/.ci-image/engineering_tools/code_coverage + +USER carma +WORKDIR /home/carma + +# Set the entrypoint +ENTRYPOINT ["/bin/bash"] \ No newline at end of file diff --git a/jammy/README.md b/jammy/README.md new file mode 100644 index 0000000..be917f7 --- /dev/null +++ b/jammy/README.md @@ -0,0 +1,28 @@ +| DockerHub Release | DockerHub Release Candidate | DockerHub Develop | +|------|-----|-----| +[![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/usdotfhwastol/carma-base?label=Docker%20Build&logo=232496ED)](https://hub.docker.com/repository/docker/usdotfhwastol/carma-base) | [![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/usdotfhwastolcandidate/carma-base?label=Docker%20Build&logo=232496ED)](https://hub.docker.com/repository/docker/usdotfhwastolcandidate/carma-base) | [![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/usdotfhwastoldev/carma-base?label=Docker%20Build&logo=232496ED)](https://hub.docker.com/repository/docker/usdotfhwastoldev/carma-base) + + +# CARMABase Humble +CARMA Base Humble is the Docker base image for Dockerized releases and deployments of the CARMA Platform. All CARMA images should inherit from this and any dependencies of those images should be instaled in this base image to minimize system build time and final image size. + +# CARMAPlatform +The primary CARMAPlatform repository can be found [here](https://github.com/usdot-fhwa-stol/carma-platform) and is part of the [USDOT FHWA STOL](https://github.com/usdot-fhwa-stol/) +github organization. Documentation on how the CARMAPlatform functions, how it will evolve over time, and how you can contribute can be found at the above links as well + +## Contribution +Welcome to the CARMA contributing guide. Please read this guide to learn about our development process, how to propose pull requests and improvements, and how to build and test your changes to this project. [CARMA Contributing Guide](https://github.com/usdot-fhwa-stol/carma-platform/blob/develop/Contributing.md) + +## Code of Conduct +Please read our [CARMA Code of Conduct](https://github.com/usdot-fhwa-stol/carma-platform/blob/develop/Code_of_Conduct.md) which outlines our expectations for participants within the CARMA community, as well as steps to reporting unacceptable behavior. We are committed to providing a welcoming and inspiring community for all and expect our code of conduct to be honored. Anyone who violates this code of conduct may be banned from the community. + +## Attribution +The development team would like to acknowledge the people who have made direct contributions to the design and code in this repository. [CARMA Attribution](https://github.com/usdot-fhwa-stol/carma-platform/blob/develop/ATTRIBUTION.txt) + +## License +By contributing to the Federal Highway Administration (FHWA) Connected Automated Research Mobility Applications (CARMA), you agree that your contributions will be licensed under its Apache License 2.0 license. [CARMA License](https://github.com/usdot-fhwa-stol/carma-platform/blob/develop/docs/License.md) + +## Contact +Please click on the CARMA logo below to visit the Federal Highway Adminstration(FHWA) CARMA website. + +[![CARMA Image](https://raw.githubusercontent.com/usdot-fhwa-stol/carma-platform/develop/docs/image/CARMA_icon.png)](https://highways.dot.gov/research/research-programs/operations/CARMA) diff --git a/jammy/additional_packages.txt b/jammy/additional_packages.txt new file mode 100644 index 0000000..43af0ff --- /dev/null +++ b/jammy/additional_packages.txt @@ -0,0 +1,25 @@ +locales +openssl +git +jq +libboost-python-dev +libfftw3-dev +libgeographic-dev +libgmock-dev +libnl-genl-3-dev +libopenblas-dev +libpcap-dev +libpugixml-dev +lttng-tools +mesa-utils +nano +nodejs +software-properties-common +sqlite3 +ssh +sudo +tmux +unzip +vim +wait-for-it +x-window-system \ No newline at end of file diff --git a/jammy/init-env.sh b/jammy/init-env.sh new file mode 100644 index 0000000..b5fc734 --- /dev/null +++ b/jammy/init-env.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# Copyright (C) 2018-2024 LEIDOS. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +# Sets all environment variables and sources scripts necessary for CARMA to operate + +export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/ + +# Export QT X11 Forwarding variables +export QT_X11_NO_MITSHM=1 + +# Set Cyclone DDS as default RMW implementation +export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp + +# Add scanner and wrapper to PATH +export PATH=$PATH:/opt/sonarqube/sonar-scanner/bin/:/opt/sonarqube/build-wrapper/ + +# Add code_coverage script folder to path for gcovr +export PATH=$PATH:/home/carma/.ci-image/engineering_tools/code_coverage/ + +# Add CUDA paths +export CUDA_HOME=/usr/local/cuda +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_HOME/lib64 +export PATH=$PATH:$CUDA_HOME/bin + +# Source ROS2 Humble setup +if [ -f "/opt/ros/humble/setup.bash" ]; then + source /opt/ros/humble/setup.bash +fi + +# Source CARMA setup if available +if [ -f "/opt/carma/install/setup.bash" ]; then + source /opt/carma/install/setup.bash +fi + +# Always source environment variables as last step +if [ -f "/opt/carma/vehicle/config/carma.env" ]; then + source /opt/carma/vehicle/config/carma.env +fi \ No newline at end of file diff --git a/jammy/package.xml b/jammy/package.xml new file mode 100644 index 0000000..9b25b30 --- /dev/null +++ b/jammy/package.xml @@ -0,0 +1,50 @@ + + + + carma_base + 5.0.0 + A metapackage to install the dependencies for CARMA + carma + Apache 2.0 + + ament_cmake + + + ackermann_msgs + automotive_platform_msgs + builtin_interfaces + camera_info_manager + can_msgs + cv_bridge + diagnostic_msgs + diagnostic_updater + geometry_msgs + image_transport + nav_msgs + nmea_msgs + pcl_conversions + rclcpp + rclpy + rosidl_default_generators + sensor_msgs + std_msgs + std_srvs + tf2 + tf2_geometry_msgs + tf2_ros + visualization_msgs + + + boost + eigen + libopencv-dev + libpcl-all-dev + yaml-cpp + + ament_lint_auto + ament_lint_common + + + ament_cmake + + \ No newline at end of file diff --git a/jammy/ros_packages.txt b/jammy/ros_packages.txt new file mode 100644 index 0000000..29a5411 --- /dev/null +++ b/jammy/ros_packages.txt @@ -0,0 +1,30 @@ +python3-colcon-common-extensions +ros-humble-desktop +ros-humble-rmw-cyclonedds-cpp +ros-humble-pcl-ros +ros-humble-test-msgs +ros-humble-nmea-msgs +ros-humble-gps-tools +ros-humble-rosbag2-storage-mcap +ros-humble-acado-vendor +ros-humble-ament-cmake-google-benchmark +ros-humble-apex-test-tools +ros-humble-automotive-platform-msgs +ros-humble-diagnostic-updater +ros-humble-gps-msgs +ros-humble-joy-linux +ros-humble-lgsvl-msgs +ros-humble-osqp-vendor +ros-humble-osrf-testing-tools-cpp +ros-humble-point-cloud-msg-wrapper +ros-humble-ros-testing +ros-humble-rosapi +ros-humble-rosapi-msgs +ros-humble-rosbridge-library +ros-humble-rosbridge-msgs +ros-humble-rosbridge-server +ros-humble-tvm-vendor +ros-humble-udp-driver +ros-humble-udp-msgs +ros-humble-velodyne-pointcloud +ros-humble-yaml-cpp-vendor \ No newline at end of file