Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 27 additions & 83 deletions .devcontainer/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

FROM docker.io/library/ubuntu:24.04@sha256:2e863c44b718727c860746568e1d54afd13b2fa71b160f5cd9058fc436217b30 as build
FROM docker.io/library/ubuntu:24.04@sha256:2e863c44b718727c860746568e1d54afd13b2fa71b160f5cd9058fc436217b30 as base

# Install dependencies
RUN DEBIAN_FRONTEND="noninteractive" apt-get update && \
Expand All @@ -28,101 +28,45 @@ RUN DEBIAN_FRONTEND="noninteractive" apt-get update && \
make \
zip \
ninja-build \
clang-tidy \
lcov \
sudo \
python3 \
pipx && \
apt-get clean

#python3-pip && \

# Build image using conan & cmake
FROM build as conan-build

# Install conan
#RUN pip3 install conan && pip3 cache purge
##RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
# python3-conan && \
# apt-get clean
ENV PATH="${PATH}:/root/.local/bin"
RUN pipx install conan

# Setup conan profile for root
COPY conan-container-default-profile /root/.conan2/profiles/default
COPY conan-container-debug-profile /root/.conan2/profiles/debug

# Build image using apt dependencies
FROM build as apt-build
FROM base as conan-build

# Install celix dependencies (note git needed for cloning gtest)
RUN DEBIAN_FRONTEND="noninteractive" sudo apt-get update && \
DEBIAN_FRONTEND="noninteractive" sudo apt-get install -y --no-install-recommends \
git \
civetweb \
libavahi-compat-libdnssd-dev \
libcivetweb-dev \
libcpputest-dev \
libcurl4-openssl-dev \
libczmq-dev \
libffi-dev \
libjansson-dev \
libxml2-dev \
libzip-dev \
libuv1-dev \
rapidjson-dev \
uuid-dev && \
sudo apt-get clean
ARG USERNAME=celixdev
ARG USER_UID=1000
ARG USER_GID=1000

#Note from build not conan-build, because conan-dev uses a celixdev user
FROM build as conan-dev

# Remove ubuntu user and add celixdev with sudo rights and a "celixdev" password
RUN userdel -r ubuntu && \
groupadd --gid 1000 celixdev && \
useradd --uid 1000 --gid 1000 -m \
-s /bin/bash -G sudo celixdev && \
echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
echo "celixdev:celixdev" | chpasswd
USER celixdev
WORKDIR /home/celixdev

#Create workdir, used in vscode
#RUN sudo mkdir -p /workspaces/celix/build && sudo chown -R celixdev:celixdev /workspaces
groupadd --gid ${USER_GID} ${USERNAME} && \
useradd --uid ${USER_UID} --gid ${USER_GID} --create-home --shell /bin/bash ${USERNAME} && \
usermod -aG sudo ${USERNAME} && \
echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

# Setup python venv for celixdev and install conan
ENV PATH="${PATH}:/home/celixdev/.local/bin"
RUN pipx install conan
USER ${USERNAME}
WORKDIR /home/${USERNAME}

# Setup conan profile for celixdev
COPY --chown=celixdev:celixdev conan-container-default-profile /home/celixdev/.conan2/profiles/default
COPY --chown=celixdev:celixdev conan-container-debug-profile /home/celixdev/.conan2/profiles/debug
ENV PATH="${PATH}:/home/${USERNAME}/.local/bin"
RUN pipx install conan && \
conan profile detect --force && \
cp /home/${USERNAME}/.conan2/profiles/default /home/${USERNAME}/.conan2/profiles/release && \
cp /home/${USERNAME}/.conan2/profiles/default /home/${USERNAME}/.conan2/profiles/debug && \
sed -i 's/^build_type=.*/build_type=Release/' /home/${USERNAME}/.conan2/profiles/release && \
sed -i 's/^build_type=.*/build_type=Debug/' /home/${USERNAME}/.conan2/profiles/debug

#Install development dependencies
RUN sudo DEBIAN_FRONTEND="noninteractive" apt-get update && \
sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
gnupg2 dos2unix git locales-all rsync tar ssh tzdata sudo vim openssh-server cmake-curses-gui gdb \
wget curl && \
sudo apt-get clean
FROM conan-build as conan-dev

RUN sudo mkdir /run/sshd

FROM apt-build as apt-dev

# Remove ubuntu user and add celixdev with sudo rights and a "celixdev" password
RUN userdel -r ubuntu && \
groupadd --gid 1000 celixdev && \
useradd --uid 1000 --gid 1000 -m \
-s /bin/bash -G sudo celixdev && \
echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
echo "celixdev:celixdev" | chpasswd
USER celixdev
WORKDIR /home/celixdev

#Install development dependencies
RUN sudo DEBIAN_FRONTEND="noninteractive" apt-get update && \
sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
gnupg2 dos2unix git locales-all rsync tar ssh tzdata sudo vim openssh-server cmake-curses-gui gdb \
USER root
RUN DEBIAN_FRONTEND="noninteractive" apt-get update && \
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
gnupg2 dos2unix locales-all ssh rsync tar tzdata sudo vim cmake-curses-gui gdb \
wget curl && \
sudo apt-get clean
apt-get clean \

