Skip to content

Commit 9b40e7f

Browse files
committed
remove expand
1 parent 3488bf2 commit 9b40e7f

File tree

1 file changed

+0
-129
lines changed

1 file changed

+0
-129
lines changed

docs/tutorials/template-from-scratch.md

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -338,135 +338,6 @@ resource "docker_container" "workspace" {
338338
}
339339
```
340340

341-
<details>
342-
<summary>Expand for the full `main.tf` file</summary>
343-
```tf
344-
terraform {
345-
required_providers {
346-
coder = {
347-
source = "coder/coder"
348-
}
349-
docker = {
350-
source = "kreuzwerker/docker"
351-
}
352-
}
353-
}
354-
355-
locals {
356-
username = data.coder_workspace_owner.me.name
357-
}
358-
359-
data "coder_provisioner" "me" {
360-
}
361-
362-
provider "docker" {
363-
}
364-
365-
provider "coder" {
366-
}
367-
368-
data "coder_workspace" "me" {
369-
}
370-
371-
data "coder_workspace_owner" "me" {}
372-
373-
resource "coder_agent" "main" {
374-
arch = data.coder_provisioner.me.arch
375-
os = "linux"
376-
startup_script = <<-EOT
377-
set -e
378-
379-
# install and start code-server
380-
curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server
381-
/tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &
382-
EOT
383-
384-
env = {
385-
GIT_AUTHOR_NAME = coalesce(data.coder_workspace_owner.me.full_name, data.coder_workspace_owner.me.name)
386-
GIT_AUTHOR_EMAIL = "${data.coder_workspace_owner.me.email}"
387-
GIT_COMMITTER_NAME = coalesce(data.coder_workspace_owner.me.full_name, data.coder_workspace_owner.me.name)
388-
GIT_COMMITTER_EMAIL = "${data.coder_workspace_owner.me.email}"
389-
}
390-
391-
metadata {
392-
display_name = "CPU Usage"
393-
key = "0_cpu_usage"
394-
script = "coder stat cpu"
395-
interval = 10
396-
timeout = 1
397-
}
398-
399-
metadata {
400-
display_name = "RAM Usage"
401-
key = "1_ram_usage"
402-
script = "coder stat mem"
403-
interval = 10
404-
timeout = 1
405-
}
406-
}
407-
408-
resource "coder_app" "code-server" {
409-
agent_id = coder_agent.main.id
410-
slug = "code-server"
411-
display_name = "code-server"
412-
url = "http://localhost:13337/?folder=/home/${local.username}"
413-
icon = "/icon/code.svg"
414-
subdomain = false
415-
share = "owner"
416-
417-
healthcheck {
418-
url = "http://localhost:13337/healthz"
419-
interval = 5
420-
threshold = 6
421-
}
422-
}
423-
424-
resource "docker_volume" "home_volume" {
425-
name = "coder-${data.coder_workspace.me.id}-home"
426-
# Protect the volume from being deleted due to changes in attributes.
427-
lifecycle {
428-
ignore_changes = all
429-
}
430-
}
431-
432-
resource "docker_image" "main" {
433-
name = "coder-${data.coder_workspace.me.id}"
434-
build {
435-
context = "./build"
436-
build_args = {
437-
USER = local.username
438-
}
439-
}
440-
triggers = {
441-
dir_sha1 = sha1(join("", [for f in fileset(path.module, "build/*") : filesha1(f)]))
442-
}
443-
}
444-
445-
resource "docker_container" "workspace" {
446-
count = data.coder_workspace.me.start_count
447-
image = docker_image.main.name
448-
# Uses lower() to avoid Docker restriction on container names.
449-
name = "coder-${data.coder_workspace_owner.me.name}-${lower(data.coder_workspace.me.name)}"
450-
# Hostname makes the shell more user friendly: coder@my-workspace:~$
451-
hostname = data.coder_workspace.me.name
452-
# Use the docker gateway if the access URL is 127.0.0.1
453-
entrypoint = ["sh", "-c", replace(coder_agent.main.init_script, "/localhost|127\\.0\\.0\\.1/", "host.docker.internal")]
454-
env = [
455-
"CODER_AGENT_TOKEN=${coder_agent.main.token}",
456-
]
457-
host {
458-
host = "host.docker.internal"
459-
ip = "host-gateway"
460-
}
461-
volumes {
462-
container_path = "/home/${local.username}"
463-
volume_name = docker_volume.home_volume.name
464-
read_only = false
465-
}
466-
}
467-
```
468-
</details>
469-
470341
## 7. Create the template in Coder
471342

472343
Save `main.tf` and exit the editor.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy