From 6382bb38313ca960f51ce6cf24eb5ac75a87d9d6 Mon Sep 17 00:00:00 2001 From: Kyle Gospodnetich Date: Sat, 22 Mar 2025 15:18:22 -0700 Subject: feat: Avoid copying build files into image, add option for linting (#93) --- Containerfile | 16 ++++++++++++---- build.sh | 24 ------------------------ build_files/build.sh | 24 ++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 28 deletions(-) delete mode 100755 build.sh create mode 100755 build_files/build.sh diff --git a/Containerfile b/Containerfile index 015dfaf..69550ff 100644 --- a/Containerfile +++ b/Containerfile @@ -1,3 +1,8 @@ +# Allow build scripts to be referenced without being copied into the final image +FROM scratch AS ctx +COPY build_files / + +# Base Image FROM ghcr.io/ublue-os/bazzite:stable ## Other possible base images include: @@ -13,11 +18,14 @@ FROM ghcr.io/ublue-os/bazzite:stable ## make modifications desired in your image and install packages by modifying the build.sh script ## the following RUN directive does all the things required to run "build.sh" as recommended. -COPY build.sh /tmp/build.sh - -RUN --mount=type=cache,dst=/var/cache \ +RUN --mount=type=bind,from=ctx,source=/,target=/ctx \ + --mount=type=cache,dst=/var/cache \ --mount=type=cache,dst=/var/log \ --mount=type=tmpfs,dst=/tmp \ - /tmp/build.sh && \ + /ctx/build.sh && \ ostree container commit +### LINTING +## Verify final image and contents are correct. +## This can be quite sensitive, so it's disabled by default. +# RUN bootc container lint \ No newline at end of file diff --git a/build.sh b/build.sh deleted file mode 100755 index f1e659a..0000000 --- a/build.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -set -ouex pipefail - -### Install packages - -# Packages can be installed from any enabled yum repo on the image. -# RPMfusion repos are available by default in ublue main images -# List of rpmfusion packages can be found here: -# https://mirrors.rpmfusion.org/mirrorlist?path=free/fedora/updates/39/x86_64/repoview/index.html&protocol=https&redirect=1 - -# this installs a package from fedora repos -dnf5 install -y tmux - -# Use a COPR Example: -# -# dnf5 -y copr enable ublue-os/staging -# dnf5 -y install package -# Disable COPRs so they don't end up enabled on the final image: -# dnf5 -y copr disable ublue-os/staging - -#### Example for enabling a System Unit File - -systemctl enable podman.socket diff --git a/build_files/build.sh b/build_files/build.sh new file mode 100755 index 0000000..f1e659a --- /dev/null +++ b/build_files/build.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -ouex pipefail + +### Install packages + +# Packages can be installed from any enabled yum repo on the image. +# RPMfusion repos are available by default in ublue main images +# List of rpmfusion packages can be found here: +# https://mirrors.rpmfusion.org/mirrorlist?path=free/fedora/updates/39/x86_64/repoview/index.html&protocol=https&redirect=1 + +# this installs a package from fedora repos +dnf5 install -y tmux + +# Use a COPR Example: +# +# dnf5 -y copr enable ublue-os/staging +# dnf5 -y install package +# Disable COPRs so they don't end up enabled on the final image: +# dnf5 -y copr disable ublue-os/staging + +#### Example for enabling a System Unit File + +systemctl enable podman.socket -- cgit v1.2.3