Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use buildah for building images #773

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 131 additions & 0 deletions images/build-fedora
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#!/bin/bash
set -Eeuo pipefail

cd $(dirname "$0")

if [ -z "${1+x}" ]; then
echo "Usage: $0 FEDORA_RELEASE_NUMBER"
exit 1
fi

if [[ ! "$1" =~ ^[0-9]+$ || "$1" -lt 28 ]]; then
echo "Invalid Fedora version '$1'. Earliest supported version is Fedora 28"
exit 1
fi

# Container name and version label
name="fedora-toolbox"
version=$1

# Build container
container=$(buildah from registry.fedoraproject.org/fedora:$version)

# It's important to set environment variables before running the setup script
buildah config \
--env NAME="$name" \
--env VERSION="$version" \
--label com.github.containers.toolbox="true" \
--label com.github.debarshiray.toolbox="true" \
--label com.redhat.component="$name" \
--label name="$name" \
--label version="$version" \
--label usage="This image is meant to be used with the toolbox command" \
--label summary="Base image for creating Fedora toolbox containers" \
--label maintainer="Debarshi Ray <[email protected]>" \
--cmd /bin/sh \
$container

# Create script that runs inside the container (saves the script in $setup_script)
# || true is needed because read return 1 on EOF
tmp_setup_script=$(mktemp)
chmod +x "$tmp_setup_script"
cat <<'EOF' > $tmp_setup_script || true
#!/bin/bash
set -Eeuo pipefail

# Enable docs installation
sed -i "/tsflags=nodocs/d" /etc/dnf/dnf.conf

# Reinstall all currently installed packages to get docs
dnf -y reinstall $(dnf list --installed|cut -d' ' -f1)

# Update every package to the latest version
dnf -y distro-sync

# Add extra packages on a per release basis
case $VERSION in
28)
extra_pkgs="PackageKit-command-not-found"
;;
29)
extra_pkgs="flatpak-xdg-utils"
;;
30)
extra_pkgs="flatpak-spawn"
;;
31|32)
extra_pkgs="flatpak-spawn xorg-x11-xauth gvfs-client"
;;
33|34)
extra_pkgs="flatpak-spawn xorg-x11-xauth gvfs-client nano-default-editor"
;;
*)
extra_pkgs=""
;;
esac

# Install packages common for all versions (along with $extra_pkgs)
dnf -y install $extra_pkgs \
bash-completion \
bzip2 \
diffutils \
dnf-plugins-core \
findutils \
fpaste \
git \
gnupg \
gnupg2-smime \
hostname \
iputils \
jwhois \
keyutils \
krb5-libs \
less \
lsof \
man-db \
man-pages \
mlocate \
mtr \
nss-mdns \
openssh-clients \
passwd \
pigz \
procps-ng \
rsync \
shadow-utils \
sudo \
tcpdump \
time \
traceroute \
tree \
unzip \
vte-profile \
wget \
which \
words \
xz \
zip

# Clean package installation cache to save some space
dnf clean all
EOF

# Inject and run setup script from $setup_script
buildah copy $container "$tmp_setup_script" /setup.sh
buildah run $container /setup.sh
buildah run $container rm /setup.sh

# Add README and finish container
buildah copy $container ../README.md /README.md
buildah commit $container $name:$version
buildah rm $container
27 changes: 0 additions & 27 deletions images/fedora/f28/Containerfile

This file was deleted.

1 change: 0 additions & 1 deletion images/fedora/f28/README.md

This file was deleted.

40 changes: 0 additions & 40 deletions images/fedora/f28/extra-packages

This file was deleted.

22 changes: 0 additions & 22 deletions images/fedora/f28/missing-docs

This file was deleted.

28 changes: 0 additions & 28 deletions images/fedora/f29/Containerfile

This file was deleted.

1 change: 0 additions & 1 deletion images/fedora/f29/README.md

This file was deleted.

40 changes: 0 additions & 40 deletions images/fedora/f29/extra-packages

This file was deleted.

20 changes: 0 additions & 20 deletions images/fedora/f29/missing-docs

This file was deleted.

28 changes: 0 additions & 28 deletions images/fedora/f30/Containerfile

This file was deleted.

1 change: 0 additions & 1 deletion images/fedora/f30/README.md

This file was deleted.

40 changes: 0 additions & 40 deletions images/fedora/f30/extra-packages

This file was deleted.

Loading