diff --git a/pkg/build/build.go b/pkg/build/build.go index c9f9a419d..15e5508a4 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -33,6 +33,16 @@ var ( // BUNDLE_DIR is the directory where the bundle is located in the CNAB execution environment. BUNDLE_DIR = "/cnab/app" + // BUNDLE_UID is the user id assigned to the user executing the bundle + BUNDLE_UID = 65532 + + // BUNDLE_GID is the group assigned to the user executing the bundle + // Defaults to root + BUNDLE_GID = 0 + + // BUNDLE_USER is the username assigned to the user executing the bundle + BUNDLE_USER="nonroot" + // PORTER_MIXINS_TOKEN can control where mixin instructions will be placed in // Dockerfile. PORTER_MIXINS_TOKEN = "# PORTER_MIXINS" diff --git a/pkg/build/dockerfile-generator.go b/pkg/build/dockerfile-generator.go index df131251d..860924ebe 100644 --- a/pkg/build/dockerfile-generator.go +++ b/pkg/build/dockerfile-generator.go @@ -192,9 +192,9 @@ func (g *DockerfileGenerator) buildMixinsSection(ctx context.Context) ([]string, func (g *DockerfileGenerator) buildInitSection() []string { return []string{ "ARG BUNDLE_DIR", - "ARG BUNDLE_UID=65532", - "ARG BUNDLE_USER=nonroot", - "ARG BUNDLE_GID=0", + fmt.Sprintf("ARG BUNDLE_UID=%d", BUNDLE_UID), + fmt.Sprintf("ARG BUNDLE_USER=%s", BUNDLE_USER), + fmt.Sprintf("ARG BUNDLE_GID=%d", BUNDLE_GID), // Create a non-root user that is in the root group with the specified id and a home directory "RUN useradd ${BUNDLE_USER} -m -u ${BUNDLE_UID} -g ${BUNDLE_GID} -o", }