updated the storage source naming convention in a coder template

This commit is contained in:
hyung-hwan 2022-11-08 21:15:58 +09:00
parent 387b12e541
commit 6fc304d2cd

View File

@ -21,7 +21,11 @@ data "coder_workspace" "me" {
} }
locals { locals {
workspace_name = "${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}" dcw_owner = replace(replace("${data.coder_workspace.me.owner}", "~", "~~"), "-", "~-")
dcw_name = replace(replace("${data.coder_workspace.me.name}", "~", "~~"), "-", "~-")
##workspace_name = "${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
workspace_name = "${local.dcw_owner}-${local.dcw_name}"
## this points to the workspace parent directory accessible from the docker host. ## this points to the workspace parent directory accessible from the docker host.
workspace_dir = "/home/gfs-data/coder/workspace/${local.workspace_name}" workspace_dir = "/home/gfs-data/coder/workspace/${local.workspace_name}"
@ -32,6 +36,7 @@ locals {
} }
resource "null_resource" "workspace" { resource "null_resource" "workspace" {
count = 1
triggers = { triggers = {
dir = local.server_workspace_dir dir = local.server_workspace_dir
@ -87,12 +92,12 @@ resource "docker_service" "workspace" {
##depends_on = [local_file.workspace] ##depends_on = [local_file.workspace]
depends_on = [null_resource.workspace] depends_on = [null_resource.workspace]
##count = data.coder_workspace.me.start_count count = data.coder_workspace.me.start_count
name = "coder-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}" name = "coder-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}"
task_spec { task_spec {
container_spec { container_spec {
image = "codercom/code-server:latest" image = "codercom/code-server:4.8.3"
hostname = lower(data.coder_workspace.me.name) hostname = lower(data.coder_workspace.me.name)
command = ["sh"] command = ["sh"]
##args = ["-c", replace(coder_agent.main.init_script, "/localhost|127\\.0\\.0\\.1/", "host.docker.internal")] ##args = ["-c", replace(coder_agent.main.init_script, "/localhost|127\\.0\\.0\\.1/", "host.docker.internal")]