Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for build-time build args #37

Open
ajhalili2006 opened this issue Jan 15, 2022 · 0 comments
Open

Support for build-time build args #37

ajhalili2006 opened this issue Jan 15, 2022 · 0 comments

Comments

@ajhalili2006
Copy link

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 <[email protected]>"
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.

ajhalili2006 added a commit to gitpodify/legacy-workspace-images that referenced this issue Mar 11, 2022
…ainer

This is an current workaround for gitpod-io/dazzle#37 for now.

Signed-off-by: Andrei Jiroh Eugenio Halili <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant