xref: /freebsd/share/examples/oci/Containerfile.pkg (revision 0fbe9f8ef94d15439e89a3ab951d1dda254d54e3)
1# This is an example showing how to extend the freebsd-runtime OCI image by
2# installing additional packages while keeping the resulting image as small as
3# possible.
4
5# The OS version matching the desired freebsd-runtime image
6ARG version=14.snap
7
8# Select freebsd-runtime as our starting point.
9FROM ghcr.io/freebsd/freebsd-runtime:${version}
10
11# A list of package(s) to install
12ARG packages
13
14# Install package management tools. We specify 'FreeBSD' as the repository to
15# use for downloading pkg since the freebsd-runtime image has both FreeBSD and
16# FreeBSD-base pkg repo configs installed and FreeBSD-base does not contain the
17# pkg package.
18#
19# Set IGNORE_OSVERSION to allow building e.g. FreeBSD-14 images on
20# FreeBSD-15 hosts.
21RUN pkg bootstrap -y -r FreeBSD && pkg -o IGNORE_OSVERSION=yes update -f
22
23# Install some package(s).
24RUN pkg install -y ${packages}
25
26# Clean up and remove package management overhead. We delete downloaded
27# packages, uninstall pkg and delete the repository metadata downloaded by 'pkg
28# install'.  This retains the record of which packages are installed in the
29# image.
30RUN pkg clean -ay && pkg delete -fy pkg && rm -rf /var/db/pkg/repos
31