Skip to content

Commit

Permalink
build: update dockerfiles (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
domire8 authored Mar 1, 2024
1 parent 8845c25 commit f44ed2f
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 27 deletions.
13 changes: 4 additions & 9 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
Expand Down
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
source/*build*
./build*
./docs/
./.*
2 changes: 1 addition & 1 deletion .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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"
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
63 changes: 55 additions & 8 deletions Dockerfile.ci → Dockerfile
Original file line number Diff line number Diff line change
@@ -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] /
Expand All @@ -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:
# ```
Expand Down Expand Up @@ -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
Expand All @@ -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`
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 \
<<HEREDOC
for PKG in state_representation dynamical_systems robot_model controllers clproto; do
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.3.2
7.3.3
2 changes: 1 addition & 1 deletion demos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(control_libraries 7.3.2 CONFIG REQUIRED)
find_package(control_libraries 7.3.3 CONFIG REQUIRED)

set(DEMOS_SCRIPTS
task_space_control_loop
Expand Down
8 changes: 7 additions & 1 deletion docker/sshd_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ while [ "$#" -gt 0 ]; do
esac
done

# define the home directory of the specified user
HOME="/home/${USERNAME}"

# update the USER_ID and GROUP_ID of the specified user
if [ -n "${USER_ID}" ] && [ -n "${GROUP_ID}" ]; then
groupmod -g "${GROUP_ID}" "${USERNAME}"
Expand All @@ -38,12 +41,15 @@ fi

if [ -n "${PUBLIC_KEY}" ]; then
# authorise the specified user for ssh login
HOME="/home/${USERNAME}"
mkdir -p "${HOME}"/.ssh
echo "${PUBLIC_KEY}" >"${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
2 changes: 1 addition & 1 deletion doxygen/doxygen.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion protocol/clproto_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down
2 changes: 1 addition & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit f44ed2f

Please sign in to comment.