-
Notifications
You must be signed in to change notification settings - Fork 1
/
Containerfile.rocky-minimal
68 lines (56 loc) · 3.13 KB
/
Containerfile.rocky-minimal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# This is a mix of:
# * https://github.com/containers/buildah/blob/main/contrib/buildahimage/Containerfile
# * https://github.com/containers/podman/blob/main/contrib/podmanimage/stable/Containerfile
# FROM registry.fedoraproject.org/fedora:latest
FROM rockylinux:9-minimal
LABEL "io.containers.capabilities"="CHOWN,DAC_OVERRIDE,FOWNER,FSETID,KILL,NET_BIND_SERVICE,SETFCAP,SETGID,SETPCAP,SETUID,CHOWN,DAC_OVERRIDE,FOWNER,FSETID,KILL,NET_BIND_SERVICE,SETFCAP,SETGID,SETPCAP,SETUID,SYS_CHROOT"
RUN printf "[main]\nexcludepkgs=container-selinux" > /etc/dnf/dnf.conf && \
microdnf -y update && \
rpm --setcaps shadow-utils 2>/dev/null && \
microdnf -y install buildah fuse-overlayfs podman nodejs git && \
microdnf -y clean all && \
rm -rf /var/cache /var/log/dnf* /var/log/yum.*
# Define uid/gid ranges for our user https://github.com/containers/buildah/issues/3053
RUN useradd build && \
echo -e "build:1:999\nbuild:1001:64535" > /etc/subuid && \
echo -e "build:1:999\nbuild:1001:64535" > /etc/subgid && \
mkdir -p /home/build/.local/share/containers && \
mkdir -p /home/build/.config/containers && \
chown -R build:build /home/build
ARG _REPO_URL="https://raw.githubusercontent.com/containers/image_build/main/podman"
ADD $_REPO_URL/containers.conf /etc/containers/containers.conf
ADD --chown=build:build $_REPO_URL/podman-containers.conf /home/build/.config/containers/containers.conf
# Setup internal Buildah to pass secrets/subscriptions down from host to internal container
RUN printf '/run/secrets/etc-pki-entitlement:/run/secrets/etc-pki-entitlement\n/run/secrets/rhsm:/run/secrets/rhsm\n' > /etc/containers/mounts.conf
# Copy & modify the defaults to provide reference if runtime changes needed.
# Changes here are required for running with fuse-overlay storage inside container.
RUN sed -e 's|^#mount_program|mount_program|g' \
-e '/additionalimage.*/a "/var/lib/shared",' \
-e 's|^mountopt[[:space:]]*=.*$|mountopt = "nodev,fsync=0"|g' \
/etc/containers/storage.conf && \
chmod 644 /etc/containers/storage.conf && \
chmod 644 /etc/containers/containers.conf
RUN mkdir -p /var/lib/shared/overlay-images \
/var/lib/shared/overlay-layers \
/var/lib/shared/vfs-images \
/var/lib/shared/vfs-layers && \
touch /var/lib/shared/overlay-images/images.lock && \
touch /var/lib/shared/overlay-layers/layers.lock && \
touch /var/lib/shared/vfs-images/images.lock && \
touch /var/lib/shared/vfs-layers/layers.lock
# See: https://github.com/containers/buildah/issues/4669
# Copy & modify the config for the `build` user and remove the global
# `runroot` and `graphroot` which current `build` user cannot access,
# in such case storage will choose a runroot in `/var/tmp`.
RUN sed -e 's|^#mount_program|mount_program|g' \
-e 's|^graphroot|#graphroot|g' \
-e 's|^runroot|#runroot|g' \
/etc/containers/storage.conf \
> /home/build/.config/containers/storage.conf && \
chown build:build /home/build/.config/containers/storage.conf
VOLUME /var/lib/containers
VOLUME /home/build/.local/share/containers
# Set an environment variable to default to chroot isolation for RUN
# instructions and "buildah run".
ENV BUILDAH_ISOLATION=chroot
USER build:build