- Notifications
You must be signed in to change notification settings - Fork928
Closed
Description
Here is the template I tried
terraform {required_providers {coder={ source="coder/coder" version="~> 0.7.0" }docker={ source="kreuzwerker/docker" version="~> 3.0.1" } }}locals {username=data.coder_workspace.me.owner}data"coder_provisioner""me" {}provider"docker" {}data"coder_workspace""me" {}data"coder_parameter""large" {type="string"name="idk"default="beans"}data"coder_parameter""large2" {type="string"name="idk2"default="beans"}data"coder_parameter""large3" {type="string"name="idk3"default="beans"}data"coder_parameter""large4" {type="string"name="idk4"default="beans default value"}data"coder_parameter""large5" {type="string"name="idk5"default="whatttt"}data"coder_parameter""large6" {type="string"name="idk6"default="whatttt2"}data"coder_parameter""large7" {type="string"name="idk6"default="whatttt2"}resource"coder_agent""main" {arch=data.coder_provisioner.me.archos="linux"login_before_ready=falsestartup_script_timeout=180startup_script=<<-EOT set -e # install and start code-server curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.11.0 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT# These environment variables allow you to make Git commits right away after creating a# workspace. Note that they take precedence over configuration defined in ~/.gitconfig!# You can remove this block if you'd prefer to configure Git manually or using# dotfiles. (see docs/dotfiles.md)env={ GIT_AUTHOR_NAME="${data.coder_workspace.me.owner}" GIT_COMMITTER_NAME="${data.coder_workspace.me.owner}" GIT_AUTHOR_EMAIL="${data.coder_workspace.me.owner_email}" GIT_COMMITTER_EMAIL="${data.coder_workspace.me.owner_email}" }}resource"coder_app""code-server" {agent_id=coder_agent.main.idslug="code-server"display_name="code-server"url="http://localhost:13337/?folder=/home/${local.username}"icon="/icon/code.svg"subdomain=falseshare="owner"healthcheck {url="http://localhost:13337/healthz"interval=5threshold=6 }}resource"docker_volume""home_volume" {name="coder-${data.coder_workspace.me.id}-home"# Protect the volume from being deleted due to changes in attributes.lifecycle {ignore_changes=all }# 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 }}resource"docker_image""main" {name="coder-${data.coder_workspace.me.id}"build {context="./build"build_args={ USER= local.username } }triggers={ dir_sha1=sha1(join("", [forfinfileset(path.module,"build/*"):filesha1(f)])) }}resource"coder_metadata""editor" {resource_id=docker_volume.home_volume.iditem {key="ikd"value=data.coder_parameter.large7.value }}resource"docker_container""workspace" {count=data.coder_workspace.me.start_countimage=docker_image.main.name# Uses lower() to avoid Docker restriction on container names.name="coder-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}"# Hostname makes the shell more user friendly: coder@my-workspace:~$hostname=data.coder_workspace.me.name# Use the docker gateway if the access URL is 127.0.0.1entrypoint=["sh","-c",replace(coder_agent.main.init_script,"/localhost|127\\.0\\.0\\.1/","host.docker.internal")]env=["CODER_AGENT_TOKEN=${coder_agent.main.token}"]host {host="host.docker.internal"ip="host-gateway" }volumes {container_path="/home/${local.username}"volume_name=docker_volume.home_volume.nameread_only=false }# 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 }}
I am seeing this in both the template editor and CLI.
From server logs:
[API]"error": insert parameter: pq: duplicate key value violates unique constraint"template_version_parameters_template_version_id_name_key"[API] storj.io/drpc/drpcwire.UnmarshalError:26[API] storj.io/drpc/drpcstream.(*Stream).HandlePacket:198[API] storj.io/drpc/drpcmanager.(*Manager).manageReader:216