|
1 |
| -# Dev Container Features: Self Authoring Template |
| 1 | +# My devcontainer features |
2 | 2 |
|
3 |
| -> This repo provides a starting point and example for creating your own custom [dev container Features](https://containers.dev/implementors/features/), hosted for free on GitHub Container Registry. The example in this repository follows the [dev container Feature distribution specification](https://containers.dev/implementors/features-distribution/). |
4 |
| -> |
5 |
| -> To provide feedback to the specification, please leave a comment [on spec issue #70](https://github.com/devcontainers/spec/issues/70). For more broad feedback regarding dev container Features, please see [spec issue #61](https://github.com/devcontainers/spec/issues/61). |
6 |
| -
|
7 |
| -## Example Contents |
8 |
| - |
9 |
| -This repository contains a _collection_ of two Features - `hello` and `color`. These Features serve as simple feature implementations. Each sub-section below shows a sample `devcontainer.json` alongside example usage of the Feature. |
10 | 3 |
|
11 |
| -### `hello` |
| 4 | +## `magircmirror` |
12 | 5 |
|
13 |
| -Running `hello` inside the built container will print the greeting provided to it via its `greeting` option. |
| 6 | +Automatically setup package manager mirrors, including ubuntu, pypi and apk etc. |
14 | 7 |
|
15 | 8 | ```jsonc
|
16 | 9 | {
|
17 | 10 | "image": "mcr.microsoft.com/devcontainers/base:ubuntu",
|
18 | 11 | "features": {
|
19 |
| - "ghcr.io/devcontainers/feature-starter/hello:1": { |
20 |
| - "greeting": "Hello" |
21 |
| - } |
22 |
| - } |
23 |
| -} |
24 |
| -``` |
25 |
| - |
26 |
| -```bash |
27 |
| -$ hello |
28 |
| - |
29 |
| -Hello, user. |
30 |
| -``` |
31 |
| - |
32 |
| -### `color` |
33 |
| - |
34 |
| -Running `color` inside the built container will print your favorite color to standard out. |
35 |
| - |
36 |
| -```jsonc |
37 |
| -{ |
38 |
| - "image": "mcr.microsoft.com/devcontainers/base:ubuntu", |
39 |
| - "features": { |
40 |
| - "ghcr.io/devcontainers/feature-starter/color:1": { |
41 |
| - "favorite": "green" |
42 |
| - } |
43 |
| - } |
44 |
| -} |
45 |
| -``` |
46 |
| - |
47 |
| -```bash |
48 |
| -$ color |
49 |
| - |
50 |
| -my favorite color is green |
51 |
| -``` |
52 |
| - |
53 |
| -## Repo and Feature Structure |
54 |
| - |
55 |
| -Similar to the [`devcontainers/features`](https://github.com/devcontainers/features) repo, this repository has a `src` folder. Each Feature has its own sub-folder, containing at least a `devcontainer-feature.json` and an entrypoint script `install.sh`. |
56 |
| - |
57 |
| -``` |
58 |
| -├── src |
59 |
| -│ ├── hello |
60 |
| -│ │ ├── devcontainer-feature.json |
61 |
| -│ │ └── install.sh |
62 |
| -│ ├── color |
63 |
| -│ │ ├── devcontainer-feature.json |
64 |
| -│ │ └── install.sh |
65 |
| -| ├── ... |
66 |
| -│ │ ├── devcontainer-feature.json |
67 |
| -│ │ └── install.sh |
68 |
| -... |
69 |
| -``` |
70 |
| - |
71 |
| -An [implementing tool](https://containers.dev/supporting#tools) will composite [the documented dev container properties](https://containers.dev/implementors/features/#devcontainer-feature-json-properties) from the feature's `devcontainer-feature.json` file, and execute in the `install.sh` entrypoint script in the container during build time. Implementing tools are also free to process attributes under the `customizations` property as desired. |
72 |
| - |
73 |
| -### Options |
74 |
| - |
75 |
| -All available options for a Feature should be declared in the `devcontainer-feature.json`. The syntax for the `options` property can be found in the [devcontainer Feature json properties reference](https://containers.dev/implementors/features/#devcontainer-feature-json-properties). |
76 |
| - |
77 |
| -For example, the `color` feature provides an enum of three possible options (`red`, `gold`, `green`). If no option is provided in a user's `devcontainer.json`, the value is set to "red". |
78 |
| - |
79 |
| -```jsonc |
80 |
| -{ |
81 |
| - // ... |
82 |
| - "options": { |
83 |
| - "favorite": { |
84 |
| - "type": "string", |
85 |
| - "enum": [ |
86 |
| - "red", |
87 |
| - "gold", |
88 |
| - "green" |
89 |
| - ], |
90 |
| - "default": "red", |
91 |
| - "description": "Choose your favorite color." |
| 12 | + "ghcr.io/sidecus/devcontainer-features/magicmirror:1": { |
| 13 | + "pypi_mirror": "https://mirrors.bfsu.edu.cn/pypi/web/simple/", |
| 14 | + "ubuntu_mirror": "mirrors.bfsu.edu.cn", |
| 15 | + "apk_mirror": "mirrors.tuna.tsinghua.edu.cn" |
92 | 16 | }
|
93 | 17 | }
|
94 | 18 | }
|
95 | 19 | ```
|
96 | 20 |
|
97 |
| -Options are exported as Feature-scoped environment variables. The option name is captialized and sanitized according to [option resolution](https://containers.dev/implementors/features/#option-resolution). |
98 |
| - |
99 |
| -```bash |
100 |
| -#!/bin/bash |
101 |
| - |
102 |
| -echo "Activating feature 'color'" |
103 |
| -echo "The provided favorite color is: ${FAVORITE}" |
104 |
| - |
105 |
| -... |
106 |
| -``` |
107 |
| - |
108 | 21 | ## Distributing Features
|
109 | 22 |
|
110 | 23 | ### Versioning
|
|
0 commit comments