opnsense-src/share/examples/oci/Containerfile.pkg
Doug Rabson 0fbe9f8ef9 share/examples/oci: Run 'pkg update' with IGNORE_OSVERSION set
This allows the image build to work even if the host's OSVERSION doesn't
match the pkgbase OSVERSION which happens if the host's patch level or
release version isn't the same as pkgbase.

Also fix the image name so that Podman/Buildah will fetch it
automatically, removing the need for users to pull an image and retag it
before using this example.

Reviewed by:		dch
MFC after:		3 days
Differential Revision:	https://reviews.freebsd.org/D50596
2025-07-22 11:46:01 +01:00

30 lines
1.1 KiB
Text

# This is an example showing how to extend the freebsd-runtime OCI image by
# installing additional packages while keeping the resulting image as small as
# possible.
# The OS version matching the desired freebsd-runtime image
ARG version=14.snap
# Select freebsd-runtime as our starting point.
FROM ghcr.io/freebsd/freebsd-runtime:${version}
# A list of package(s) to install
ARG packages
# Install package management tools. We specify 'FreeBSD' as the repository to
# use for downloading pkg since the freebsd-runtime image has both FreeBSD and
# FreeBSD-base pkg repo configs installed and FreeBSD-base does not contain the
# pkg package.
#
# Set IGNORE_OSVERSION to allow building e.g. FreeBSD-14 images on
# FreeBSD-15 hosts.
RUN pkg bootstrap -y -r FreeBSD && pkg -o IGNORE_OSVERSION=yes update -f
# Install some package(s).
RUN pkg install -y ${packages}
# Clean up and remove package management overhead. We delete downloaded
# packages, uninstall pkg and delete the repository metadata downloaded by 'pkg
# install'. This retains the record of which packages are installed in the
# image.
RUN pkg clean -ay && pkg delete -fy pkg && rm -rf /var/db/pkg/repos