Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5953a46

Browse files
authored
docs: Open in Coder (#6859)
* docs: git auth via template* add page* docs: Open in Coder* fmt
1 parenta6b7e8c commit5953a46

File tree

6 files changed

+136
-0
lines changed

6 files changed

+136
-0
lines changed
1.51 MB
Binary file not shown.
Lines changed: 16 additions & 0 deletions
Loading
54.3 KB
Loading

‎docs/manifest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@
146146
"description":"Use parameters to customize templates",
147147
"path":"./templates/parameters.md",
148148
"icon_path":"./images/icons/code.svg"
149+
},
150+
{
151+
"title":"Open in Coder",
152+
"description":"Learn how to add an\"Open in Coder\" button to your repos",
153+
"path":"./templates/open-in-coder.md",
154+
"icon_path":"./images/icons/key.svg"
149155
}
150156
]
151157
},

‎docs/templates/open-in-coder.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#Open in Coder
2+
3+
An "Open in Coder" button can be embedded into your git repos or internal wikis to allow developers to quickly launch a new workspace.
4+
5+
<videoautoplayplaysinlineloop>
6+
<sourcesrc="https://github.com/coder/coder/blob/main/docs/images/templates/open-in-coder.mp4?raw=true"type="video/mp4">
7+
Your browser does not support the video tag.
8+
</video>
9+
10+
##How it works
11+
12+
To support any infrastructure and software stack, Coder provides a generic approach for "Open in Coder" flows.
13+
14+
1. Set up[Git Authentication](../admin/git-providers.md#require-git-authentication-in-templates) in your Coder deployment
15+
16+
1. Modify your template to auto-clone repos:
17+
18+
- If you want the template to clone a specific git repo
19+
20+
```hcl
21+
# Require git authentication to use this template
22+
data "coder_git_auth" "github" {
23+
id = "github"
24+
}
25+
26+
resource "coder_agent" "dev" {
27+
# ...
28+
dir = "~/coder"
29+
startup_script =<<EOF
30+
31+
# Clone repo from GitHub
32+
if [ ! -d "coder" ]
33+
then
34+
git clone https://github.com/coder/coder
35+
fi
36+
37+
EOF
38+
}
39+
```
40+
41+
- If you want the template to support any repository via [parameters](./parameters.md)
42+
43+
```hcl
44+
# Require git authentication to use this template
45+
data "coder_git_auth" "github" {
46+
id = "github"
47+
}
48+
49+
# Prompt the user for the git repo URL
50+
data "coder_parameter" "git_repo" {
51+
name = "Git repository"
52+
default = "https://github.com/coder/coder"
53+
}
54+
55+
locals {
56+
folder_name = try(element(split("/", data.coder_parameter.git_repo.value), length(split("/", data.coder_parameter.git_repo.value)) - 1), "")
57+
}
58+
59+
resource "coder_agent" "dev" {
60+
# ...
61+
dir = "~/${local.folder_name}"
62+
startup_script =<<EOF
63+
64+
# Clone repo from GitHub
65+
if [ ! -d "${local.folder_name}" ]
66+
then
67+
git clone ${data.coder_parameter.git_repo.value}
68+
fi
69+
70+
EOF
71+
}
72+
```
73+
74+
1. Embed the "Open in Coder" button with Markdown
75+
76+
```md
77+
[![Open in Coder](https://YOUR_ACCESS_URL/open-in-coder.svg)](https://YOUR_ACCESS_URL/templates/YOUR_TEMPLATE/workspace)
78+
```
79+
80+
>Be sure to replace`YOUR_ACCESS_URL` with your Coder access url (e.g.https://coder.example.com) and`YOUR_TEMPLATE` with the name of your template.
81+
82+
1. Optional: pre-fill parameter values in the "Create workspace" page
83+
84+
This can be used to pre-fill the git repo URL, disk size, image, etc.
85+
86+
```md
87+
[![Open in Coder](https://YOUR_ACCESS_URL/open-in-coder.svg)](https://YOUR_ACCESS_URL/templates/YOUR_TEMPLATE/workspace?param.Git%20repository=https://github.com/coder/slog&param.Home%20Disk%20Size%20%28GB%29=20)
88+
```
89+
90+
![Pre-filled parameters](../images/templates/pre-filled-parameters.png)
91+
92+
##Example: Kubernetes
93+
94+
For a full example of the Open in Coder flow in Kubernetes, check out[this example template](https://github.com/bpmct/coder-templates/tree/main/kubernetes-open-in-coder).
95+
96+
##Devcontainer support
97+
98+
Devcontainer support is on the roadmap.[Follow along here](https://github.com/coder/coder/issues/5559)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp