You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/templates/gcp-devcontainer/README.md
+16-1Lines changed: 16 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -51,14 +51,29 @@ a service account:
51
51
52
52
This template provisions the following resources:
53
53
54
-
- GCP VM (persistent)
54
+
- Envbuilder cached image (conditional, persistent) using [`terraform-provider-envbuilder`](https://github.com/coder/terraform-provider-envbuilder)
55
+
- GCP VM (persistent) with a running Docker daemon
55
56
- GCP Disk (persistent, mounted to root)
57
+
-[Envbuilder container](https://github.com/coder/envbuilder) inside the GCP VM
56
58
57
59
Coder persists the root volume. The full filesystem is preserved when the workspace restarts.
60
+
When the GCP VM starts, a startup script runs that ensures a running Docker daemon, and starts
61
+
an Envbuilder container using this Docker daemon. The Docker socket is also mounted inside the container to allow running Docker containers inside the workspace.
58
62
59
63
> **Note**
60
64
> This template is designed to be a starting point! Edit the Terraform to extend the template to support your use case.
61
65
66
+
## Caching
67
+
68
+
To speed up your builds, you can use a container registry as a cache.
69
+
When creating the template, set the parameter `cache_repo` to a valid Docker repository in the form `host.tld/path/to/repo`.
70
+
71
+
See the [Envbuilder Terraform Provider Examples](https://github.com/coder/terraform-provider-envbuilder/blob/main/examples/resources/envbuilder_cached_image/envbuilder_cached_image_resource.tf/) for a more complete example of how the provider works.
72
+
73
+
> [!NOTE] We recommend using a registry cache with authentication enabled.
74
+
> To allow Envbuilder to authenticate with the registry cache, specify the variable `cache_repo_docker_config_path`
75
+
> with the path to a Docker config `.json` on disk containing valid credentials for the registry.
76
+
62
77
## code-server
63
78
64
79
`code-server` is installed via the [`code-server`](https://registry.coder.com/modules/code-server) registry module. Please check [Coder Registry](https://registry.coder.com) for a list of all modules and templates.
Copy file name to clipboardExpand all lines: examples/templates/gcp-devcontainer/main.tf
+7-14Lines changed: 7 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -12,8 +12,7 @@ terraform {
12
12
}
13
13
}
14
14
15
-
provider"coder" {
16
-
}
15
+
provider"coder" {}
17
16
18
17
provider"google" {
19
18
zone=data.coder_parameter.zone.value
@@ -31,19 +30,13 @@ variable "project_id" {
31
30
32
31
variable"cache_repo" {
33
32
default=""
34
-
description="(Optional) Use a container registry as a cache to speed up builds."
33
+
description="(Optional) Use a container registry as a cache to speed up builds. Example: host.tld/path/to/repo."
35
34
type=string
36
35
}
37
36
38
-
variable"insecure_cache_repo" {
39
-
default=false
40
-
description="Enable this option if your cache registry does not serve HTTPS."
41
-
type=bool
42
-
}
43
-
44
37
variable"cache_repo_docker_config_path" {
45
38
default=""
46
-
description="(Optional) Path to a docker config.json containing credentials to the provided cache repo, if required."
39
+
description="(Optional) Path to a docker config.json containing credentials to the provided cache repo, if required. This will depend on your Coder setup. Example: `/home/coder/.docker/config.json`."
47
40
sensitive=true
48
41
type=string
49
42
}
@@ -118,8 +111,8 @@ data "coder_parameter" "fallback_image" {
118
111
data"coder_parameter""devcontainer_builder" {
119
112
description=<<-EOF
120
113
Image that will build the devcontainer.
121
-
We highly recommend using a specific release as the `:latest` tag will change.
122
114
Find the latest version of Envbuilder here: https://ghcr.io/coder/envbuilder
115
+
Be aware that using the `:latest` tag may expose you to breaking changes.
123
116
EOF
124
117
display_name="Devcontainer Builder"
125
118
mutable=true
@@ -141,7 +134,7 @@ data "local_sensitive_file" "cache_repo_dockerconfigjson" {
0 commit comments