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

This commit is contained in:
Peter 2023-06-17 11:42:23 +02:00
parent 3000812b15
commit b81e97116f
Signed by: prskr
GPG key ID: C1DB5D2E8DB512F9
2 changed files with 53 additions and 12 deletions

View file

@ -43,6 +43,28 @@ write_files:
permissions: "0644" permissions: "0644"
content: | content: |
export DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock export DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock
%{ endif ~}
%{ if remote_ide_setup == "fleet" ~}
- path: /etc/systemd/system/fleet.service
permissions: "0644"
content: |
[Unit]
Description=Fleet
After=network-online.target
Wants=network-online.target
[Service]
User=${username}
ExecStart=/usr/local/bin/fleet launch workspace --version 1.19.111 -- --auth=accept-everyone --enableSmartMode --workspacePort 3500
Restart=always
RestartSec=10
TimeoutStopSec=90
KillMode=process
SyslogIdentifier=fleet
[Install]
WantedBy=multi-user.target
%{ endif ~} %{ endif ~}
- path: /etc/systemd/system/coder-agent.service - path: /etc/systemd/system/coder-agent.service
permissions: "0644" permissions: "0644"
@ -66,7 +88,7 @@ write_files:
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
%{ if code_server_setup ~} %{ if remote_ide_setup == "code_server" ~}
- path: /home/${username}/.config/code-server/config.yaml - path: /home/${username}/.config/code-server/config.yaml
permissions: "0644" permissions: "0644"
content: | content: |
@ -84,8 +106,11 @@ runcmd:
- chown -R ${username}:${username} /home/${username} - chown -R ${username}:${username} /home/${username}
- sudo -u ${username} DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus" systemctl --user start podman - sudo -u ${username} DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus" systemctl --user start podman
%{ endif ~} %{ endif ~}
%{ if code_server_setup ~} %{ if remote_ide_setup == "code_server" ~}
- dnf install -y $(curl -sL https://api.github.com/repos/coder/code-server/releases/latest | jq -r '.assets[].browser_download_url' | grep "amd64.rpm") - dnf install -y $(curl -sL https://api.github.com/repos/coder/code-server/releases/latest | jq -r '.assets[].browser_download_url' | grep "amd64.rpm")
- systemctl enable --now code-server@${username} - systemctl enable --now code-server@${username}
%{ endif }
%{ if remote_ide_setup == "fleet" ~}
- systemctl enable --now fleet
%{ endif } %{ endif }
- chown -R ${username}:${username} /home/${username} - chown -R ${username}:${username} /home/${username}

View file

@ -177,21 +177,27 @@ data "coder_parameter" "volume_size" {
} }
} }
data "coder_parameter" "code_server" { data "coder_parameter" "remote_ide" {
name = "install_code_server" name = "install_remote_ide"
description = "Should Code Server be installed?" description = "Which remote IDE should be installed"
default = "true" default = "code_server"
type = "string" type = "string"
mutable = true mutable = true
option { option {
name = "Install" name = "None"
value = "true" value = "none"
} }
option { option {
name = "Don't install" name = "Code server"
value = "false" value = "code_server"
}
option {
name = "Jetbrains Fleet"
value = "fleet"
} }
} }
@ -228,7 +234,7 @@ resource "coder_agent" "dev" {
resource "coder_app" "code-server" { resource "coder_app" "code-server" {
display_name = "code-server" display_name = "code-server"
count = data.coder_parameter.code_server.value ? 1 : 0 count = data.coder_parameter.remote_ide.value == "code_server" ? 1 : 0
agent_id = coder_agent.dev.id agent_id = coder_agent.dev.id
slug = "code-server" slug = "code-server"
icon = "/icon/code.svg" icon = "/icon/code.svg"
@ -236,6 +242,16 @@ resource "coder_app" "code-server" {
subdomain = var.use_subdomain subdomain = var.use_subdomain
} }
resource "coder_app" "fleet" {
display_name = "Jetbrains Fleet"
count = data.coder_parameter.remote_ide.value == "fleet" ? 1 : 0
agent_id = coder_agent.dev.id
slug = "fleet"
icon = "/icon/code.svg"
url = "http://localhost:3500"
subdomain = var.use_subdomain
}
# Generate a dummy ssh key that is not accessible so Hetzner cloud does not spam the admin with emails. # Generate a dummy ssh key that is not accessible so Hetzner cloud does not spam the admin with emails.
resource "tls_private_key" "rsa_4096" { resource "tls_private_key" "rsa_4096" {
algorithm = "RSA" algorithm = "RSA"
@ -260,7 +276,7 @@ resource "hcloud_server" "root" {
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 remote_ide_setup = data.coder_parameter.remote_ide.value
install_podman_setup = data.coder_parameter.install_podman.value install_podman_setup = data.coder_parameter.install_podman.value
user_shell = data.coder_parameter.user_shell.value user_shell = data.coder_parameter.user_shell.value
}) })