Skip to content

Support for build-time build args #37

@ajhalili2006

Description

@ajhalili2006

About this Issue

I embedded some image metadata straight to one of my Dockerfiles, like this one below, to aid in debugging issues on an fresh Gitpod workspace.

# Source: https://gitlab.com/gitpodify/gitpodified-workspace-images/blob/ad23ccfac649e7f1ab3db219447bccaf01065de3/base/Dockerfile#L75-94
ARG buildId=123e4567-e89b-12d3-a456-426652340000
ARG maintainer="Recap Time Squad <docker+gp-ws-images@recaptime.tk>"
ARG gitRepo=https://gitlab.com/gitpodify/gitpodified-workspace-images
ARG commitId=0000000000000000000000000000
LABEL dev.gitpodify.baseImage.buildId=${buildId} \
      dev.gitpodify.baseImage.buildMaintainer=${maintainer} \
      org.opencontainers.image.licenses=MIT \
      org.opencontainers.image.source=${gitRepo} \
      dev.gitpodify.baseImage.buildSource=${gitRepo} \
      dev.gitpodify.baseImage.gitCommitSha=${commitId}
# Load build ID, maintainer and source metadata as env vars
ENV GITPODIFY_BASE_BUILD_ID=${buildId} \
    GITPODIFY_BASE_BUILD_MAINTAINER=${maintainer} \
    GITPODIFY_BASE_BUILD_SOURCE=${gitRepo} \
    GITPODIFY_BASE_BUILD_COMMIT_SHA=${commitId} \
    # GITPODIFY_IMAGE_BUILD_ID can be changed when built on other images base don it, so we're also provide
    # the GITPODIFY_BASE_BUILD_ID just in case.
    GITPODIFY_IMAGE_BUILD_ID=${buildId} \
    # For dotfiles support handling on install scripts and stuff
    GITPODIFIED_WORKSPACE_IMAGE=true

The only problem is we embed two dynamic build argument called buildId and commitId. My build script generates the build ID through uuidgen package and also get the commit ID from Git through the git rev-parse HEAD command.

Suggestion

Add an --build-arg flag to the dazzle build command.

Workarounds

I can generate these values on the fly before using dazzle build using some cat <dazzle/chunks/name-here>/chunk.yml | envsubst >> <dazzle/chunks/name-here>/chunk.yml magic on the build script, through this add gettext package to list of required system packages to install, especially on Alpine Linux-based containers OR use docker build instead.

Other notes

Currently, build arguments at build time are unsupported in Dazzle yet as per https://github.com/gitpod-io/dazzle#limitations-and-caveats.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions