diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8d4e0cb10..81793e293 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,22 +1,17 @@ { "name": "control libraries", - "remoteUser": "ros2", + "remoteUser": "developer", "build": { - "dockerfile": "../Dockerfile.ci", + "dockerfile": "../Dockerfile", "context": "..", - "target": "development", - "args": { - "ROS2_VERSION": "humble", - "PINOCCHIO_TESTS": "OFF" - } + "target": "development" }, "workspaceMount": "source=${localWorkspaceFolder},target=/src,type=bind,consistency=cached", "workspaceFolder": "/src", "customizations": { "vscode": { "extensions": [ - "ms-vscode.cpptools-extension-pack", - "eamodio.gitlens" + "ms-vscode.cpptools-extension-pack" ] } } diff --git a/.dockerignore b/.dockerignore index 5b0a757fe..0987a4a44 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,3 @@ -source/*build* \ No newline at end of file +./build* +./docs/ +./.* \ No newline at end of file diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml index b300730bf..95ec0513f 100644 --- a/.github/workflows/build-release.yaml +++ b/.github/workflows/build-release.yaml @@ -46,7 +46,7 @@ jobs: with: image_name: aica-technology/control-libraries image_tags: ${{ steps.merge-tags.outputs.list }} - dockerfile_path: Dockerfile.ci + dockerfile_path: Dockerfile token: ${{ secrets.GITHUB_TOKEN }} multi-arch: diff --git a/.vscode/settings.json b/.vscode/settings.json index 8ca221a0c..056d439bc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { "cmake.sourceDirectory": "/src/source", "cmake.configureArgs": [ "-DBUILD_TESTING=ON" ], - "C_Cpp.clang_format_style": "file:/home/ros2/.clang-format" + "C_Cpp.clang_format_style": "file:/guidelines/.clang-format" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index b9a56f8ad..70c669383 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Release Versions: ## Upcoming changes (in development) +- build: update dockerfiles (#153) - build: copy python packages into /usr instead of ~ros2 to avoid permission issues (#155) - feat: Add ParameterType conversion functions to go from enum to type label and the inverse (#154) diff --git a/Dockerfile.ci b/Dockerfile similarity index 79% rename from Dockerfile.ci rename to Dockerfile index 331e8577d..566edfc87 100644 --- a/Dockerfile.ci +++ b/Dockerfile @@ -1,6 +1,23 @@ -ARG ROS2_VERSION=humble -FROM ghcr.io/aica-technology/ros2-ws:${ROS2_VERSION} as base -USER ${USER} +ARG BASE_TAG=22.04 +FROM ubuntu:${BASE_TAG} as base +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y \ + cmake \ + g++ \ + git \ + libgtest-dev \ + libeigen3-dev \ + python3-pip \ + ssh \ + sudo \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN echo "Set disable_coredump false" >> /etc/sudo.conf + +# create the credentials to be able to pull private repos using ssh +RUN mkdir /root/.ssh/ && ssh-keyscan github.com | tee -a /root/.ssh/known_hosts FROM base as apt-dependencies COPY apt-packages.tx[t] / @@ -13,7 +30,7 @@ fi mkdir -p /tmp/apt -sudo apt-get update +apt-get update # We then do a dry-run and parse the output of apt to gather the list of packages to be installed # Example output: # ``` @@ -44,7 +61,7 @@ xargs -a /apt-packages.txt apt-get install --dry-run \ | grep -e '^Inst ' \ | sed -E 's/^Inst (\S+) .*$/\1/' > /tmp/new-packages.txt # Then we install apt packages like normal -xargs -a /apt-packages.txt sudo apt-get install -y +xargs -a /apt-packages.txt apt-get install -y # Finally we use dpkg to get all files installed by those packages and copy them to a new root # - get list of files installed by all the packages # - remove empty lines @@ -64,7 +81,7 @@ COPY --from=apt-dependencies /tmp/apt / ARG TARGETPLATFORM ARG CACHEID ARG PINOCCHIO_TAG=v2.6.9 -ARG PINOCCHIO_TESTS=ON +ARG PINOCCHIO_TESTS=OFF # FIXME: it would be nicer to have it all in the root CMakelists.txt but: # * `pinocchio` doesn't provide an include directory we can easily plug into `target_include_directories` and thus needs to be installed first # * `pinocchio` uses hacks relying on undocumented CMake quirks which break if you use `FetchContent` @@ -101,9 +118,39 @@ FROM base as code WORKDIR /src COPY --from=apt-dependencies /tmp/apt / COPY --from=dependencies /tmp/deps /usr -COPY --chown=${USER}:${USER} . /src +COPY . /src FROM code as development +# create and configure a new user +ARG UID=1000 +ARG GID=1000 +ENV USER developer +ENV HOME /home/${USER} + +RUN addgroup --gid ${GID} ${USER} +RUN adduser --gecos "Remote 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 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 + +# 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 ./docker/sshd_entrypoint.sh /sshd_entrypoint.sh +RUN chmod 744 /sshd_entrypoint.sh + +RUN chown -R ${USER}:${USER} /src +RUN mkdir /guidelines && cd /guidelines \ + && wget https://raw.githubusercontent.com/aica-technology/.github/v0.9.0/guidelines/.clang-format + +USER ${USER} FROM code as build ARG TARGETPLATFORM @@ -141,7 +188,7 @@ COPY --from=apt-dependencies /tmp/apt / COPY --from=dependencies /tmp/deps /usr COPY --from=install /tmp/cl /usr COPY --from=python /tmp/python-usr /usr -RUN sudo pip install pybind11-stubgen +RUN pip install pybind11-stubgen RUN --mount=type=cache,target=${HOME}/.cache,id=pip-${TARGETPLATFORM}-${CACHEID},uid=1000 \ <"${HOME}"/.ssh/authorized_keys chmod -R 755 "${HOME}"/.ssh chown -R "${USERNAME}:${USERNAME}" "${HOME}"/.ssh fi +# save all environment variables to a file (except those listed below) and source it when the specified user logs in +env | egrep -v "^(HOME=|USER=|MAIL=|LC_ALL=|LS_COLORS=|LANG=|HOSTNAME=|PWD=|TERM=|SHLVL=|LANGUAGE=|_=)" >> /etc/environment +echo "source /etc/environment" | cat - "${HOME}/.bashrc" > tmp && mv tmp "${HOME}/.bashrc" + # start the ssh server /usr/sbin/sshd -D -e -f /etc/ssh/sshd_config_development diff --git a/doxygen/doxygen.conf b/doxygen/doxygen.conf index 4e344be5f..0d4442e51 100644 --- a/doxygen/doxygen.conf +++ b/doxygen/doxygen.conf @@ -38,7 +38,7 @@ PROJECT_NAME = "Control Libraries" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 7.3.2 +PROJECT_NUMBER = 7.3.3 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/protocol/clproto_cpp/CMakeLists.txt b/protocol/clproto_cpp/CMakeLists.txt index ccc07d73f..f23343ae0 100644 --- a/protocol/clproto_cpp/CMakeLists.txt +++ b/protocol/clproto_cpp/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.15) -project(clproto VERSION 7.3.2) +project(clproto VERSION 7.3.3) # Default to C99 if(NOT CMAKE_C_STANDARD) diff --git a/python/setup.py b/python/setup.py index 66cf7a7e4..da1cf096b 100644 --- a/python/setup.py +++ b/python/setup.py @@ -11,7 +11,7 @@ # names of the environment variables that define osqp and openrobots include directories osqp_path_var = 'OSQP_INCLUDE_DIR' -__version__ = "7.3.2" +__version__ = "7.3.3" __libraries__ = ['state_representation', 'clproto', 'controllers', 'dynamical_systems', 'robot_model'] __include_dirs__ = ['include'] diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 6263d8a9d..183263a70 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.15) -project(control_libraries VERSION 7.3.2) +project(control_libraries VERSION 7.3.3) # Build options option(BUILD_TESTING "Build all tests." OFF)