Skip to content

Commit

Permalink
Use podman as base
Browse files Browse the repository at this point in the history
  • Loading branch information
SupremeMortal committed Feb 29, 2024
1 parent b8a7041 commit 9680981
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 301 deletions.
59 changes: 8 additions & 51 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,59 +1,15 @@
FROM registry.fedoraproject.org/fedora:latest
FROM quay.io/podman/testing:latest

LABEL maintainer="luzuccar@redhat.com"
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"

# gcc for cgo
RUN dnf -y makecache && \
dnf -y update && \
rpm --setcaps shadow-utils 2>/dev/null && \
dnf install -y podman buildah slirp4netns shadow-utils git gcc make unzip diffutils nodejs npm fuse-overlayfs cpp --exclude container-selinux && \
dnf install -y git gcc make unzip diffutils nodejs npm && \
dnf -y clean all && \
rm -rf /var/cache /var/log/dnf* /var/log/yum.*

ADD ./containers.conf /etc/containers/

COPY --chmod=755 ./storage.conf /etc/containers/

# 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' \
/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 && \
chmod 755 -R /usr/lib/containers/

RUN useradd -u 65532 -ms /bin/bash build && \
usermod --add-subuids 100000-165535 --add-subgids 100000-165535 build && \
mkdir -p /home/build/.local/share/containers && \
mkdir -p /home/build/.config/containers

# 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

ENV GOLANG_VERSION 1.21.7
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
ENV GOLANG_DOWNLOAD_SHA256 13b76a9b2a26823e53062fa841b07087d48ae2ef2936445dc34c4ae03293702c
Expand All @@ -70,6 +26,8 @@ ENV GOLANGCI_LINT_VERSION v1.56.2

RUN npm install -g yarn

RUN sed -r -i 's/(driver = ")[a-z]+/\1vfs/' /etc/containers/storage.conf

RUN curl -fsSLo ${OPERATOR_SDK_BIN} "https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk_${OS}_${ARCH}" \
&& chmod 0755 $OPERATOR_SDK_BIN

Expand All @@ -93,6 +51,9 @@ ENV GOCACHE /home/build/.cache/go-build
env GOLANGCI_LINT_CACHE /home/build/.cache/golangci-lint
ENV GOENV /home/build/.config/go/env

RUN useradd -u 65532 -ms /bin/bash build && \
usermod --add-subuids 100000-165535 --add-subgids 100000-165535 build

RUN mkdir -p /home/build/src /home/build/bin /home/build/pkg /home/build/build /home/build/.cache /home/build/.local \
&& chmod -R 0777 /home/build

Expand All @@ -107,8 +68,4 @@ COPY uid_entrypoint.sh /home/build/

USER build

ENTRYPOINT [ "./uid_entrypoint.sh" ]

# Set an environment variable to default to chroot isolation for RUN
# instructions and "buildah run".
ENV BUILDAH_ISOLATION=chroot
ENTRYPOINT [ "./uid_entrypoint.sh" ]
2 changes: 0 additions & 2 deletions containers.conf

This file was deleted.

248 changes: 0 additions & 248 deletions storage.conf

This file was deleted.

0 comments on commit 9680981

Please sign in to comment.