Skip to content

Commit f12bdd7

Browse files
Add docs for devcontainer templates publish (#410)
* Add docs for `devcontainer templates publish` ref: microsoft/vscode-dev-containers#1238 * Update publish.md * Update publish.md * Update docs/templates/publish.md Co-authored-by: Samruddhi Khandale <[email protected]> * Update publish.md --------- Co-authored-by: Samruddhi Khandale <[email protected]>
1 parent 4705707 commit f12bdd7

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

docs/templates/publish.md

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Publishing Dev Container Templates
2+
3+
> NOTE: You may want to first check out our [templates-starter](https://github.com/devcontainers/template-starter), which includes an example [actions workflow](https://github.com/devcontainers/action) for publishing directly out of your GitHub repo!
4+
5+
## Summary
6+
7+
The CLI can be used to publish [Dev Container Template](https://containers.dev/implementors/templates/) artifacts to an OCI registry (that supports the [artifacts specification](https://oras.land/implementors/)).
8+
9+
To see all the available options, run `devcontainers templates publish --help`.
10+
11+
## Example
12+
13+
Given a directory that is organized according to the [Templates distribution specification](https://containers.dev/implementors/templates-distribution/) - for example:
14+
15+
```
16+
├── src
17+
│ ├── color
18+
│ │ ├── devcontainer-template.json
19+
│ │ └──| .devcontainer
20+
│ │ └── devcontainer.json
21+
│ ├── hello
22+
│ │ ├── devcontainer-template.json
23+
│ │ └──| .devcontainer
24+
│ │ ├── devcontainer.json
25+
│ │ └── Dockerfile
26+
| ├── ...
27+
│ │ ├── devcontainer-template.json
28+
│ │ └──| .devcontainer
29+
│ │ └── devcontainer.json
30+
├── test
31+
│ ├── color
32+
│ │ └── test.sh
33+
│ ├── hello
34+
│ │ └── test.sh
35+
│ └──test-utils
36+
│ └── test-utils.sh
37+
...
38+
```
39+
40+
The following command will publish each Template above (`color,hello`) to the registry `ghcr.io` with the following namespace (prefix) `devcontainers/templates`.
41+
42+
```
43+
[/tmp]$ GITHUB_TOKEN="$CR_PAT" devcontainer templates publish -r ghcr.io -n devcontainers/templates ./src
44+
```
45+
46+
To later apply a published Template (in the example below, the `color` template) with the CLI, the following [apply](../apply) command would be used:
47+
48+
```
49+
[/tmp]$ devcontainer templates apply \
50+
-t 'ghcr.io/devcontainers/templates/color' \
51+
-a '{"favorite": "red"}'
52+
```
53+
54+
### Authentication Methods
55+
56+
> NOTE: OS-specific docker credential helpers (Docker Desktop credential helper) are not currently recognized by the CLI.
57+
58+
- Adding a $HOME/.docker/config.json with your credentials following [this commonly defined format](https://www.systutorials.com/docs/linux/man/5-docker-config-json/).
59+
- Your `docker login` command may write this file for you depending on your operating system.
60+
- Using our custom env variable DEVCONTAINERS_OCI_AUTH
61+
- eg: `DEVCONTAINERS_OCI_AUTH=service1|user1|token1,service2|user2|token2`
62+
63+
For publishing to `ghcr.io`
64+
- Using the `devcontainers/action` GitHub action to handle the `GITHUB_TOKEN` credential for you.
65+
- Providing a GITHUB_TOKEN with permission to `write:packages`.

0 commit comments

Comments
 (0)