Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4ed8d43

Browse files
committed
chore(docker-android): update and add adb-tools module
1 parent b149d4c commit 4ed8d43

File tree

6 files changed

+96
-5
lines changed

6 files changed

+96
-5
lines changed

docker-android/main.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ resource "docker_volume" "home_volume" {
133133

134134
resource "docker_container" "workspace" {
135135
count = data.coder_workspace.me.start_count
136-
image = "ghcr.io/phorcys420/coder-templates/docker-android-env"
136+
image = "ghcr.io/phorcys420/coder-templates/docker-android-env@sha256:35e00111ab49985c68635b6df75d786327d59ba4566124b2b9066a798464c9f4"
137137
# Uses lower() to avoid Docker restriction on container names.
138138
name = "coder-${lower(data.coder_workspace_owner.me.name)}-${lower(data.coder_workspace.me.name)}"
139139
# Hostname makes the shell more user friendly: coder@my-workspace:~$
@@ -231,3 +231,11 @@ module "novnc" {
231231

232232
agent_id = coder_agent.main.id
233233
}
234+
235+
module "adb-tools" {
236+
count = data.coder_workspace.me.start_count
237+
238+
source = "./modules/adb-tools"
239+
240+
agent_id = coder_agent.main.id
241+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
terraform {
2+
required_providers {
3+
coder = {
4+
source = "coder/coder"
5+
version = "~> 2.8.0"
6+
}
7+
}
8+
}
9+
10+
variable "agent_id" {
11+
type = string
12+
description = "The ID of a Coder agent."
13+
}
14+
15+
variable "listen_host" {
16+
type = string
17+
description = "The host adb-tools should be listening on."
18+
default = "localhost:15555"
19+
}
20+
21+
variable "host_to_proxy" {
22+
type = string
23+
description = "The ADB server websockify should be proxying."
24+
default = "localhost:5555"
25+
}
26+
27+
resource "coder_script" "novnc" {
28+
agent_id = var.agent_id
29+
display_name = "adb-tools"
30+
icon = "/icon/widgets.svg"
31+
32+
script = templatefile("${path.module}/run.sh", {
33+
WEB_SERVER_LISTEN_HOST = var.listen_host,
34+
ADB_SERVER_HOST = var.host_to_proxy
35+
})
36+
37+
run_on_start = true
38+
}
39+
40+
resource "coder_app" "adb-tools" {
41+
agent_id = var.agent_id
42+
43+
display_name = "adb-tools"
44+
slug = "adb-tools"
45+
icon = "/emojis/1f4f1.png"
46+
47+
url = "http://${var.listen_host}"
48+
49+
group = "adb-tools"
50+
subdomain = true
51+
52+
order = 4
53+
54+
healthcheck {
55+
url = "http://${var.listen_host}/"
56+
interval = 5
57+
threshold = 6
58+
}
59+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
# Injected by terraform through templatefile()
4+
WEB_SERVER_LISTEN_HOST='${WEB_SERVER_LISTEN_HOST}'
5+
ADB_SERVER_HOST='${ADB_SERVER_HOST}'
6+
7+
STATIC_SITE_PATH="/tmp/adb-tools-static-site"
8+
9+
#echo "[adb-tools] Installing websockify"
10+
#sudo apt-get update -y
11+
#sudo apt-get install -y websockify
12+
13+
echo "[adb-tools] Downloading frontend"
14+
wget https://nightly.link/phorcys420/adb-tools/workflows/deploy/main/adb-tools-static-site.zip
15+
unzip adb-tools-static-site.zip -d "$STATIC_SITE_PATH"
16+
17+
# TODO: remove this once we support coder_script ordering
18+
sleep 20
19+
20+
echo "[adb-tools] Starting websockify"
21+
websockify "$WEB_SERVER_LISTEN_HOST" "$ADB_SERVER_HOST" --web "$STATIC_SITE_PATH" >/tmp/adb-tools-websockify.log 2>&1 &

docker-android/modules/droidvnc/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ resource "coder_app" "novnc2" {
4343
threshold = 6
4444
}
4545

46-
order = 4
46+
order = 5
4747
}

docker-android/modules/novnc/main.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,12 @@ resource "coder_app" "novnc" {
6969

7070
url = "http://${var.listen_host}/${var.coder_app_uri_parameters}"
7171

72-
# TODO: make variable for those
73-
share = var.coder_app_share
74-
72+
# TODO: make variable for these
73+
share = var.coder_app_share
7574
order = 3
7675

76+
subdomain = true
77+
7778
healthcheck {
7879
url = "http://${var.listen_host}/"
7980
interval = 5

docker-android/modules/novnc/run.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
NOVNC_LISTEN_HOST='${NOVNC_LISTEN_HOST}'
55
NOVNC_HOST_TO_PROXY='${NOVNC_HOST_TO_PROXY}'
66

7+
# TODO: support a noVNC repo already being present
8+
# TODO: move to git-clone module once coder_script ordering is supported
79
echo "[noVNC] Installing noVNC"
810
sudo apt-get update -y
911
sudo apt-get install -y websockify && git clone https://github.com/novnc/noVNC && mv noVNC/vnc.html noVNC/index.html

0 commit comments

Comments
 (0)