2022-07-18 22:44:09 +00:00
|
|
|
terraform {
|
|
|
|
required_providers {
|
|
|
|
coder = {
|
2023-09-26 02:23:42 +00:00
|
|
|
source = "coder/coder"
|
2022-07-18 22:44:09 +00:00
|
|
|
}
|
|
|
|
docker = {
|
|
|
|
source = "kreuzwerker/docker"
|
2023-08-26 22:22:28 +00:00
|
|
|
version = "~> 3.0.0"
|
2022-07-18 22:44:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-17 14:20:48 +00:00
|
|
|
locals {
|
2023-12-01 11:16:49 +00:00
|
|
|
// These are cluster service addresses mapped to Tailscale nodes. Ask Dean or
|
|
|
|
// Kyle for help.
|
2023-01-17 14:20:48 +00:00
|
|
|
docker_host = {
|
2023-12-01 11:16:49 +00:00
|
|
|
"" = "tcp://dogfood-ts-cdr-dev.tailscale.svc.cluster.local:2375"
|
|
|
|
"us-pittsburgh" = "tcp://dogfood-ts-cdr-dev.tailscale.svc.cluster.local:2375"
|
|
|
|
"eu-helsinki" = "tcp://reinhard-hel-cdr-dev.tailscale.svc.cluster.local:2375"
|
|
|
|
"ap-sydney" = "tcp://hildegard-sydney-cdr-dev.tailscale.svc.cluster.local:2375"
|
|
|
|
"sa-saopaulo" = "tcp://oberstein-sao-cdr-dev.tailscale.svc.cluster.local:2375"
|
2023-01-17 14:20:48 +00:00
|
|
|
}
|
2023-10-03 05:55:25 +00:00
|
|
|
|
|
|
|
repo_dir = replace(data.coder_parameter.repo_dir.value, "/^~\\//", "/home/coder/")
|
2023-01-17 14:20:48 +00:00
|
|
|
}
|
2022-07-18 22:44:09 +00:00
|
|
|
|
2023-05-13 12:42:10 +00:00
|
|
|
data "coder_parameter" "repo_dir" {
|
|
|
|
type = "string"
|
|
|
|
name = "Coder Repository Directory"
|
|
|
|
default = "~/coder"
|
|
|
|
description = "The directory specified will be created and [coder/coder](https://github.com/coder/coder) will be automatically cloned into it 🪄."
|
|
|
|
mutable = true
|
|
|
|
}
|
|
|
|
|
|
|
|
data "coder_parameter" "region" {
|
2023-08-26 22:22:28 +00:00
|
|
|
type = "string"
|
|
|
|
name = "Region"
|
|
|
|
icon = "/emojis/1f30e.png"
|
|
|
|
default = "us-pittsburgh"
|
2023-05-13 12:42:10 +00:00
|
|
|
option {
|
|
|
|
icon = "/emojis/1f1fa-1f1f8.png"
|
|
|
|
name = "Pittsburgh"
|
|
|
|
value = "us-pittsburgh"
|
|
|
|
}
|
|
|
|
option {
|
|
|
|
icon = "/emojis/1f1eb-1f1ee.png"
|
|
|
|
name = "Helsinki"
|
|
|
|
value = "eu-helsinki"
|
|
|
|
}
|
|
|
|
option {
|
|
|
|
icon = "/emojis/1f1e6-1f1fa.png"
|
|
|
|
name = "Sydney"
|
|
|
|
value = "ap-sydney"
|
|
|
|
}
|
|
|
|
option {
|
|
|
|
icon = "/emojis/1f1e7-1f1f7.png"
|
|
|
|
name = "São Paulo"
|
|
|
|
value = "sa-saopaulo"
|
|
|
|
}
|
2023-09-13 14:49:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-18 22:44:09 +00:00
|
|
|
provider "docker" {
|
2023-05-13 12:42:10 +00:00
|
|
|
host = lookup(local.docker_host, data.coder_parameter.region.value)
|
2022-07-18 22:44:09 +00:00
|
|
|
}
|
|
|
|
|
2023-01-17 14:20:48 +00:00
|
|
|
provider "coder" {}
|
2022-07-18 22:44:09 +00:00
|
|
|
|
2023-10-12 07:30:00 +00:00
|
|
|
data "coder_external_auth" "github" {
|
2023-05-13 12:42:10 +00:00
|
|
|
id = "github"
|
|
|
|
}
|
|
|
|
|
2023-01-17 14:20:48 +00:00
|
|
|
data "coder_workspace" "me" {}
|
2022-07-18 22:44:09 +00:00
|
|
|
|
2023-10-10 22:46:47 +00:00
|
|
|
module "slackme" {
|
2023-10-11 08:29:25 +00:00
|
|
|
source = "https://registry.coder.com/modules/slackme"
|
2023-10-10 22:46:47 +00:00
|
|
|
agent_id = coder_agent.dev.id
|
|
|
|
auth_provider_id = "slack"
|
|
|
|
}
|
|
|
|
|
chore(dogfood): use coder modules in dogfood (#9890)
updates dogfood to use coder modules
---
<details open="true"><summary>Generated summary (powered by <a href="https://app.graphite.dev">Graphite</a>)</summary>
> # TL;DR
> This pull request removes the `dotfiles_url` and `jetbrains_ide` parameters, and the related code from the `main.tf` file. It also adds several new modules for `dotfiles`, `git-clone`, `personalize`, `code-server`, `jetbrains_gateway`, `vscode`, and `filebrowser`. The `startup_script` has been updated to remove the installation and launch of `filebrowser` and the `dotfiles` related code.
>
> # What changed
> - Removed `dotfiles_url` and `jetbrains_ide` parameters.
> - Removed related code for `dotfiles_url` and `jetbrains_ide`.
> - Added new modules for `dotfiles`, `git-clone`, `personalize`, `code-server`, `jetbrains_gateway`, `vscode`, and `filebrowser`.
> - Updated `startup_script` to remove the installation and launch of `filebrowser` and the `dotfiles` related code.
>
> # How to test
> 1. Go to https://dev.coder.com/templates/coder/versions/dazzling_hugle0 and create a new workspace or change your dogfood workspace version to `dazzling_hugle0` .
> 2. Verify that the new modules are working as expected.
>
> # Why make this change
> The `dotfiles_url` and `jetbrains_ide` parameters and related code were removed to simplify the configuration and make it easier to manage. The new modules were added to provide additional functionality and improve the overall user experience. The `startup_script` was updated to reflect these changes.
</details>
2023-09-30 19:22:14 +00:00
|
|
|
module "dotfiles" {
|
|
|
|
source = "https://registry.coder.com/modules/dotfiles"
|
|
|
|
agent_id = coder_agent.dev.id
|
|
|
|
}
|
|
|
|
|
|
|
|
module "git-clone" {
|
|
|
|
source = "https://registry.coder.com/modules/git-clone"
|
|
|
|
agent_id = coder_agent.dev.id
|
|
|
|
url = "https://github.com/coder/coder"
|
2023-10-03 05:55:25 +00:00
|
|
|
path = local.repo_dir
|
chore(dogfood): use coder modules in dogfood (#9890)
updates dogfood to use coder modules
---
<details open="true"><summary>Generated summary (powered by <a href="https://app.graphite.dev">Graphite</a>)</summary>
> # TL;DR
> This pull request removes the `dotfiles_url` and `jetbrains_ide` parameters, and the related code from the `main.tf` file. It also adds several new modules for `dotfiles`, `git-clone`, `personalize`, `code-server`, `jetbrains_gateway`, `vscode`, and `filebrowser`. The `startup_script` has been updated to remove the installation and launch of `filebrowser` and the `dotfiles` related code.
>
> # What changed
> - Removed `dotfiles_url` and `jetbrains_ide` parameters.
> - Removed related code for `dotfiles_url` and `jetbrains_ide`.
> - Added new modules for `dotfiles`, `git-clone`, `personalize`, `code-server`, `jetbrains_gateway`, `vscode`, and `filebrowser`.
> - Updated `startup_script` to remove the installation and launch of `filebrowser` and the `dotfiles` related code.
>
> # How to test
> 1. Go to https://dev.coder.com/templates/coder/versions/dazzling_hugle0 and create a new workspace or change your dogfood workspace version to `dazzling_hugle0` .
> 2. Verify that the new modules are working as expected.
>
> # Why make this change
> The `dotfiles_url` and `jetbrains_ide` parameters and related code were removed to simplify the configuration and make it easier to manage. The new modules were added to provide additional functionality and improve the overall user experience. The `startup_script` was updated to reflect these changes.
</details>
2023-09-30 19:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module "personalize" {
|
|
|
|
source = "https://registry.coder.com/modules/personalize"
|
|
|
|
agent_id = coder_agent.dev.id
|
|
|
|
}
|
|
|
|
|
|
|
|
module "code-server" {
|
|
|
|
source = "https://registry.coder.com/modules/code-server"
|
|
|
|
agent_id = coder_agent.dev.id
|
2023-10-03 05:55:25 +00:00
|
|
|
folder = local.repo_dir
|
chore(dogfood): use coder modules in dogfood (#9890)
updates dogfood to use coder modules
---
<details open="true"><summary>Generated summary (powered by <a href="https://app.graphite.dev">Graphite</a>)</summary>
> # TL;DR
> This pull request removes the `dotfiles_url` and `jetbrains_ide` parameters, and the related code from the `main.tf` file. It also adds several new modules for `dotfiles`, `git-clone`, `personalize`, `code-server`, `jetbrains_gateway`, `vscode`, and `filebrowser`. The `startup_script` has been updated to remove the installation and launch of `filebrowser` and the `dotfiles` related code.
>
> # What changed
> - Removed `dotfiles_url` and `jetbrains_ide` parameters.
> - Removed related code for `dotfiles_url` and `jetbrains_ide`.
> - Added new modules for `dotfiles`, `git-clone`, `personalize`, `code-server`, `jetbrains_gateway`, `vscode`, and `filebrowser`.
> - Updated `startup_script` to remove the installation and launch of `filebrowser` and the `dotfiles` related code.
>
> # How to test
> 1. Go to https://dev.coder.com/templates/coder/versions/dazzling_hugle0 and create a new workspace or change your dogfood workspace version to `dazzling_hugle0` .
> 2. Verify that the new modules are working as expected.
>
> # Why make this change
> The `dotfiles_url` and `jetbrains_ide` parameters and related code were removed to simplify the configuration and make it easier to manage. The new modules were added to provide additional functionality and improve the overall user experience. The `startup_script` was updated to reflect these changes.
</details>
2023-09-30 19:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module "jetbrains_gateway" {
|
2023-10-03 07:11:58 +00:00
|
|
|
source = "https://registry.coder.com/modules/jetbrains-gateway"
|
|
|
|
agent_id = coder_agent.dev.id
|
|
|
|
agent_name = "dev"
|
|
|
|
folder = local.repo_dir
|
|
|
|
jetbrains_ides = ["GO", "WS"]
|
|
|
|
default = "GO"
|
chore(dogfood): use coder modules in dogfood (#9890)
updates dogfood to use coder modules
---
<details open="true"><summary>Generated summary (powered by <a href="https://app.graphite.dev">Graphite</a>)</summary>
> # TL;DR
> This pull request removes the `dotfiles_url` and `jetbrains_ide` parameters, and the related code from the `main.tf` file. It also adds several new modules for `dotfiles`, `git-clone`, `personalize`, `code-server`, `jetbrains_gateway`, `vscode`, and `filebrowser`. The `startup_script` has been updated to remove the installation and launch of `filebrowser` and the `dotfiles` related code.
>
> # What changed
> - Removed `dotfiles_url` and `jetbrains_ide` parameters.
> - Removed related code for `dotfiles_url` and `jetbrains_ide`.
> - Added new modules for `dotfiles`, `git-clone`, `personalize`, `code-server`, `jetbrains_gateway`, `vscode`, and `filebrowser`.
> - Updated `startup_script` to remove the installation and launch of `filebrowser` and the `dotfiles` related code.
>
> # How to test
> 1. Go to https://dev.coder.com/templates/coder/versions/dazzling_hugle0 and create a new workspace or change your dogfood workspace version to `dazzling_hugle0` .
> 2. Verify that the new modules are working as expected.
>
> # Why make this change
> The `dotfiles_url` and `jetbrains_ide` parameters and related code were removed to simplify the configuration and make it easier to manage. The new modules were added to provide additional functionality and improve the overall user experience. The `startup_script` was updated to reflect these changes.
</details>
2023-09-30 19:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module "vscode-desktop" {
|
|
|
|
source = "https://registry.coder.com/modules/vscode-desktop"
|
|
|
|
agent_id = coder_agent.dev.id
|
2023-10-03 05:55:25 +00:00
|
|
|
folder = local.repo_dir
|
chore(dogfood): use coder modules in dogfood (#9890)
updates dogfood to use coder modules
---
<details open="true"><summary>Generated summary (powered by <a href="https://app.graphite.dev">Graphite</a>)</summary>
> # TL;DR
> This pull request removes the `dotfiles_url` and `jetbrains_ide` parameters, and the related code from the `main.tf` file. It also adds several new modules for `dotfiles`, `git-clone`, `personalize`, `code-server`, `jetbrains_gateway`, `vscode`, and `filebrowser`. The `startup_script` has been updated to remove the installation and launch of `filebrowser` and the `dotfiles` related code.
>
> # What changed
> - Removed `dotfiles_url` and `jetbrains_ide` parameters.
> - Removed related code for `dotfiles_url` and `jetbrains_ide`.
> - Added new modules for `dotfiles`, `git-clone`, `personalize`, `code-server`, `jetbrains_gateway`, `vscode`, and `filebrowser`.
> - Updated `startup_script` to remove the installation and launch of `filebrowser` and the `dotfiles` related code.
>
> # How to test
> 1. Go to https://dev.coder.com/templates/coder/versions/dazzling_hugle0 and create a new workspace or change your dogfood workspace version to `dazzling_hugle0` .
> 2. Verify that the new modules are working as expected.
>
> # Why make this change
> The `dotfiles_url` and `jetbrains_ide` parameters and related code were removed to simplify the configuration and make it easier to manage. The new modules were added to provide additional functionality and improve the overall user experience. The `startup_script` was updated to reflect these changes.
</details>
2023-09-30 19:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module "filebrowser" {
|
|
|
|
source = "https://registry.coder.com/modules/filebrowser"
|
|
|
|
agent_id = coder_agent.dev.id
|
|
|
|
}
|
|
|
|
|
|
|
|
module "coder-login" {
|
|
|
|
source = "https://registry.coder.com/modules/coder-login"
|
|
|
|
agent_id = coder_agent.dev.id
|
|
|
|
}
|
|
|
|
|
2022-08-02 20:20:54 +00:00
|
|
|
resource "coder_agent" "dev" {
|
2023-01-27 21:01:48 +00:00
|
|
|
arch = "amd64"
|
|
|
|
os = "linux"
|
2023-07-18 14:04:00 +00:00
|
|
|
dir = data.coder_parameter.repo_dir.value
|
2023-05-13 12:42:10 +00:00
|
|
|
env = {
|
2023-10-12 07:30:00 +00:00
|
|
|
GITHUB_TOKEN : data.coder_external_auth.github.access_token,
|
2023-05-13 12:42:10 +00:00
|
|
|
OIDC_TOKEN : data.coder_workspace.me.owner_oidc_access_token,
|
|
|
|
}
|
2023-06-06 08:58:07 +00:00
|
|
|
startup_script_behavior = "blocking"
|
2023-05-13 12:42:10 +00:00
|
|
|
|
chore(dogfood): use coder modules in dogfood (#9890)
updates dogfood to use coder modules
---
<details open="true"><summary>Generated summary (powered by <a href="https://app.graphite.dev">Graphite</a>)</summary>
> # TL;DR
> This pull request removes the `dotfiles_url` and `jetbrains_ide` parameters, and the related code from the `main.tf` file. It also adds several new modules for `dotfiles`, `git-clone`, `personalize`, `code-server`, `jetbrains_gateway`, `vscode`, and `filebrowser`. The `startup_script` has been updated to remove the installation and launch of `filebrowser` and the `dotfiles` related code.
>
> # What changed
> - Removed `dotfiles_url` and `jetbrains_ide` parameters.
> - Removed related code for `dotfiles_url` and `jetbrains_ide`.
> - Added new modules for `dotfiles`, `git-clone`, `personalize`, `code-server`, `jetbrains_gateway`, `vscode`, and `filebrowser`.
> - Updated `startup_script` to remove the installation and launch of `filebrowser` and the `dotfiles` related code.
>
> # How to test
> 1. Go to https://dev.coder.com/templates/coder/versions/dazzling_hugle0 and create a new workspace or change your dogfood workspace version to `dazzling_hugle0` .
> 2. Verify that the new modules are working as expected.
>
> # Why make this change
> The `dotfiles_url` and `jetbrains_ide` parameters and related code were removed to simplify the configuration and make it easier to manage. The new modules were added to provide additional functionality and improve the overall user experience. The `startup_script` was updated to reflect these changes.
</details>
2023-09-30 19:22:14 +00:00
|
|
|
display_apps {
|
|
|
|
vscode = false
|
|
|
|
}
|
|
|
|
|
2023-06-20 09:16:57 +00:00
|
|
|
# The following metadata blocks are optional. They are used to display
|
|
|
|
# information about your workspace in the dashboard. You can remove them
|
|
|
|
# if you don't want to display any information.
|
2023-05-13 12:42:10 +00:00
|
|
|
metadata {
|
|
|
|
display_name = "CPU Usage"
|
2023-06-20 09:16:57 +00:00
|
|
|
key = "0_cpu_usage"
|
|
|
|
script = "coder stat cpu"
|
2023-05-19 12:15:48 +00:00
|
|
|
interval = 10
|
2023-05-13 12:42:10 +00:00
|
|
|
timeout = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
metadata {
|
2023-05-19 12:15:48 +00:00
|
|
|
display_name = "RAM Usage"
|
2023-06-20 09:16:57 +00:00
|
|
|
key = "1_ram_usage"
|
|
|
|
script = "coder stat mem"
|
2023-05-19 12:15:48 +00:00
|
|
|
interval = 10
|
2023-05-13 12:42:10 +00:00
|
|
|
timeout = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
metadata {
|
2023-05-19 12:15:48 +00:00
|
|
|
display_name = "CPU Usage (Host)"
|
2023-06-20 09:16:57 +00:00
|
|
|
key = "2_cpu_usage_host"
|
|
|
|
script = "coder stat cpu --host"
|
2023-05-19 12:15:48 +00:00
|
|
|
interval = 10
|
2023-05-13 12:42:10 +00:00
|
|
|
timeout = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
metadata {
|
2023-06-20 09:16:57 +00:00
|
|
|
display_name = "RAM Usage (Host)"
|
|
|
|
key = "3_ram_usage_host"
|
|
|
|
script = "coder stat mem --host"
|
|
|
|
interval = 10
|
|
|
|
timeout = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
metadata {
|
|
|
|
display_name = "Swap Usage (Host)"
|
|
|
|
key = "4_swap_usage_host"
|
2023-05-13 12:42:10 +00:00
|
|
|
script = <<EOT
|
2023-10-09 15:57:57 +00:00
|
|
|
#!/bin/bash
|
2023-06-20 09:16:57 +00:00
|
|
|
echo "$(free -b | awk '/^Swap/ { printf("%.1f/%.1f", $3/1024.0/1024.0/1024.0, $2/1024.0/1024.0/1024.0) }') GiB"
|
|
|
|
EOT
|
2023-05-19 12:15:48 +00:00
|
|
|
interval = 10
|
2023-05-13 12:42:10 +00:00
|
|
|
timeout = 1
|
|
|
|
}
|
|
|
|
|
2023-05-19 12:15:48 +00:00
|
|
|
metadata {
|
|
|
|
display_name = "Load Average (Host)"
|
2023-06-20 09:16:57 +00:00
|
|
|
key = "5_load_host"
|
2023-05-19 12:15:48 +00:00
|
|
|
# get load avg scaled by number of cores
|
|
|
|
script = <<EOT
|
2023-10-09 15:57:57 +00:00
|
|
|
#!/bin/bash
|
2023-05-19 12:15:48 +00:00
|
|
|
echo "`cat /proc/loadavg | awk '{ print $1 }'` `nproc`" | awk '{ printf "%0.2f", $1/$2 }'
|
|
|
|
EOT
|
2023-06-20 09:16:57 +00:00
|
|
|
interval = 60
|
2023-05-19 12:15:48 +00:00
|
|
|
timeout = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
metadata {
|
|
|
|
display_name = "Disk Usage (Host)"
|
2023-06-20 09:16:57 +00:00
|
|
|
key = "6_disk_host"
|
|
|
|
script = "coder stat disk --path /"
|
2023-05-19 12:15:48 +00:00
|
|
|
interval = 600
|
2023-06-20 09:16:57 +00:00
|
|
|
timeout = 10
|
2023-05-19 12:15:48 +00:00
|
|
|
}
|
2023-05-13 12:42:10 +00:00
|
|
|
|
|
|
|
metadata {
|
|
|
|
display_name = "Word of the Day"
|
2023-06-20 09:16:57 +00:00
|
|
|
key = "7_word"
|
2023-05-13 12:42:10 +00:00
|
|
|
script = <<EOT
|
2023-10-09 15:57:57 +00:00
|
|
|
#!/bin/bash
|
2023-05-19 12:15:48 +00:00
|
|
|
curl -o - --silent https://www.merriam-webster.com/word-of-the-day 2>&1 | awk ' $0 ~ "Word of the Day: [A-z]+" { print $5; exit }'
|
|
|
|
EOT
|
|
|
|
interval = 86400
|
2023-05-13 12:42:10 +00:00
|
|
|
timeout = 5
|
|
|
|
}
|
|
|
|
|
2023-01-27 21:01:48 +00:00
|
|
|
startup_script_timeout = 60
|
|
|
|
startup_script = <<-EOT
|
chore(dogfood): use coder modules in dogfood (#9890)
updates dogfood to use coder modules
---
<details open="true"><summary>Generated summary (powered by <a href="https://app.graphite.dev">Graphite</a>)</summary>
> # TL;DR
> This pull request removes the `dotfiles_url` and `jetbrains_ide` parameters, and the related code from the `main.tf` file. It also adds several new modules for `dotfiles`, `git-clone`, `personalize`, `code-server`, `jetbrains_gateway`, `vscode`, and `filebrowser`. The `startup_script` has been updated to remove the installation and launch of `filebrowser` and the `dotfiles` related code.
>
> # What changed
> - Removed `dotfiles_url` and `jetbrains_ide` parameters.
> - Removed related code for `dotfiles_url` and `jetbrains_ide`.
> - Added new modules for `dotfiles`, `git-clone`, `personalize`, `code-server`, `jetbrains_gateway`, `vscode`, and `filebrowser`.
> - Updated `startup_script` to remove the installation and launch of `filebrowser` and the `dotfiles` related code.
>
> # How to test
> 1. Go to https://dev.coder.com/templates/coder/versions/dazzling_hugle0 and create a new workspace or change your dogfood workspace version to `dazzling_hugle0` .
> 2. Verify that the new modules are working as expected.
>
> # Why make this change
> The `dotfiles_url` and `jetbrains_ide` parameters and related code were removed to simplify the configuration and make it easier to manage. The new modules were added to provide additional functionality and improve the overall user experience. The `startup_script` was updated to reflect these changes.
</details>
2023-09-30 19:22:14 +00:00
|
|
|
set -eux -o pipefail
|
2022-07-18 22:44:09 +00:00
|
|
|
sudo service docker start
|
2023-01-27 21:01:48 +00:00
|
|
|
EOT
|
2022-07-18 22:44:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "docker_volume" "home_volume" {
|
2022-11-09 14:18:19 +00:00
|
|
|
name = "coder-${data.coder_workspace.me.id}-home"
|
|
|
|
# Protect the volume from being deleted due to changes in attributes.
|
2022-10-24 19:59:27 +00:00
|
|
|
lifecycle {
|
|
|
|
ignore_changes = all
|
|
|
|
}
|
2022-11-09 14:18:19 +00:00
|
|
|
# Add labels in Docker to keep track of orphan resources.
|
|
|
|
labels {
|
|
|
|
label = "coder.owner"
|
|
|
|
value = data.coder_workspace.me.owner
|
|
|
|
}
|
|
|
|
labels {
|
|
|
|
label = "coder.owner_id"
|
|
|
|
value = data.coder_workspace.me.owner_id
|
|
|
|
}
|
|
|
|
labels {
|
|
|
|
label = "coder.workspace_id"
|
|
|
|
value = data.coder_workspace.me.id
|
|
|
|
}
|
|
|
|
# This field becomes outdated if the workspace is renamed but can
|
|
|
|
# be useful for debugging or cleaning out dangling volumes.
|
|
|
|
labels {
|
|
|
|
label = "coder.workspace_name_at_creation"
|
|
|
|
value = data.coder_workspace.me.name
|
|
|
|
}
|
2022-07-18 22:44:09 +00:00
|
|
|
}
|
|
|
|
|
2022-09-05 19:23:52 +00:00
|
|
|
locals {
|
|
|
|
container_name = "coder-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}"
|
2022-10-20 03:06:57 +00:00
|
|
|
registry_name = "codercom/oss-dogfood"
|
|
|
|
}
|
|
|
|
data "docker_registry_image" "dogfood" {
|
2023-12-05 09:02:57 +00:00
|
|
|
name = "${local.registry_name}:latest"
|
2022-09-05 19:23:52 +00:00
|
|
|
}
|
|
|
|
|
2022-09-04 21:06:36 +00:00
|
|
|
resource "docker_image" "dogfood" {
|
2022-10-20 03:06:57 +00:00
|
|
|
name = "${local.registry_name}@${data.docker_registry_image.dogfood.sha256_digest}"
|
|
|
|
pull_triggers = [
|
2023-12-05 09:02:57 +00:00
|
|
|
data.docker_registry_image.dogfood.sha256_digest,
|
|
|
|
sha1(join("", [for f in fileset(path.module, "files/*") : filesha1(f)])),
|
|
|
|
filesha1("Dockerfile"),
|
2022-10-20 03:06:57 +00:00
|
|
|
]
|
|
|
|
keep_locally = true
|
2022-09-04 21:06:36 +00:00
|
|
|
}
|
2022-08-09 23:40:12 +00:00
|
|
|
|
2022-07-18 22:44:09 +00:00
|
|
|
resource "docker_container" "workspace" {
|
|
|
|
count = data.coder_workspace.me.start_count
|
2022-09-04 21:06:36 +00:00
|
|
|
image = docker_image.dogfood.name
|
2022-11-08 16:52:19 +00:00
|
|
|
name = local.container_name
|
2022-07-18 22:44:09 +00:00
|
|
|
# Hostname makes the shell more user friendly: coder@my-workspace:~$
|
2023-05-13 12:42:10 +00:00
|
|
|
hostname = data.coder_workspace.me.name
|
|
|
|
# Use the docker gateway if the access URL is 127.0.0.1
|
2023-04-25 04:58:09 +00:00
|
|
|
entrypoint = ["sh", "-c", coder_agent.dev.init_script]
|
2022-07-18 22:44:09 +00:00
|
|
|
# CPU limits are unnecessary since Docker will load balance automatically
|
2023-07-11 20:24:29 +00:00
|
|
|
memory = data.coder_workspace.me.owner == "code-asher" ? 65536 : 32768
|
2022-07-18 22:44:09 +00:00
|
|
|
runtime = "sysbox-runc"
|
2022-12-09 11:00:39 +00:00
|
|
|
env = [
|
2022-12-07 21:59:32 +00:00
|
|
|
"CODER_AGENT_TOKEN=${coder_agent.dev.token}",
|
2023-10-03 22:34:29 +00:00
|
|
|
"USE_CAP_NET_ADMIN=true",
|
2022-12-07 21:59:32 +00:00
|
|
|
]
|
2022-07-18 22:44:09 +00:00
|
|
|
host {
|
|
|
|
host = "host.docker.internal"
|
|
|
|
ip = "host-gateway"
|
|
|
|
}
|
|
|
|
volumes {
|
|
|
|
container_path = "/home/coder/"
|
|
|
|
volume_name = docker_volume.home_volume.name
|
|
|
|
read_only = false
|
|
|
|
}
|
2023-10-03 22:34:29 +00:00
|
|
|
capabilities {
|
|
|
|
add = ["CAP_NET_ADMIN", "CAP_SYS_NICE"]
|
|
|
|
}
|
2022-11-09 14:18:19 +00:00
|
|
|
# Add labels in Docker to keep track of orphan resources.
|
|
|
|
labels {
|
|
|
|
label = "coder.owner"
|
|
|
|
value = data.coder_workspace.me.owner
|
|
|
|
}
|
|
|
|
labels {
|
|
|
|
label = "coder.owner_id"
|
|
|
|
value = data.coder_workspace.me.owner_id
|
|
|
|
}
|
|
|
|
labels {
|
|
|
|
label = "coder.workspace_id"
|
|
|
|
value = data.coder_workspace.me.id
|
|
|
|
}
|
|
|
|
labels {
|
|
|
|
label = "coder.workspace_name"
|
|
|
|
value = data.coder_workspace.me.name
|
|
|
|
}
|
2022-07-18 22:44:09 +00:00
|
|
|
}
|
2022-08-09 23:40:12 +00:00
|
|
|
|
|
|
|
resource "coder_metadata" "container_info" {
|
2022-09-04 21:06:36 +00:00
|
|
|
count = data.coder_workspace.me.start_count
|
2022-08-09 23:40:12 +00:00
|
|
|
resource_id = docker_container.workspace[0].id
|
|
|
|
item {
|
2022-09-04 21:06:36 +00:00
|
|
|
key = "memory"
|
2022-08-09 23:40:12 +00:00
|
|
|
value = docker_container.workspace[0].memory
|
|
|
|
}
|
|
|
|
item {
|
2022-09-04 21:06:36 +00:00
|
|
|
key = "runtime"
|
2022-08-09 23:40:12 +00:00
|
|
|
value = docker_container.workspace[0].runtime
|
|
|
|
}
|
2023-08-26 22:22:28 +00:00
|
|
|
item {
|
|
|
|
key = "region"
|
|
|
|
value = data.coder_parameter.region.option[index(data.coder_parameter.region.option.*.value, data.coder_parameter.region.value)].name
|
|
|
|
}
|
2022-08-09 23:40:12 +00:00
|
|
|
}
|