Git Product home page Git Product logo

template-starter's Introduction

Dev Container Templates: Self Authoring Guide

This repo provides a starting point and example for creating your own custom Dev Container Templates, hosted for free on GitHub Container Registry. The example in this repository follows the Dev Container Template distribution specification.

To provide feedback on the distribution spec, please leave a comment on spec issue #71.

Repo and Template Structure

This repository contains a collection of two Templates - hello and color. These Templates serve as simple template implementations which helps containerize the project. Similar to the devcontainers/templates repo, this repository has a src folder. Each Template has its own sub-folder, containing at least a devcontainer-template.json and .devcontainer/devcontainer.json.

├── src
│   ├── color
│   │   ├── devcontainer-template.json
│   │   └──| .devcontainer
│   │      └── devcontainer.json
│   ├── hello
│   │   ├── devcontainer-template.json
│   │   └──| .devcontainer
│   │      ├── devcontainer.json
│   │      └── Dockerfile
|   ├── ...
│   │   ├── devcontainer-template.json
│   │   └──| .devcontainer
│   │      └── devcontainer.json
├── test
│   ├── color
│   │   └── test.sh
│   ├── hello
│   │   └── test.sh
│   └──test-utils
│      └── test-utils.sh
...

Options

All available options for a Template should be declared in the devcontainer-template.json. The syntax for the options property can be found in the devcontainer Template json properties reference.

For example, the color Template provides three possible options (red, gold, green), where the default value is set to "red".

{
    // ...
    "options": {
        "favorite": {
            "type": "string",
            "description": "Choose your favorite color."
            "proposals": [
                "red",
                "gold",
                "green"
            ],
            "default": "red"
        }
    }
}

An implementing tool will use the options property from the documented Dev Container Template properties for customizing the Template. See option resolution example for details.

Distributing Templates

Note: Allow GitHub Actions to create and approve pull requests should be enabled in the repository's Settings > Actions > General > Workflow permissions for auto generation of src/<template>/README.md per Template (which merges any existing src/<template>/NOTES.md).

Versioning

Templates are individually versioned by the version attribute in a Template's devcontainer-template.json. Templates are versioned according to the semver specification. More details can be found in the Dev Container Template specification.

Publishing

NOTE: The Distribution spec can be found here.

While any registry implementing the OCI Distribution spec can be used, this template will leverage GHCR (GitHub Container Registry) as the backing registry.

Templates are source files packaged together that encode configuration for a complete development environment.

This repo contains a GitHub Action workflow that will publish each template to GHCR. By default, each Template will be prefixed with the <owner/<repo> namespace. For example, the two Templates in this repository can be referenced by an implementing tool with:

ghcr.io/devcontainers/template-starter/color:latest
ghcr.io/devcontainers/template-starter/hello:latest

The provided GitHub Action will also publish a third "metadata" package with just the namespace, eg: ghcr.io/devcontainers/template-starter. This contains information useful for tools aiding in Template discovery.

'devcontainers/template-starter' is known as the template collection namespace.

Marking Template Public

For your Template to be used, it currently needs to be available publicly. By default, OCI Artifacts in GHCR are marked as private.

To make them public, navigate to the Template's "package settings" page in GHCR, and set the visibility to 'public`.

https://github.com/users/<owner>/packages/container/<repo>%2F<templateName>/settings

Adding Templates to the Index

Next you will need to add your Templates collection to our public index so that other community members can find them. Just follow these steps once per collection you create:

This index is from where supporting tools like VS Code Dev Containers and GitHub Codespaces surface Templates for their Dev Container Creation Configuration UI.

Testing Templates

This repo contains a GitHub Action workflow for testing the Templates. Similar to the devcontainers/templates repo, this repository has a test folder. Each Template has its own sub-folder, containing at least a test.sh.

For running the tests locally, you would need to execute the following commands -

    ./.github/actions/smoke-test/build.sh ${TEMPLATE-ID} 
    ./.github/actions/smoke-test/test.sh ${TEMPLATE-ID} 

Updating Documentation

This repo contains a GitHub Action workflow that will automatically generate documentation (ie. README.md) for each Template. This file will be auto-generated from the devcontainer-template.json and NOTES.md.

template-starter's People

Contributors

eitsupi avatar joshuanianji avatar samruddhikhandale avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

template-starter's Issues

Test templates locally?

I'd like to be able to test a devcontainer template locally. Just like the regular old code-test-commit loop that I use for a lot of other projects, I'd love to do the same with a devcontainer-feature.json.

It seems like there's already some testing that's done in the https://github.com/devcontainers/template-starter/blob/main/.github/workflows/test-pr.yaml file, but I'd love to see that pulled out into something more "runnable" rather than stuffed inside a github action. Like ./test.sh or tools/test.sh or something 🤷‍♂️

But that's just an idea. 💡

Tell user about needed permissions for Workflow

Trying to run the workflow Release Dev Container Templates & Generate Documentation from
release.yaml I kept getting error messages, such as:

{
    "errors": [
        {
            "code": "DENIED",
            "message": "installation not allowed to Create organization package"
        }
    ]
}

👇I think one of the final fixes was setting these two things, but I'm not positive what finally got it to work.
image

Is anyone very familiar with Workflow/Permissions who could please take a look? ...and make sure this repo, meant for starters, has more guides/warnings for things that need to be set (as permissions can't be set in the using the fork/template). Or is workflow going to change soon, and this may be non-issue?

This seems similiar to ticket I opened on the template-feature repo devcontainers/feature-starter#38

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

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?

How to provide private templates?

Hello there!

The documentation says:

Templates listed here will be presented in the UX of supporting tools.

Is there a way to provide an additional source for templates to select from, like from a non-public gitlab instance, the same way current templates are shown?

(Alternatively I'm looking for a way to share one container with multiple repositories, something like Reopen/Clone in existing container...)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.