fedora-40: fix buildah environment

This commit is contained in:
thislight 2024-07-14 15:32:27 +08:00
parent c9afabb81f
commit 95b662533c
No known key found for this signature in database
GPG key ID: A50F9451AC56A63E
2 changed files with 30 additions and 6 deletions

View file

@ -17,11 +17,25 @@ RUN dnf install -y --setopt install_weak_deps=False buildah podman --exclude con
# We don't clean up dnf cache since user may want to install packages for their use # We don't clean up dnf cache since user may want to install packages for their use
ADD containers.conf /etc/containers/ ADD containers.conf /etc/containers/
ADD containers/storage.conf /etc/containers/
# Adjust storage.conf to enable Fuse storage. # Copy & modify the defaults to provide reference if runtime changes needed.
RUN sed -i -e 's|^#mount_program|mount_program|g' -e '/additionalimage.*/a "/var/lib/shared",' /etc/containers/storage.conf # Changes here are required for running with fuse-overlay storage inside container.
RUN mkdir -p /var/lib/shared/overlay-images /var/lib/shared/overlay-layers; touch /var/lib/shared/overlay-images/images.lock; touch /var/lib/shared/overlay-layers/layers.lock RUN sed -e 's|^#mount_program|mount_program|g' \
-e '/additionalimage.*/a "/var/lib/shared",' \
-e 's|^mountopt[[:space:]]*=.*$|mountopt = "nodev,fsync=0"|g' \
/usr/share/containers/storage.conf \
> /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
# Define uid/gid ranges for our user https://github.com/containers/buildah/issues/3053 # Define uid/gid ranges for our user https://github.com/containers/buildah/issues/3053
RUN useradd action && \ RUN useradd action && \
@ -31,6 +45,18 @@ RUN useradd action && \
mkdir -p /home/action/.config/containers && \ mkdir -p /home/action/.config/containers && \
chown -R action:action /home/action chown -R action:action /home/action
# See: https://github.com/containers/buildah/issues/4669
# Copy & modify the config for the `action` user and remove the global
# `runroot` and `graphroot` which current `actuib` 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/action/.config/containers/storage.conf && \
chown action:action /home/action/.config/containers/storage.conf
VOLUME /var/lib/containers VOLUME /var/lib/containers
VOLUME /home/action/.local/share/containers VOLUME /home/action/.local/share/containers

View file

@ -1,2 +0,0 @@
[storage.option.overlay]
mount_program="/usr/bin/fuse-overlayfs"