-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #656 from apache/feature/add-dev-container
Add dev container with Celix dependencies
- Loading branch information
Showing
9 changed files
with
331 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
|
||
/.project | ||
.DS_Store | ||
.clion.source.upload.marker | ||
.idea | ||
.vscode | ||
*.iml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
# 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. | ||
|
||
tasks: | ||
- init: | | ||
mkdir -p cmake-build-debug-gitpod | ||
cd cmake-build-debug-gitpod && ../container/support-scripts/build-all.sh && make -j | ||
image: | ||
file: container/Containerfile.gitpod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# 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. | ||
|
||
# SSH credentials: | ||
# root@password | ||
|
||
FROM docker.io/gitpod/workspace-full:2023-10-06-16-22-14@sha256:76d3041cc7a2caa00d6f4610ace0e15009c361515f3d5d9ee6690e4019adcfd4 | ||
|
||
# Switch to root user to install dependencies and configure sshd | ||
USER root | ||
|
||
# Install dependencies | ||
RUN DEBIAN_FRONTEND="noninteractive" apt-get update && \ | ||
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \ | ||
# Development dependencies \ | ||
dos2unix \ | ||
git \ | ||
locales-all \ | ||
rsync \ | ||
tar \ | ||
ssh \ | ||
tzdata \ | ||
# Build dependencies \ | ||
build-essential \ | ||
ccache \ | ||
cmake \ | ||
curl \ | ||
default-jdk \ | ||
gcc \ | ||
g++ \ | ||
gdb \ | ||
make \ | ||
python3 \ | ||
# Celix dependencies \ | ||
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 && \ | ||
apt-get clean | ||
|
||
# Switch back to the (default) gitpod user | ||
USER gitpod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# 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. | ||
|
||
# SSH credentials: | ||
# root@password | ||
|
||
FROM docker.io/library/ubuntu:22.04@sha256:b492494d8e0113c4ad3fe4528a4b5ff89faa5331f7d52c5c138196f69ce176a6 | ||
|
||
# Install dependencies | ||
RUN DEBIAN_FRONTEND="noninteractive" apt-get update && \ | ||
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \ | ||
# Development dependencies \ | ||
dos2unix \ | ||
git \ | ||
locales-all \ | ||
rsync \ | ||
tar \ | ||
ssh \ | ||
tzdata \ | ||
# Build dependencies \ | ||
build-essential \ | ||
ccache \ | ||
cmake \ | ||
curl \ | ||
default-jdk \ | ||
gcc \ | ||
g++ \ | ||
gdb \ | ||
make \ | ||
python3 \ | ||
# Celix dependencies \ | ||
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 && \ | ||
apt-get clean | ||
|
||
RUN ( \ | ||
echo 'Port 2233'; \ | ||
echo 'LogLevel INFO'; \ | ||
echo 'PermitRootLogin yes'; \ | ||
echo 'PasswordAuthentication yes'; \ | ||
echo 'Subsystem sftp /usr/lib/openssh/sftp-server'; \ | ||
) > /etc/ssh/sshd_config_celix \ | ||
&& mkdir /run/sshd | ||
|
||
RUN yes password | passwd root | ||
|
||
CMD ["/usr/sbin/sshd", "-D", "-e", "-f", "/etc/ssh/sshd_config_celix"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Celix dev container usage | ||
|
||
This subdirectory contains a [Gitpod Containerfile](./Containerfile.gitpod) for developing on Celix using [Gitpod](https://gitpod.io/#https://github.com/apache/celix) | ||
and a [Ubuntu Containerfile](./Containerfile.ubuntu) for local development on Celix. | ||
|
||
The below steps only need to be executed if you want to develop locally, and not via Gitpod. | ||
|
||
## Build the celix-dev image yourself | ||
|
||
To always be able to develop on Celix with an up-to-date image, built the image yourself. | ||
|
||
```bash | ||
./container/build-ubuntu-container.sh | ||
``` | ||
|
||
## Using the image | ||
|
||
### Start locally with SSH daemon | ||
|
||
```bash | ||
cd <project-root> | ||
|
||
# Start a local container with the SSH daemon running | ||
./container/start-ubuntu-container.sh | ||
``` | ||
|
||
Now connect to the container via the remote container option of your favoured IDE and start building/developing. | ||
|
||
For example, you can now start with: | ||
|
||
* CLion connected to the container using [JetBrains Gateway](https://www.jetbrains.com/help/clion/remote-development-a.html) | ||
* CLion configured to connect to the container as [Remote Host](https://www.jetbrains.com/help/clion/remote-projects-support.html) | ||
|
||
When finished with development and testing, press `CTRL + \` to stop the SSH daemon and exit the container. | ||
|
||
### Start locally with only a bash shell | ||
|
||
The start script allows passing of additional paramters, which will override the starting of the SSH daemon. | ||
Execute the following commands to open a bash shell and build Celix from the command line: | ||
|
||
```bash | ||
cd <project-root> | ||
|
||
# Start a local container and open a bash shell | ||
./container/start-ubuntu-container.sh bash | ||
|
||
# Build Apache Celix | ||
mkdir celix-build | ||
cd celix-build | ||
../container/support-scripts/build-all.sh | ||
make -j | ||
|
||
# Run the unit tests for Apache Celix | ||
ctest --output-on-failure | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/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 a Celix dev container with all needed dependencies pre-installed. | ||
|
||
SCRIPT_LOCATION=$(realpath "$(dirname "${BASH_SOURCE[0]}")") | ||
CELIX_REPO_ROOT=$(realpath "${SCRIPT_LOCATION}/..") | ||
|
||
# Check which container engine is available. | ||
# Check for podman first, because the 'podman-docker' package might be installed providing a dummy 'docker' command. | ||
if command -v podman > /dev/null 2>&1; then | ||
CONTAINER_ENGINE="podman" | ||
else | ||
CONTAINER_ENGINE="docker" | ||
fi | ||
|
||
cd "${SCRIPT_LOCATION}" | ||
${CONTAINER_ENGINE} build -t apache/celix-dev:ubuntu-latest -f Containerfile.ubuntu . | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/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. | ||
# | ||
# Start a Celix dev container with all needed dependencies | ||
# pre-installed already. | ||
|
||
SCRIPT_LOCATION=$(realpath "$(dirname "${BASH_SOURCE[0]}")") | ||
CELIX_REPO_ROOT=$(realpath "${SCRIPT_LOCATION}/..") | ||
|
||
CONTAINER_COMMAND_DEFAULT="/usr/sbin/sshd -D -e -f /etc/ssh/sshd_config_celix" | ||
CONTAINER_COMMAND=${1:-${CONTAINER_COMMAND_DEFAULT}} | ||
|
||
# Check which container engine is available. | ||
# Check for podman first, because the 'podman-docker' package might be installed providing a dummy 'docker' command. | ||
if command -v podman > /dev/null 2>&1; then | ||
CONTAINER_ENGINE="podman" | ||
else | ||
CONTAINER_ENGINE="docker" | ||
fi | ||
|
||
# Start a container with all the Celix dependencies pre-installed | ||
# --privileged to allow the unit tests to change thread priorities | ||
# --net=host is used to allow e.g. communication with etcd | ||
# --volume & --workdir are set to the Celix repo root (to allow building and editing of the Celix repo) | ||
# --security-opt disables SELinux for the container | ||
${CONTAINER_ENGINE} run -it --rm --privileged \ | ||
--net=host \ | ||
--volume "${CELIX_REPO_ROOT}":"${CELIX_REPO_ROOT}" \ | ||
--workdir "${CELIX_REPO_ROOT}" \ | ||
--security-opt label=disable \ | ||
apache/celix-dev:ubuntu-latest ${CONTAINER_COMMAND} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/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 \ | ||
.. | ||
|