Tobias Cudnik 2 лет назад
Родитель
Сommit
b62dea0806
3 измененных файлов с 63 добавлено и 0 удалено
  1. 33 0
      scripts/dev/README.md
  2. 14 0
      scripts/dev/docker-compose.override.yml
  3. 16 0
      scripts/dev/tunnel-compose.sh

+ 33 - 0
scripts/dev/README.md

@@ -0,0 +1,33 @@
+# Dev Scripts
+
+Dev scripts for Netmaker
+
+## Tunnel Compose
+
+Creates tunnels between a local instance and a docker-compose deployment on a droplet. Allows for fast local builds and local debugging.
+
+Steps:
+1. Create 2 ssh hosts in `~/.ssh/config` (adjust `DROPLET` and `IP`):
+```
+Host DROPLET
+    User root
+    Hostname IP
+
+Host DROPLET-docker-netmaker
+    User user
+    Hostname localhost
+    Port 2222
+    ProxyJump DROPLET
+    StrictHostKeyChecking no
+    UserKnownHostsFile=/dev/null
+    RequestTTY no
+    RemoteCommand cat
+```
+2. Copy [./scripts/dev/docker-compose.override.yml](./docker-compose.override.yml) to the installation dir on DROPLET (merge if already exists)
+3. `docker-compose down`
+4. `docker-compose up --force-recreate`
+5. `./scripts/dev/tunnel-compose.sh DROPLET-docker-netmaker`
+6. Add env vars to the local build (include a password from the droplet), eg:
+  `MQ_PASSWORD=SECRET;MQ_USERNAME=netmaker;SERVER_BROKER_ENDPOINT=ws://localhost:1883;VERBOSE=3`
+
+At this point tunnels should be set up and running a local build should talk to the docker-compose services on the droplet.

+ 14 - 0
scripts/dev/docker-compose.override.yml

@@ -0,0 +1,14 @@
+version: "3.4"
+
+services:
+
+  netmaker:
+    image: linuxserver/openssh-server
+    environment:
+      - PASSWORD_ACCESS=true
+      - USER_PASSWORD=123123
+      - USER_NAME=user
+      - SUDO_ACCESS=true
+      - DOCKER_MODS=linuxserver/mods:openssh-server-ssh-tunnel
+    ports:
+      - "2222:2222"

+ 16 - 0
scripts/dev/tunnel-compose.sh

@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+SSH_HOST=$1
+SCRIPT_DIR=$(dirname "$(realpath "$0")")
+
+source "$SCRIPT_DIR/../netmaker.env"
+
+# TODO read 1883 from SERVER_BROKER_ENDPOINT
+# $API_PORT 8081
+sshpass -p123123 ssh $SSH_HOST \
+	-R 0.0.0.0:$API_PORT:localhost:$API_PORT \
+	-L 1883:mq:1883 \
+	-N -vv
+
+	# TODO UDP fwd 3478
+	#-R $STUN_PORT:localhost:$STUN_PORT