Skip to content

Commit 28a3ae4

Browse files
committed
Add development container for usage with Podman
This patch adds a development container for usage with Podman. This new container provides a few improvements compared to the already existing one: - The new container image is based on the official Debian Bullseye image in the slim variant. The existing container is using a three years old image based on Debian Stretch. - The new container image only contains a minimal set of Debian packages which are needed to run ELBE from the Git sources. The container image has a size of 329 MB. The already existing image has a size of 1.15 GB. - To build and run the container image / instance Podman is used. The main reason to switch from Docker to Podman - in this case - is the usage of systemd inside the container. With Docker it is not that easy to run systemd in a container. This can be seen at the already existing container. With Podman it is very easy to achieve this. See https://developers.redhat.com/blog/2019/04/24/how-to-run-systemd-in-a-container for detailed information. Right now there is one downside of the new container: the container instance is started as rootful container in privileged mode. Podman's rootless mode cannot be used, because the CAP_SYS_ADMIN capability is needed which is only granted in rootful mode. The privileged mode is used right now, because I wasn't able the create and use an initvm without it. Dumb copying of the security settings from the existing container was not working unfortunately. This is something which should be optimized in the future. Signed-off-by: Daniel Braunwarth <[email protected]>
1 parent 26c4b9d commit 28a3ae4

File tree

4 files changed

+177
-0
lines changed

4 files changed

+177
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,7 @@ contrib/debathena-transform-lighttpd/debian/*.log
5757
contrib/debathena-transform-lighttpd/debian/debathena-transform-lighttpd/
5858
contrib/debathena-transform-lighttpd/debian/debhelper-build-stamp
5959
contrib/debathena-transform-lighttpd/debian/files
60+
61+
# initvm and ELBE builds
62+
initvm/
63+
elbe-build-*/

contrib/container/Containerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# ELBE development container
2+
# Copyright (c) 2021 Daniel Braunwarth <[email protected]>
3+
#
4+
# SPDX-License-Identifier: GPL-3.0-or-later
5+
6+
FROM debian:bullseye-slim
7+
8+
ENV DEBIAN_FRONTEND=noninteractive
9+
10+
RUN apt-get update --yes && apt-get install --yes --no-install-recommends \
11+
systemd \
12+
python3 \
13+
python3-libvirt \
14+
python3-lxml \
15+
python3-gpg \
16+
python3-mako \
17+
python3-suds \
18+
python3-debian \
19+
wget \
20+
bzip2 \
21+
make \
22+
cpio \
23+
rsync \
24+
ssh \
25+
qemu-system-x86 \
26+
qemu-utils \
27+
libvirt-daemon-system \
28+
&& rm -rf /var/lib/apt/lists/*
29+
30+
RUN systemctl enable libvirtd.service
31+
32+
CMD [ "/lib/systemd/systemd" ]

contrib/container/Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# ELBE development container
2+
# Copyright (c) 2021 Daniel Braunwarth <[email protected]>
3+
#
4+
# SPDX-License-Identifier: GPL-3.0-or-later
5+
6+
build:
7+
podman image build --tag elbe-devel .
8+
9+
start:
10+
podman container list | grep elbe-devel || \
11+
podman container run \
12+
--name elbe-devel \
13+
--detach \
14+
--rm \
15+
--volume $(shell git rev-parse --show-toplevel):/usr/src \
16+
--workdir /usr/src \
17+
--privileged \
18+
elbe-devel
19+
20+
stop:
21+
podman container stop --ignore elbe-devel
22+
23+
attach: start
24+
podman container exec \
25+
--tty \
26+
--interactive \
27+
elbe-devel \
28+
/bin/bash
29+
30+
clean: stop
31+
podman image rm --force elbe-devel || true
32+
33+
.PHONY: build start stop clean atach

contrib/container/README.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# ELBE development container
2+
3+
[//]: # "Copyright (c) 2021 Daniel Braunwarth <[email protected]>"
4+
[//]: # "SPDX-License-Identifier: GPL-3.0-or-later"
5+
6+
This container is intended to build and run ELBE from Git sources.
7+
8+
To build and run the container [Podman](https://podman.io/) should be used.
9+
10+
The container is based on the official Debian Bullseye image in the slim
11+
variant.
12+
13+
## Dependencies
14+
15+
To be able to build and use this container you need:
16+
17+
- [Make](https://www.gnu.org/software/make/)
18+
- [Podman](https://podman.io/)
19+
20+
See <https://podman.io/getting-started/> for information how to get started
21+
with Podman.
22+
23+
## Security
24+
25+
Unfortunately podman cannot be used in rootless mode, because ELBE needs the
26+
`CAP_SYS_ADMIN` capability to be able to facilitate QEMU.
27+
28+
At the moment the container is started in privileged mode. This should be
29+
restricted in the future.
30+
31+
## Usage
32+
33+
### Build container image
34+
35+
To build the container image run:
36+
37+
```shell
38+
sudo make build
39+
```
40+
41+
The resulting image is named `elbe-devel`.
42+
43+
### Start container
44+
45+
To start the container run:
46+
47+
```shell
48+
sudo make start
49+
```
50+
51+
The started container is named `elbe-devel`. It is not possible to start
52+
multiple container instances.
53+
54+
### Stop container
55+
56+
To stop the container run:
57+
58+
```shell
59+
sudo make stop
60+
```
61+
62+
### Attach to running container
63+
64+
To attach to a running container run:
65+
66+
```shell
67+
sudo make attach
68+
```
69+
70+
The default working directory is `/usr/src`. This is where the Git repository
71+
is mounted to.
72+
73+
### Build initvm
74+
75+
To build an initvm attach to the running container and run:
76+
77+
```shell
78+
./elbe initvm --devel create elbepack/init/initvm-ssh-root-open-danger.xml
79+
```
80+
81+
To be able to sync the ELBE sources between the Git repository and the initvm
82+
we must be able to connect to the initvm via SSH as root user. For this reason
83+
we are using `elbepack/init/initvm-ssh-root-open-danger.xml`.
84+
85+
### Add already existing initvm to container
86+
87+
To add an already existing initvm to a newly created container instance attach
88+
to the running container and run:
89+
90+
```shell
91+
virsh --connect qemu:///system define initvm/libvirt.xml
92+
```
93+
94+
### Update ELBE in initvm
95+
96+
To update the used ELBE sources in an initvm run:
97+
98+
```shell
99+
./elbe initvm --devel sync
100+
```
101+
102+
### Clean-up
103+
104+
To remove the container instance and image run:
105+
106+
```shell
107+
sudo make clean
108+
```

0 commit comments

Comments
 (0)