xref: /freebsd/share/examples/oci/Containerfile.pkg (revision 3750ccefb8629a08890bfbae894dd6bc6a7483b4)
1# This is an example showing how to extend the freebsd-minimal 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-minimal image
6ARG version=15.0-CURRENT-amd64
7
8# Select freebsd-minimal as our starting point.
9FROM localhost/freebsd-minimal:${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-minimal image has both FreeBSD and
16# FreeBSD-base pkg repo configs installed and FreeBSD-base does not contain the
17# pkg package.
18RUN env ASSUME_ALWAYS_YES=yes pkg bootstrap -r FreeBSD && pkg update
19
20# Install some package(s).
21RUN pkg install -y ${packages}
22
23# Clean up and remove package management overhead. We delete downloaded
24# packages, uninstall pkg and delete the repository metadata downloaded by 'pkg
25# install'.  This retains the record of which packages are installed in the
26# image.
27RUN pkg clean -ay && pkg delete -fy pkg && rm -rf /var/db/pkg/repos
28