feat: add dotfiles support
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Peter 2023-06-15 22:02:08 +02:00
parent 0cf60f2942
commit afd4540dc7
Signed by: prskr
GPG key ID: C1DB5D2E8DB512F9

View file

@ -44,6 +44,19 @@ variable "private_network_id" {
default = "" default = ""
} }
data "coder_parameter" "dotfiles_uri" {
name = "dotfiles_uri"
display_name = "Dotfiles URI"
description = <<-EOF
Dotfiles repo URI (optional)
see https://dotfiles.github.io
EOF
default = ""
mutable = true
}
data "coder_parameter" "instance_location" { data "coder_parameter" "instance_location" {
name = "instance_location" name = "instance_location"
display_name = "Instance location" display_name = "Instance location"
@ -251,6 +264,12 @@ data "coder_workspace" "me" {
resource "coder_agent" "dev" { resource "coder_agent" "dev" {
arch = "amd64" arch = "amd64"
os = "linux" os = "linux"
startup_script = data.coder_parameter.dotfiles_uri.value != "" ? "coder dotfiles -y ${data.coder_parameter.dotfiles_uri.value}" : null
env = {
DOCKER_HOST= data.coder_parameter.install_podman.value == "true" ? "unix:///run/user/1000/podman/podman.sock" : "unix:///var/run/docker.sock"
}
} }
resource "coder_app" "code-server" { resource "coder_app" "code-server" {
@ -283,14 +302,14 @@ resource "hcloud_server" "root" {
ssh_keys = [hcloud_ssh_key.root.id] ssh_keys = [hcloud_ssh_key.root.id]
user_data = templatefile("cloud-config.yaml.tftpl", { user_data = templatefile("cloud-config.yaml.tftpl", {
username = data.coder_workspace.me.owner username = data.coder_workspace.me.owner
volume_path = "/dev/disk/by-id/scsi-0HC_Volume_${hcloud_volume.root.id}" volume_path = "/dev/disk/by-id/scsi-0HC_Volume_${hcloud_volume.root.id}"
init_script = base64encode(coder_agent.dev.init_script) init_script = base64encode(coder_agent.dev.init_script)
coder_agent_token = coder_agent.dev.token coder_agent_token = coder_agent.dev.token
code_server_setup = data.coder_parameter.code_server.value code_server_setup = data.coder_parameter.code_server.value
install_go_setup = data.coder_parameter.install_go.value install_go_setup = data.coder_parameter.install_go.value
install_dotnet_setup = data.coder_parameter.install_dotnet.value install_dotnet_setup = data.coder_parameter.install_dotnet.value
install_podman_setup = data.coder_parameter.install_podman.value install_podman_setup = data.coder_parameter.install_podman.value
install_terraform_setup = data.coder_parameter.install_terraform.value install_terraform_setup = data.coder_parameter.install_terraform.value
}) })