-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from cevich/pbsaio
Add all-in-one image and build automation
- Loading branch information
Showing
9 changed files
with
405 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# aio/Containerfile | ||
# | ||
# Build an all in one Podman, Buildah, Skopeo container | ||
# image from the latest stable version of Podman on the | ||
# Fedoras Updates System. | ||
# https://bodhi.fedoraproject.org/updates/?search=podman | ||
# https://bodhi.fedoraproject.org/updates/?search=buildah | ||
# https://bodhi.fedoraproject.org/updates/?search=skopeo | ||
# This image is intended to be used as-is, or as a base- | ||
# image for development work or use in CI/CD systems. | ||
|
||
FROM registry.fedoraproject.org/fedora-minimal:latest | ||
|
||
# When building for multiple-architectures in parallel using emulation | ||
# it's really easy for one/more dnf processes to timeout or mis-count | ||
# the minimum download rates. Bump both to be extremely forgiving of | ||
# an overworked host. | ||
RUN echo -e "\n\n# Added during image build" >> /etc/dnf/dnf.conf && \ | ||
echo -e "minrate=100\ntimeout=60\n" >> /etc/dnf/dnf.conf | ||
|
||
RUN microdnf -y makecache && \ | ||
microdnf -y update && \ | ||
microdnf -y install podman buildah skopeo fuse-overlayfs openssh-clients \ | ||
--exclude "container-selinux,qemu-*" && \ | ||
rpm --setcaps shadow-utils 2>/dev/null && \ | ||
microdnf clean all && \ | ||
rm -rf /var/cache /var/log/dnf* /var/log/yum.* | ||
|
||
# It's assumed `user` will end up with UID/GID 1000 | ||
RUN useradd user && \ | ||
echo -e "user:1:999\nuser:1001:64535" > /etc/subuid && \ | ||
echo -e "user:1:999\nuser:1001:64535" > /etc/subgid | ||
|
||
ADD /containers.conf /etc/containers/containers.conf | ||
ADD /user-containers.conf /home/user/.config/containers/containers.conf | ||
|
||
RUN mkdir -p /home/user/.local/share/containers && \ | ||
mkdir -p /home/user/.config/containers && \ | ||
chown user:user -R /home/user && \ | ||
chmod 644 /etc/containers/containers.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 | ||
|
||
# Setup internal Podman to pass 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 | ||
|
||
# Note VOLUME options must always happen after the chown call above | ||
# RUN commands can not modify existing volumes | ||
VOLUME /var/lib/containers | ||
VOLUME /home/user/.local/share/containers | ||
|
||
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 | ||
|
||
ENV _CONTAINERS_USERNS_CONFIGURED="" \ | ||
BUILDAH_ISOLATION=chroot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
[comment]: <> (***ATTENTION*** ***WARNING*** ***ALERT*** ***CAUTION*** ***DANGER***) | ||
[comment]: <> () | ||
[comment]: <> (ANY changes made below, once committed/merged must) | ||
[comment]: <> (be manually copy/pasted -in markdown- into the description) | ||
[comment]: <> (field on Quay at the following locations:) | ||
[comment]: <> () | ||
[comment]: <> (https://quay.io/repository/containers/aio) | ||
[comment]: <> () | ||
[comment]: <> (***ATTENTION*** ***WARNING*** ***ALERT*** ***CAUTION*** ***DANGER***) | ||
|
||
![PODMAN logo](https://raw.githubusercontent.com/containers/common/main/logos/podman-logo-full-vert.png) | ||
![buildah logo](https://cdn.rawgit.com/containers/buildah/main/logos/buildah-logo_large.png) | ||
<img src="https://cdn.rawgit.com/containers/skopeo/main/docs/skopeo.svg" width="250"> | ||
|
||
# All In One: Podman, Buildah and Skopeo Image | ||
|
||
## Build information | ||
|
||
Please see the [containers/image_build repo. README.md for build | ||
details](https://github.com/containers/image_build/blob/main/README.md). | ||
|
||
## Sample Usage | ||
|
||
Running as 'root' inside the container: | ||
|
||
``` | ||
# Create a directory on the host to mount the container's | ||
# /var/lib/container directory to so containers can be | ||
# run within the container. | ||
mkdir /var/lib/mycontainers | ||
# Run a shell in the container, will full nested container run and build | ||
# possibilities: | ||
podman run -it --net=host --security-opt label=disable --privileged \ | ||
--security-opt seccomp=unconfined --device /dev/fuse:rw \ | ||
-v /var/lib/mycontainers:/var/lib/containers:Z \ | ||
quay.io/containers/aio:latest | ||
``` | ||
|
||
Running rootless inside the container: | ||
``` | ||
mkdir $HOME/mycontainers | ||
# Run a shell in the container, will full nested container run and build | ||
# possibilities: | ||
podman run -it --net=host --security-opt label=disable --privileged \ | ||
--security-opt seccomp=unconfined --device /dev/fuse:rw \ | ||
--user user --userns=keep-id:uid=1000,gid=1000 \ | ||
-v $HOME/mycontainers:/home/user/.local/share/containers:Z \ | ||
quay.io/containers/aio:latest | ||
``` | ||
|
||
**Note:** If you encounter a `fuse: device not found` error when running the container image, it is likely that | ||
the fuse kernel module has not been loaded on your host system. Use the command `modprobe fuse` to load the | ||
module and then run the container image. To enable this automatically at boot time, you can add a configuration | ||
file to `/etc/modules.load.d`. See `man modules-load.d` for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[containers] | ||
netns="host" | ||
userns="host" | ||
ipcns="host" | ||
utsns="host" | ||
cgroupns="host" | ||
cgroups="disabled" | ||
log_driver = "k8s-file" | ||
|
||
[engine] | ||
cgroup_manager = "cgroupfs" | ||
events_logger="file" | ||
runtime="crun" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/bin/bash | ||
|
||
# This script is not intended for humans. It's meant to be run | ||
# by a CI system after a test-build of the | ||
# quay.io/containers/aio:latest manifest list. | ||
|
||
set -eo pipefail | ||
|
||
if [[ -r "/etc/automation_environment" ]]; then | ||
source /etc/automation_environment # defines AUTOMATION_LIB_PATH | ||
#shellcheck disable=SC1090,SC2154 | ||
source "$AUTOMATION_LIB_PATH/common_lib.sh" | ||
dbg "Using automation common library version $(<$AUTOMATION_LIB_PATH/../AUTOMATION_VERSION)" | ||
else | ||
echo "Expecting to find automation common library installed." | ||
exit 1 | ||
fi | ||
|
||
FQIN="quay.io/containers/aio:latest" | ||
FQIN_FILE="$(basename $FQIN | tr ':' '-').tar" | ||
|
||
# msg() doesn't support a prefix, nor show file/line-no. | ||
# Abuse warn() to print testing messages and make them stand-out. | ||
WARNING_MSG_PREFIX="***** TEST:" | ||
msg() { warn "$1"; } | ||
|
||
# These tests need to be run rootless, assume the environment is disposable. | ||
# N/B: This condition does not return! | ||
if [[ "$UID" -eq 0 ]]; then | ||
msg "Check that $FQIN exists in local storage" | ||
showrun podman manifest exists $FQIN | ||
|
||
msg "Verify manifest-list contains image for amd64 architecture" | ||
arches=$(showrun podman manifest inspect $FQIN | showrun jq -r -e '.manifests[].platform.architecture') | ||
showrun grep -F -x -q 'amd64' <<<"$arches" | ||
|
||
msg "Verify skopeo can inspect the local manifest list" | ||
showrun skopeo inspect --raw containers-storage:$FQIN | jq . | ||
|
||
msg "Setting up for rootless testing" | ||
TESTUSER="testuser$RANDOM" | ||
showrun useradd "$TESTUSER" | ||
export TUHOME="/home/$TESTUSER" | ||
showrun podman save -o "$TUHOME/$FQIN_FILE" "$FQIN" | ||
showrun chown $TESTUSER:$TESTUSER "$TUHOME/$FQIN_FILE" | ||
(umask 077; showrun mkdir -p "/root/.ssh") | ||
(umask 077; showrun ssh-keyscan localhost >> "/root/.ssh/known_hosts") | ||
showrun ssh-keygen -t rsa -P "" -f "/root/.ssh/id_rsa" | ||
(umask 077; showrun mkdir -p "$TUHOME/.ssh") | ||
showrun cp "/root/.ssh/id_rsa.pub" "$TUHOME/.ssh/authorized_keys" | ||
showrun chown -R $TESTUSER:$TESTUSER "$TUHOME/.ssh" | ||
showrun chmod 0600 "$TUHOME/.ssh/authorized_keys" | ||
# $SCRIPT_PATH/$SCRIPT_FILENAME defined by automation library | ||
# shellcheck disable=SC2154 | ||
showrun exec ssh $TESTUSER@localhost $SCRIPT_PATH/$SCRIPT_FILENAME | ||
fi | ||
|
||
# SCRIPT_FILENAME defined by automation library | ||
# shellcheck disable=SC2154 | ||
TMPD=$(mktemp -p '' -d ${SCRIPT_FILENAME}_XXXXX_tmp) | ||
trap "podman unshare rm -rf '$TMPD'" EXIT | ||
|
||
msg "Loading test image" | ||
showrun podman load -i $HOME/$FQIN_FILE | ||
|
||
# These tests come directly from the aio/README.md examples | ||
mkdir $TMPD/cntr_storage | ||
mkdir $TMPD/context | ||
echo -e 'FROM registry.fedoraproject.org/fedora-minimal:latest\nENV TESTING=true' > $TMPD/context/Containerfile | ||
for tool in buildah podman; do | ||
msg "Verify $tool can create a simple image as root inside $FQIN" | ||
showrun podman unshare rm -rf $TMPD/cntr_storage/* $TMPD/cntr_storage/.??* | ||
showrun podman run -i --rm --net=host --security-opt label=disable --privileged \ | ||
--security-opt seccomp=unconfined --device /dev/fuse:rw \ | ||
-v $TMPD/cntr_storage:/var/lib/containers:Z \ | ||
-v $TMPD/context:/root/context:Z \ | ||
$FQIN $tool build -t root_testimage /root/context | ||
|
||
msg "Verify $tool can create a simple image as rootless inside $FQIN" | ||
showrun podman unshare rm -rf $TMPD/cntr_storage/* $TMPD/cntr_storage/.??* | ||
showrun podman run -i --rm --net=host --security-opt label=disable --privileged \ | ||
--security-opt seccomp=unconfined --device /dev/fuse:rw \ | ||
--user user --userns=keep-id:uid=1000,gid=1000 \ | ||
-v $TMPD/cntr_storage:/home/user/.local/share/containers:Z \ | ||
-v $TMPD/context:/home/user/context:Z \ | ||
$FQIN $tool build -t rootless_testimage /home/user/context | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[containers] | ||
volumes = [ | ||
"/proc:/proc", | ||
] | ||
default_sysctls = [] |
Oops, something went wrong.