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 1 commit
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
45 changes: 33 additions & 12 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:22.04@sha256:b492494d8e0113c4ad3fe4528a4b5ff89faa5331f7d52c5c138196f69ce176a6 as build
FROM docker.io/library/ubuntu:24.04@sha256:2e863c44b718727c860746568e1d54afd13b2fa71b160f5cd9058fc436217b30 as build

# Install dependencies
RUN DEBIAN_FRONTEND="noninteractive" apt-get update && \
Expand All @@ -31,18 +31,25 @@ RUN DEBIAN_FRONTEND="noninteractive" apt-get update && \
lcov \
sudo \
python3 \
python3-pip && \
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 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 .devcontainer/conan-container-default-profile /root/.conan2/profiles/default
COPY .devcontainer/conan-container-debug-profile /root/.conan2/profiles/debug
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
Expand All @@ -65,18 +72,29 @@ RUN DEBIAN_FRONTEND="noninteractive" sudo apt-get update && \
uuid-dev && \
sudo apt-get clean

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

# Add user celixdev with sudo rights and a "celixdev" password
RUN useradd -m -s /bin/bash -G sudo celixdev && \
# 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 .devcontainer/conan-container-default-profile /home/celixdev/.conan2/profiles/default
COPY .devcontainer/conan-container-debug-profile /home/celixdev/.conan2/profiles/debug
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 && \
Expand All @@ -88,8 +106,11 @@ RUN sudo mkdir /run/sshd

FROM apt-build as apt-dev

# Add user celixdev with sudo rights and a "celixdev" password
RUN useradd -m -s /bin/bash -G sudo celixdev && \
# 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
Expand Down
11 changes: 10 additions & 1 deletion .devcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,13 @@ 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.
selecting CLion as the IDE.

## Running tests
Tests can be runned 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
```
8 changes: 5 additions & 3 deletions .devcontainer/build-project-with-conan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# specific language governing permissions and limitations
# under the License.

conan build . --build missing --options build_all=True --options enable_address_sanitizer=True \
--options enable_testing=True --options enable_ccache=True --output-folder build \
--conf tools.cmake.cmaketoolchain:generator=Ninja --settings build_type=Debug
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
4 changes: 2 additions & 2 deletions .devcontainer/conan-container-debug-profile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
# specific language governing permissions and limitations
# under the License.

#Based on gcc from ubuntu:22.04 base image
#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=11
compiler.version=13
os=Linux
4 changes: 2 additions & 2 deletions .devcontainer/conan-container-default-profile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
# specific language governing permissions and limitations
# under the License.

#Based on gcc from ubuntu:22.04 base image
#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=11
compiler.version=13
os=Linux
2 changes: 2 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"runArgs" : [
"--userns=keep-id"
],
"remoteUser": "celixdev",
"containerUser": "celixdev",
"onCreateCommand": "sh .devcontainer/setup-project-with-conan.sh",
"postCreateCommand": "sh .devcontainer/build-project-with-conan.sh"
}
10 changes: 7 additions & 3 deletions .devcontainer/setup-project-with-conan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
# specific language governing permissions and limitations
# under the License.

conan install . --build missing --options build_all=True --options enable_address_sanitizer=True \
--options enable_testing=True --options enable_ccache=True --output-folder build \
--conf tools.cmake.cmaketoolchain:generator=Ninja --settings build_type=Debug
mkdir build

conan install . --build missing --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
14 changes: 8 additions & 6 deletions .github/workflows/containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ jobs:
restore-keys: cache-ccache-container-${{ runner.os }}-${{ github.job }}-
- name: Build container image
run: |
docker build --tag apache/celix-conan-build:latest --target conan-build --file .devcontainer/Containerfile .
cd .devcontainer && \
docker build --tag apache/celix-conan-build:latest --target conan-build --file Containerfile .
- name: Build Celix dependencies
run: | #Using .conan2-container so that the steps can be reproduced locally without affecting the host conan
mkdir -p ~/.conan2-container/profiles && \
Expand Down Expand Up @@ -55,8 +56,7 @@ jobs:
docker run --rm -v ~/.conan2-container:/root/.conan2 -v $(pwd):/workspace \
apache/celix-conan-build:latest /bin/bash -c \
"cd /workspace/build && \
source conanrun.sh && \
ctest --output-on-failure -E unit_test_discovery_zeroconf"
ctest --output-on-failure --test-command ./workspaces/celix/build/conanrun.sh"

container-apt-build-ubuntu:
runs-on: ubuntu-22.04
Expand All @@ -66,7 +66,8 @@ jobs:
uses: actions/checkout@v3.3.0
- name: Build container image
run: |
docker build --tag apache/celix-apt-build:latest --target apt-build --file .devcontainer/Containerfile .
cd .devcontainer && \
docker build --tag apache/celix-apt-build:latest --target apt-build --file Containerfile .
- name: Cache ccache
uses: actions/cache@v3
with:
Expand Down Expand Up @@ -95,5 +96,6 @@ jobs:
uses: actions/checkout@v3.3.0
- name: Build dev container images
run: |
docker build --tag apache/celix-conan-dev:latest --target conan-dev --file .devcontainer/Containerfile .
docker build --tag apache/celix-apt-dev:latest --target apt-dev --file .devcontainer/Containerfile .
cd .devcontainer && \
docker build --tag apache/celix-conan-dev:latest --target conan-dev --file Containerfile . && \
docker build --tag apache/celix-apt-dev:latest --target apt-dev --file Containerfile .
1 change: 1 addition & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ def requirements(self):
or self.options.build_rsa_discovery_common or self.options.build_rsa_remote_service_admin_dfi
or self.options.build_launcher):
self.requires("libcurl/[>=8.4.0 <9.0.0]")
self.requires("openssl/[>=3.2.0]")
PengZheng marked this conversation as resolved.
Show resolved Hide resolved
if (self.options.build_rsa_discovery_common
or (self.options.build_rsa_remote_service_admin_dfi and self.options.enable_testing)):
self.requires("libxml2/[>=2.9.9 <3.0.0]")
Expand Down
Loading