RUN sudo mkdir /run/sshd
USER ${USERNAME}
WORKDIR /home/${USERNAME}
89 changes: 64 additions & 25 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,49 +21,88 @@ limitations under the License.

This directory contains a [DevContainer](https://containers.dev) setup for developing Apache Celix inside a container.

Although Apache Celix can be built using CMake with APT-installed dependencies or Conan with Conan-installed/built
dependencies, this DevContainer setup currently only supports Conan.
Although Apache Celix can be built using CMake with APT-installed dependencies or Conan
with Conan-installed/built dependencies, this DevContainer setup is based on Conan.

Please note, the DevContainer setup is not broadly tested and might not work on all systems.
It has been tested on Ubuntu 23.10 and Fedora 40.
It has been tested on MacOS 26 and Fedora 43, using podman.

## Mounts

The devcontainer uses the following container volumes to ensure dependency build and project
building is more efficient, even after recreating a devcontainer:

- celixdev-conan-package-cache
- celixdev-conan-download-cache
- celixdev-ccache-cache

Use `podman volume rm` / `docker volume rm` to remove the volumes if you do no longer use them.

## VSCode Usage

VSCode has built-in support for DevContainers.
Simply launch VSCode using the Celix workspace folder, and you will be prompted to open the workspace in a container.
Launch VSCode using the Celix workspace folder, and you will be prompted to
open the workspace in a container.

VSCode ensures that your host `.gitconfig` file, `.gnupg` directory, and SSH agent forwarding are available in the
container.
VSCode ensures that your host `.gitconfig` file and SSH agent forwarding
are available in the container.

## CLion Usage

At the time of writing this readme, CLion does not fully support DevContainers,
but there is some support focusing on Docker. Using a container and remote development via SSH with CLion works.
CLion 2025.3.1 includes DevContainer support (including Podman), so you can open this repository directly
using the IDE's DevContainer workflow. Once the container is built, enable and select the conan-debug (generated)
profile.

When running "All CTests" from the CLion UI (2025.3.2), ensure that the correct ctest args are used:
- ALT-SHIFT-F10 (`Run...`)
- Hover `All CTests`
- Click `Edit...`
- Configure CTest arguments to: `--preset conan-debug --extra-verbose -j1`
- Configure working directory to: `$ProjectFileDir$`

To start developing in a container with build a CevContainer image using the `build-devcontainer-image.sh` script
and then start a container with SSHD running and interactively set up `.gitconfig`, `.gnupg`, and SSH agent
forwarding, using the `.devcontainer/run-dev-container.sh` script:
When running gtests from the CLion UI (2025.3.2) directly from gtest sources, ensure that the environment is
correctly configured:
- Click "play" button next to the line numbers
- Click `Modify Run Configuration...`
- Click `Edit environment variables` (file icon in the `Environment variables` textfield)
- Click `Browse` from "Load variables from file"
- Browse to `build/Debug/generators/conanrun.sh`
- Click `OK`, Click `Apply`, Click `Ok`

```bash
cd ${CELIX_ROOT}
./.devcontainer/build-devcontainer-image.sh
./.devcontainer/run-devcontainer.sh
ssh -p 2233 celixdev@localhost
## Conan Install

Run conan install to install required dependencies and tools and generate the needed cmake configuration files

```shell
conan install . --build missing --profile ${CONAN_PROFILE} ${CONAN_OPTS} ${CONAN_CONF}
```

In CLion, open the Remote Development window by navigating to "File -> Remote Development..." and add a new
configuration. When a new configuration is added, you can start a new project using `/home/celixdev/workspace` as the
project root and selecting CLion as the IDE.
Note: `CONAN_PROFILE`, `CONAN_OPTS` and `CONAN_CONF` are environments variables in the dev container.

Also ensure the CMake profile from the - conan generated - `CMakeUserPresets.json` is used: Enable the profile in the
Settings -> "Build, Execution, Deployment" -> CMake menu.
## CMake Configure

CMake configure can be done from the root workspace dir:

```shell
cmake --preset conan-debug
```

## Building

Build can be done from the root workspace dir:

```shell
cmake --build build/Debug --parallel
```

## Running tests

Tests can be run using ctest.
When building with conan, the conanrun.sh script will setup the environment for the
built dependencies. To run the tests, execute the following commands:
When building with Conan, run tests from the build directory after configuring/building:

```shell
cd build
ctest --output-on-failure --test-command ./workspaces/celix/build/conanrun.sh
ctest --preset conan-debug --output-on-failure -j1
```

Note `-j1` is needed to prevent ctest from running tests parallel; running tests in parallel is currently not supported
in Apache Celix.
33 changes: 0 additions & 33 deletions .devcontainer/build-devcontainer-image.sh

This file was deleted.

24 changes: 0 additions & 24 deletions .devcontainer/build-project-with-conan.sh

This file was deleted.

26 changes: 0 additions & 26 deletions .devcontainer/conan-container-debug-profile

This file was deleted.

26 changes: 0 additions & 26 deletions .devcontainer/conan-container-default-profile

This file was deleted.

Loading
Loading