Skip to content

How to reference a devcontainer-template / create a hierarchy of templates in a repo? #26

Open

Description

Hi,

I'm trying to get started with devcontainers but I can not use the cpp devcontainer image because its base image (base-ubuntu in my case) does not support a recent enough version for me (I need a recent version of gcc, currently only available in ubuntu lunar).

So, I tried authoring both a custom base-ubuntu and a custom cpp template. I'm struggling with using base-ubuntu as the base of my cpp template. I must be missing something. Does the devcontainer template package in ghcr.io need to be built to a docker image and hosted elsewhere?

The whole point of doing this in two templates is that cpp depend on some of the decontainer features being available from base-ubuntu (git, common).

Here is my repo and the most recent pull request smoke test, with trace output for devcontainer cli's up command: https://github.com/meastp/devcontainer-templates/actions/runs/5878222841/job/15939860188?pr=5

I suspect the problem is that I'm trying to reference the base-ubuntu image in src/cpp/Dockerfile:

FROM ghcr.io/meastp/devcontainer-templates/base-ubuntu:latest

I'm not sure how to solve this, if it should be supported or if I need to build the image out of band?

Activity

  1. samruddhikhandale commented on Aug 16, 2023

    @samruddhikhandale
    Member

    Hi 👋

    So, I tried authoring both a custom base-ubuntu and a custom cpp template. I'm struggling with using base-ubuntu as the base of my cpp template.

    Looks like you are trying to create two Templates (ubuntu and cpp) and extend cpp from the ubuntu Template? Unfortunately, the spec currently does not support building a Template on top of another one. All the templates are isolated and are built on top of an image rather than a Template.

    In your case, can you create a new ubuntu Docker image and push it to a registry of your choice? Then, you'd be able to reference it in your cpp Template. Let me know if that makes sense, thanks!

    Another alternative, create the cpp template whose Dockerfile would also contain the ubuntu contents (ie. which you would ideally put in your ubuntu Template or the contents used to build that image). However, I think the first approach is a bit cleaner.

  2. meastp commented on Aug 16, 2023

    @meastp
    Author

    Another alternative, create the cpp template whose Dockerfile would also contain the ubuntu contents (ie. which you would ideally put in your ubuntu Template or the contents used to build that image). However, I think the first approach is a bit cleaner.

    This won't work, because the cpp template (content/script in Dockerfile) depends on some devcontainer features being installed. It does look like devcontainer features are added after the content of the Dockerfile is executed, that's why this needs to be in two images/templates/..

    In your case, can you create a new ubuntu Docker image and push it to a registry of your choice? Then, you'd be able to reference it in your cpp Template. Let me know if that makes sense, thanks!

    This does make sense, but I'm not sure how to do it. Is it possible to create a github action on the template repository to generate and push docker image(s) for base-ubuntu as well? If it is, could you please explain how? Using the devcontainer ci somehow? devcontainer-ci build command? How does this work with template parameters?
    I feel there is some documentation around this missing (or I haven't been able to find it).

    Thank you for helping with this! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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