The build-time base image provides the OS-level dependencies for buildpacks at build-time.
We need a Dockerfile similar to the following:
# Define the base image
FROM ubuntu:jammy
# Install packages that we want to make available at build time
RUN apt-get update && \
apt-get install -y xz-utils ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Set required CNB user information
ARG cnb_uid=1000
ARG cnb_gid=1000
ENV CNB_USER_ID=${cnb_uid}
ENV CNB_GROUP_ID=${cnb_gid}
# Create user and group
RUN groupadd cnb --gid ${CNB_GROUP_ID} && \
useradd --uid ${CNB_USER_ID} --gid ${CNB_GROUP_ID} -m -s /bin/bash cnb
# Set user and group
USER ${CNB_USER_ID}:${CNB_GROUP_ID}
# Set required CNB target information
LABEL io.buildpacks.base.distro.name="your distro name"
LABEL io.buildpacks.base.distro.version="your distro version"
We start with ubuntu:jammy
as our base image.
You can use any operating system, operating system distribution, and operating system distribution version of your choosing,
as long as they are supported by the available buildpacks.
Install any system packages that your buildpacks will need.
We need to define CNB_USER_ID
and CNB_GROUP_ID
in the environment so that the lifecycle can run as the correct user.
The USER
in the image config must match the user indicated by CNB_USER_ID
and CNB_GROUP_ID
.
The given user MUST NOT be a root user, and must have a writeable home directory.
Finally, we need to label the image with operating system distribution information for platforms and the lifecycle to use.
To determine which values to provide, see targets concept information.
docker build . -t cnbs/sample-base-build:jammy