Skip to content

Latest commit

 

History

History
97 lines (69 loc) · 2.95 KB

custom-base-image.md

File metadata and controls

97 lines (69 loc) · 2.95 KB

Custom base image

The following sample can be used to create a containerbase/base based image which does not extend containerbase/base directly. Currently only ubuntu focal and jammy based amd64 distro are suported.

You can also use our buildpack from GitHub container registry as ghcr.io/containerbase/base. containerbase/base and ghcr.io/containerbase/base are exchangeble. You should always use a specific version which can be found at docker hub or at GitHub container registry

Default user name and id

Use this template for using a custom base image with our default user named ubuntu and userid 1000.

# This buildpack is used for tool intallation and user/directory setup
FROM containerbase/base AS buildpack

FROM amd64/ubuntu:focal as base

# Allows custom apt proxy usage
ARG APT_HTTP_PROXY

# Set env and shell
ENV BASH_ENV=/usr/local/etc/env ENV=/usr/local/etc/env PATH=/home/ubuntu/bin:$PATH
SHELL ["/bin/bash" , "-c"]

# This entry point ensures that dumb-init is run
ENTRYPOINT [ "docker-entrypoint.sh" ]
CMD [ "bash" ]

# Optional: Add custom root certificate, should come before `install-buildpack`
COPY my-root-ca.crt /usr/local/share/ca-certificates/my-root-ca.crt

# Set up buildpack
COPY --from=buildpack /usr/local/bin/ /usr/local/bin/
COPY --from=buildpack /usr/local/base/ /usr/local/base/
RUN install-buildpack


# renovate: datasource=github-tags packageName=git/git
RUN install-tool git v2.30.0
# renovate: datasource=docker versioning=docker
RUN install-tool node 14.15.4
# renovate: datasource=npm versioning=npm
RUN install-tool yarn 1.22.10

WORKDIR /usr/src/app

# must be numeric if this should work with openshift
USER 1000

Custom user name and id

You can also customize username or userid by using this template.

# This buildpack is used for tool intallation and user/directory setup
FROM containerbase/base AS buildpack

FROM amd64/ubuntu:focal as base

# The buildpack supports custom user
ARG USER_NAME=custom
ARG USER_ID=1005
# Allows custom apt proxy usage
ARG APT_HTTP_PROXY

# Set env and shell
ENV BASH_ENV=/usr/local/etc/env ENV=/usr/local/etc/env PATH=/home/$USER_NAME/bin:$PATH
SHELL ["/bin/bash" , "-c"]

# This entry point ensures that dumb-init is run
ENTRYPOINT [ "docker-entrypoint.sh" ]
CMD [ "bash" ]

# Optional: Add custom root certificate, should come before `install-buildpack`
COPY my-root-ca.crt /usr/local/share/ca-certificates/my-root-ca.crt

# Set up buildpack
COPY --from=buildpack /usr/local/bin/ /usr/local/bin/
COPY --from=buildpack /usr/local/base/ /usr/local/base/
RUN install-buildpack


# renovate: datasource=github-tags packageName=git/git
RUN install-tool git v2.30.0
# renovate: datasource=docker versioning=docker
RUN install-tool node 14.15.4
# renovate: datasource=npm versioning=npm
RUN install-tool yarn 1.22.10

WORKDIR /usr/src/app

# must be numeric if this should work with openshift
USER 1005