Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/devcontainer #731

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
eb38591
Add initial setup for devcontainer
pnoltes Feb 18, 2024
74450e1
Fix trailing commas in devcontainer.json
pnoltes Feb 18, 2024
9310ddc
Add devcontainer badge in README.md
pnoltes Feb 19, 2024
dc8afe8
Update .devcontainer/devcontainer.json
pnoltes Apr 16, 2024
b15249f
Merge branch 'refs/heads/master' into feature/devcontainer
pnoltes Jun 9, 2024
6f45fb6
Refactor devcontainer setup for building with conan
pnoltes Jun 9, 2024
3ceb3c5
Refactor Containerfile to build and dev with non root user
pnoltes Jun 10, 2024
70922c9
Update devcontainer setup for gpg
pnoltes Jun 11, 2024
247744a
Improve run container scripting and add initial readme
pnoltes Jun 11, 2024
d28280e
Combine container build ci with devcontainer setup
pnoltes Jun 15, 2024
9dea26d
Fix apt container ci build configuration
pnoltes Jun 15, 2024
8bc3f59
Update docker build command
pnoltes Jun 16, 2024
8e5ff23
Move celixdev user to dev images
pnoltes Jun 16, 2024
de8b49a
Split container install, build & test in multiple steps
pnoltes Jun 16, 2024
ada1c88
Add conan.lock file to lock dependencies when using conan
pnoltes Jun 16, 2024
8f678b5
Add conan cache action for ci container build using conan.lock
pnoltes Jun 16, 2024
e5a0640
Revert introduction conan.lock
pnoltes Jun 16, 2024
d2779cc
Update Containerfile and conan cache setup
pnoltes Jun 18, 2024
aa947f4
Add additional cache mechanisms for container ci builds
pnoltes Jun 18, 2024
fa845b9
Remove disallowed docker cache action
pnoltes Jun 18, 2024
e69a3e2
Update devcontainer to ubuntu 24.04 and fix openssl issue
pnoltes Jun 23, 2024
6606e77
Replace usage of tags for github action to hashes
pnoltes Jun 23, 2024
d1ba2bf
Avoid the introduction of openssl dependency.
PengZheng Jun 24, 2024
d20f2b4
Remove openssl 1.1.1 override for Conan build on Ubuntu.
PengZheng Jun 24, 2024
a779cbf
Fix wrong conanrun.sh path.
PengZheng Jun 24, 2024
d4d41ce
Merge branch 'master' into feature/devcontainer
PengZheng Jun 24, 2024
1e77207
Fix ctest warning.
PengZheng Jun 24, 2024
14398f4
Fix ctest dynamic linking error.
PengZheng Jun 24, 2024
52001cb
Fix conan option format.
PengZheng Jun 24, 2024
50e1193
Update to macOS-12.
PengZheng Jun 24, 2024
d3b1e15
Enable address sanitizer in test_package.
PengZheng Jun 24, 2024
95a34d8
Remove sudo in run_unit_test_discovery_zeroconf.
PengZheng Jun 24, 2024
00dc17a
Fix test_package error.
PengZheng Jun 24, 2024
2206733
Merge branch 'master' into feature/devcontainer
PengZheng Jun 24, 2024
ae2243a
Use sudo to start mdnsd in discovery_zeroconf unit test
xuzhenbao Jun 24, 2024
02a82bf
Resolve unit test failed for discovery_zeroconf
xuzhenbao Jun 24, 2024
f9c22aa
Add securityOpts config for devcontainer.json
pnoltes Jul 7, 2024
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
127 changes: 127 additions & 0 deletions .devcontainer/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

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

# Install dependencies
RUN DEBIAN_FRONTEND="noninteractive" apt-get update && \
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
build-essential \
ccache \
cmake \
gcc \
g++ \
make \
zip \
ninja-build \
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

# 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 \
rapidjson-dev \
uuid-dev && \
sudo apt-get clean

#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

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

# 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

#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

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 \
wget curl && \
sudo apt-get clean

RUN sudo mkdir /run/sshd
66 changes: 66 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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.
-->

# Apache Celix Development Container

## Introduction

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

While Apache Celix can be built using CMake with APT-installed dependencies or using Conan with Conan-installed/built
dependencies, this DevContainer setup currently only supports building Celix using 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.

## VSCode Usage

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

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

## CLion Usage

CLion does not have built-in support for DevContainers and is not fully supported at this time.
Instead, you can use remote development via SSH with CLion.

To start a container with SSHD running and interactively set up `.gitconfig`, `.gnupg`, and SSH agent forwarding, use
the `.devcontainer/run-dev-container.sh` script.
Before using this script, you must build a `celix-conan-dev` image.

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

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.

## 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:

```shell
cd build
ctest --output-on-failure --test-command ./workspaces/celix/build/conanrun.sh
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# Build a Celix dev container with all needed dependencies pre-installed.

SCRIPT_LOCATION=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
CELIX_REPO_ROOT=$(realpath "${SCRIPT_LOCATION}/..")
IMAGE_TARGET="${1:-conan-dev}"

# Check which container engine is available.
# Check for podman first, because the 'podman-docker' package might be installed providing a dummy 'docker' command.
Expand All @@ -31,4 +30,4 @@ else
fi

cd "${SCRIPT_LOCATION}"
${CONTAINER_ENGINE} build -t apache/celix-dev:ubuntu-latest -f Containerfile.ubuntu .
${CONTAINER_ENGINE} build -t apache/celix-${IMAGE_TARGET} -f Containerfile --target ${IMAGE_TARGET} .
24 changes: 24 additions & 0 deletions .devcontainer/build-project-with-conan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

conan build . --profile debug \
--options celix/*:build_all=True --options celix/*:enable_address_sanitizer=True \
--options celix/*:enable_testing=True --options celix/*:enable_ccache=True \
--conf:build tools.cmake.cmaketoolchain:generator=Ninja \
--output-folder build
25 changes: 11 additions & 14 deletions container/support-scripts/build-all.sh → .devcontainer/conan-container-debug-profile
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

BUILD_TYPE=${1:-Debug}

cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=../celix-install \
-DBUILD_EXPERIMENTAL=ON \
-DENABLE_TESTING=ON \
-DRSA_JSON_RPC=ON \
-DRSA_SHM=ON \
-DRSA_REMOTE_SERVICE_ADMIN_SHM_V2=ON \
..
#Based on gcc from ubuntu:24.04 base image
[settings]
arch=x86_64
build_type=Debug
compiler=gcc
compiler.cppstd=17
compiler.libcxx=libstdc++11
compiler.version=13
os=Linux
26 changes: 26 additions & 0 deletions .devcontainer/conan-container-default-profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

#Based on gcc from ubuntu:24.04 base image
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=17
compiler.libcxx=libstdc++11
compiler.version=13
os=Linux
15 changes: 15 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Apache Celix Dev Container",
"build": {
"dockerfile": "Containerfile",
"target": "conan-dev"
},
"runArgs" : [
"--userns=keep-id"
],
"securityOpt":["label=disable"],
"remoteUser": "celixdev",
"containerUser": "celixdev",
"onCreateCommand": "sh .devcontainer/setup-project-with-conan.sh",
"postCreateCommand": "sh .devcontainer/build-project-with-conan.sh"
}
Loading
Loading