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

Commit42c6b08

Browse files
authored
example: add and document dotfiles usage (#2046)
1 parentc331137 commit42c6b08

File tree

3 files changed

+111
-0
lines changed

3 files changed

+111
-0
lines changed

‎docs/workspaces.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ resources](./templates.md#persistent-and-ephemeral-resources).
6565
6666
When a workspace is deleted, all of the workspace's resources are deleted.
6767

68+
##Dotfiles
69+
70+
Users can install configuration from a personal[dotfiles repository](https://dotfiles.github.io) with the`coder dotfiles <repo>`
71+
command in their workspace. Templates can also prompt users for their dotfiles repo[(example)](../examples/templates/docker-with-dotfiles/README.md#how-it-works).
72+
6873
##Updating workspaces
6974

7075
Use the following command to update a workspace to the latest template version.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name:Develop in Docker with a dotfiles URL
3+
description:Run workspaces on a Docker host using registry images
4+
tags:[local, docker]
5+
---
6+
7+
#docker-with-dotfiles
8+
9+
This is an example for deploying workspaces with a prompt for the users' dotfiles repo URI.
10+
11+
##Getting started
12+
13+
Run`coder templates init` and select this template. Follow the instructions that appear.
14+
15+
##How it works
16+
17+
During workspace creation, Coder prompts you to specify a dotfiles URL via a Terraform variable. Once the workspace starts, the Coder agent runs`coder dotfiles` via the startup script:
18+
19+
```hcl
20+
variable "dotfiles_uri" {
21+
description = <<-EOF
22+
Dotfiles repo URI (optional)
23+
24+
see https://dotfiles.github.io
25+
EOF
26+
# The codercom/enterprise-* images are only built for amd64
27+
default = ""
28+
}
29+
30+
resource "coder_agent" "dev" {
31+
...
32+
startup_script = var.dotfiles_uri != "" ? "/tmp/tmp.coder*/coder dotfiles -y ${var.dotfiles_uri}" : null
33+
}
34+
```
35+
36+
#Managing images and workspaces
37+
38+
Refer to the documentation in the[Docker template](../docker/README.md).
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Note: this example demonstrates the use of
2+
# dotfiles with Coder templates.
3+
4+
# The Docker aspect of the template only works
5+
# with MacOS/Linux amd64 systems. See the full
6+
# Docker example for details
7+
8+
terraform {
9+
required_providers {
10+
coder={
11+
source="coder/coder"
12+
version="0.4.1"
13+
}
14+
docker={
15+
source="kreuzwerker/docker"
16+
version="~> 2.16.0"
17+
}
18+
}
19+
}
20+
21+
provider"docker" {
22+
host="unix:///var/run/docker.sock"
23+
}
24+
25+
provider"coder" {
26+
}
27+
28+
data"coder_workspace""me" {
29+
}
30+
31+
variable"dotfiles_uri" {
32+
description=<<-EOF
33+
Dotfiles repo URI (optional)
34+
35+
see https://dotfiles.github.io
36+
EOF
37+
default=""
38+
}
39+
40+
resource"coder_agent""dev" {
41+
arch="amd64"
42+
os="linux"
43+
startup_script=var.dotfiles_uri!=""?"coder dotfiles -y${var.dotfiles_uri}":null
44+
}
45+
46+
resource"docker_volume""home_volume" {
47+
name="coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}-root"
48+
}
49+
50+
resource"docker_container""workspace" {
51+
count=data.coder_workspace.me.start_count
52+
image="codercom/enterprise-base:ubuntu"
53+
# Uses lower() to avoid Docker restriction on container names.
54+
name="coder-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}"
55+
dns=["1.1.1.1"]
56+
# Refer to Docker host when Coder is on localhost
57+
command=["sh","-c",replace(coder_agent.dev.init_script,"127.0.0.1","host.docker.internal")]
58+
env=["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
59+
host {
60+
host="host.docker.internal"
61+
ip="host-gateway"
62+
}
63+
volumes {
64+
container_path="/home/coder/"
65+
volume_name=docker_volume.home_volume.name
66+
read_only=false
67+
}
68+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp