Skip to content

Commit ec2c261

Browse files
committed
Merge branch 'locator'
2 parents a678414 + a089542 commit ec2c261

33 files changed

+465
-46
lines changed

.github/workflows/general-stack.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,45 @@ run-name: General ${{ github.sha }}
55
on:
66
workflow_dispatch:
77

8+
env:
9+
REGISTRY: ghcr.io
10+
LOCATOR_IMAGE_NAME: ${{ github.repository }}/locator
11+
812
jobs:
13+
################################################################
14+
build-locator:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
packages: write
18+
19+
outputs:
20+
image_tag: ${{ steps.meta.outputs.tags }} # TODO: output SHA tag only
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: docker/setup-buildx-action@v3
24+
- uses: docker/login-action@v3
25+
with:
26+
registry: ${{ env.REGISTRY }}
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
- uses: docker/metadata-action@v5
30+
id: meta
31+
with:
32+
images: ${{ env.REGISTRY }}/${{ env.LOCATOR_IMAGE_NAME }}
33+
tags: type=sha
34+
- uses: docker/build-push-action@v6
35+
with:
36+
context: .
37+
push: true
38+
file: src/Locator/Locator.Service/Dockerfile
39+
tags: ${{ steps.meta.outputs.tags }}
40+
labels: ${{ steps.meta.outputs.labels }}
41+
cache-from: type=gha
42+
cache-to: type=gha,mode=max
43+
44+
################################################################
945
deploy:
46+
needs: build-locator
1047
runs-on: ubuntu-latest
1148
permissions:
1249
deployments: write
@@ -26,6 +63,9 @@ jobs:
2663
DATA_ROOT: /home/${{ secrets.REMOTE_USER }}
2764
SERVER_NAME: ${{ secrets.REMOTE_HOST }}
2865
DOMAIN_EMAIL: ${{ secrets.DOMAIN_EMAIL }}
66+
LOCATOR_IMAGE: ${{ needs.build-locator.outputs.image_tag }}
67+
TURN_USERNAME: ${{ secrets.TURN_USERNAME }}
68+
TURN_PASSWORD: ${{ secrets.TURN_PASSWORD }}
2969
with:
3070
ssh_user: ${{ secrets.REMOTE_USER }}
3171
ssh_host: ${{ secrets.REMOTE_HOST }}

.github/workflows/stand-stack.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ jobs:
2222
- uses: actions/checkout@v4
2323
- uses: rlespinasse/github-slug-action@v5
2424

25-
- uses: ./.github/composites/deploy-begin
26-
with:
27-
token: ${{ secrets.GITHUB_TOKEN }}
28-
environment: stand-${{ env.GITHUB_REF_POINT_SLUG }}
29-
3025
################################################################
3126
# Server Build
3227
- uses: docker/setup-buildx-action@v3 #https://github.com/marketplace/actions/docker-setup-buildx
@@ -55,13 +50,20 @@ jobs:
5550

5651
################################################################
5752
# Stand Deploy (custom docker stack deploy step much faster than docker-stack-deploy action)
53+
- uses: ./.github/composites/deploy-begin
54+
with:
55+
token: ${{ secrets.GITHUB_TOKEN }}
56+
environment: stand-${{ env.GITHUB_REF_POINT_SLUG }}
57+
5858
- uses: ./.github/composites/remote-deploy
5959
env:
6060
# environment variables that are used for compose
6161
STAND_NAME: ${{ env.GITHUB_REF_POINT_SLUG }}
6262
STACK_NAME: stand-${{ env.GITHUB_REF_POINT_SLUG }}
6363
SERVER_NAME: ${{ secrets.REMOTE_HOST }}
6464
SERVER_IMAGE: ${{ steps.meta.outputs.tags }}
65+
TURN_USERNAME: ${{ secrets.TURN_USERNAME }}
66+
TURN_PASSWORD: ${{ secrets.TURN_PASSWORD }}
6567
with:
6668
ssh_user: ${{ secrets.REMOTE_USER }}
6769
ssh_host: ${{ secrets.REMOTE_HOST }}

complex.sln.DotSettings

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,5 @@
8181
<s:Boolean x:Key="/Default/UserDictionary/Words/=ffxx/@EntryIndexedValue">True</s:Boolean>
8282
<s:Boolean x:Key="/Default/UserDictionary/Words/=ghcr/@EntryIndexedValue">True</s:Boolean>
8383
<s:Boolean x:Key="/Default/UserDictionary/Words/=letsencrypt/@EntryIndexedValue">True</s:Boolean>
84-
<s:Boolean x:Key="/Default/UserDictionary/Words/=mech/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
84+
<s:Boolean x:Key="/Default/UserDictionary/Words/=mech/@EntryIndexedValue">True</s:Boolean>
85+
<s:Boolean x:Key="/Default/UserDictionary/Words/=opencontainers/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

complex.slnx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<Solution>
2-
<Folder Name="/ext/">
3-
<Project Path="ext\sipsorcery\src\SIPSorcery.csproj" Type="Classic C#" />
2+
<Folder Name="/Locator/">
3+
<Project Path="src\Locator\Locator.Api\Locator.Api.csproj" Type="Classic C#" />
4+
<Project Path="src\Locator\Locator.Client\Locator.Client.csproj" Type="Classic C#" />
5+
<Project Path="src\Locator\Locator.Service\Locator.Service.csproj" Type="Classic C#" />
46
</Folder>
57
<Folder Name="/Server/">
68
<Project Path="src\Common\Runtime\Common.csproj" Type="Classic C#" />

deploy/_general/compose.override.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ services:
2727
-out $$_PATH/fullchain.pem \
2828
-subj "/C=ZZ/ST=State/L=City/O=Development/CN=localhost"
2929
echo "<<<< certbot emulation finished"
30+
31+
locator:
32+
build:
33+
context: ../..
34+
dockerfile: src/Locator/Locator.Service/Dockerfile

deploy/_general/compose.swarm.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,9 @@ services:
5252
/etc/letsencrypt/live
5353
echo "<<<< certbot finished"
5454
#read -n 1 -s -r -p "Press any key to exit (debugging)..."
55+
56+
locator:
57+
networks:
58+
- general_shared # allow access from nginx
59+
environment:
60+
LocatorConfig__StandUrlTemplate: "https://${SERVER_NAME:-localhost}/$$STAND_NAME"

deploy/_general/compose.yaml

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ services:
77
condition: none
88
volumes:
99
# tmp DATA_ROOT from .env usage until image isn't built
10-
- ${DATA_ROOT:-.}/deploy/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
10+
- ${DATA_ROOT:-../..}/deploy/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
1111
# templates to render environment variables
1212
# https://github.com/docker-library/docs/tree/master/nginx#using-environment-variables-in-nginx-configuration-new-in-119
13-
- ${DATA_ROOT:-.}/deploy/nginx/templates:/etc/nginx/templates:ro
14-
- ${DATA_ROOT:-.}/pages:/usr/share/nginx/html:ro
15-
- ${DATA_ROOT:-.}/certbot/www:/var/www/certbot:ro
16-
- ${DATA_ROOT:-.}/certbot/conf:/etc/letsencrypt:ro
13+
- ${DATA_ROOT:-../..}/deploy/nginx/templates:/etc/nginx/templates:ro
14+
- ${DATA_ROOT:-../..}/pages:/usr/share/nginx/html:ro
15+
- ${DATA_ROOT:-../..}/certbot/www:/var/www/certbot:ro
16+
- ${DATA_ROOT:-../..}/certbot/conf:/etc/letsencrypt:ro
1717
environment:
1818
- SERVER_NAME=${SERVER_NAME:-localhost}
1919
ports:
@@ -29,8 +29,6 @@ services:
2929
published: 443
3030
target: 443
3131

32-
# TODO: user/pass setup for remote deployment
33-
# TODO: --allowed-peer-ip for TURN in internal network only
3432
# Workaround to deploy multiple WebRTC servers in docker swarm infrastructure.
3533
# Host mode cannot be used for several servers on minimum number of swarm nodes.
3634
#
@@ -44,9 +42,10 @@ services:
4442
# (different load-balancer service types are available for the same server)
4543
coturn:
4644
image: coturn/coturn:latest
47-
# -n is not used "Do not use configuration file, take all parameters from the command line only."
48-
# as gives "CONFIGURATION ALERT: Unknown argument: "
45+
# -n "Do not use configuration file, take all parameters from the command line only."
46+
# not used as it gives "CONFIGURATION ALERT: Unknown argument: "
4947
# TODO: use config file instead
48+
#
5049
# --listening-port=3478 mentions default value just to recall its value
5150
# --relay-threads=1 to make less socket bindings in develop environments
5251
# --no-cli to get rid of "CONFIG ERROR: Empty cli-password, and so telnet cli interface is disabled! Please set a non empty cli-password!"
@@ -61,7 +60,19 @@ services:
6160
# TODO: research is --fingerprint required increasing traffic
6261
#
6362
# TODO: enable/setup DTLS support (rm --no-dtls) for clients allowing "stuns:*" url
63+
#
64+
# TODO: remote --allowed-peer-ip for TURN in internal network only (additionally with auth)
65+
# Local docker compose tested:
66+
# --listening-ip=10.211.55.4
67+
# --relay-ip=10.211.55.4
68+
# --denied-peer-ip="0.0.0.0-255.255.255.255"
69+
# --allowed-peer-ip="172.17.0.0-172.17.255.255"
70+
# rt -stun stun:host.docker.internal:3478
71+
# rt -stun turn:10.211.55.4
72+
# turnutils_uclient 10.211.55.4 -DgX -u user -w pass -n 1 -c -y
73+
# turnutils_uclient 172.17.0.1 -DgX -u user -w pass -n 1 -c -e 172.21.0.2
6474
command: >
75+
-n
6576
--listening-port=3478
6677
--relay-threads=1
6778
--no-cli
@@ -70,9 +81,9 @@ services:
7081
--no-dtls
7182
--no-tcp-relay
7283
--no-multicast-peers
84+
--user=${TURN_USERNAME:-user}:${TURN_PASSWORD:-pass}
85+
--realm=default
7386
--lt-cred-mech
74-
--user user:pass
75-
--realm default
7687
--fingerprint
7788
--log-file=stdout
7889
--verbose
@@ -83,5 +94,11 @@ services:
8394
environment:
8495
- SERVER_NAME=${SERVER_NAME:-localhost}
8596
volumes:
86-
- ${DATA_ROOT:-.}/certbot/www:/var/www/certbot:rw
87-
- ${DATA_ROOT:-.}/certbot/conf:/etc/letsencrypt:rw
97+
- ${DATA_ROOT:-../..}/certbot/www:/var/www/certbot:rw
98+
- ${DATA_ROOT:-../..}/certbot/conf:/etc/letsencrypt:rw
99+
100+
locator:
101+
image: ${LOCATOR_IMAGE:-locator}
102+
volumes:
103+
- /var/run/docker.sock:/var/run/docker.sock
104+
# WebAPI TCP port 8080 is internal as NGINX is used to access

deploy/nginx/templates/default.conf.template

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@ server {
1111

1212
#access_log /var/log/nginx/host.access.log main;
1313

14-
# NOTE: port 80 must be opened to renew cert (check it first)
14+
################################################################
15+
# certbot requirement
16+
# NOTE: port 80 must be opened to renew cert (check UFW if renew fails)
1517
location /.well-known/acme-challenge/ {
1618
root /var/www/certbot;
1719
}
1820

19-
location /api {
21+
################################################################
22+
# Locator service
23+
# /-/stands
24+
location ~ ^/-/(.*) {
2025
# DISABLED: CORS headers are added to service app instead (simplified local develop)
2126
# # enables CORS to develop client against deployed server
2227
# # https://docs.unity3d.com/Manual/webgl-networking.html
@@ -32,17 +37,19 @@ server {
3237
# }
3338
# add_header 'Access-Control-Allow-Origin' '*';
3439

35-
# using $stand variable to workaround '[emerg] host not found in upstream ".." in /etc/nginx/conf.d/default.conf'
40+
# using $upstream variable to workaround '[emerg] host not found in upstream ".." in /etc/nginx/conf.d/default.conf'
3641
# https://dev.to/danielkun/nginx-everything-about-proxypass-2ona#let-nginx-start-even-when-not-all-upstream-hosts-are-available
3742
# https://github.com/NginxProxyManager/nginx-proxy-manager/issues/1807
3843
# https://stackoverflow.com/questions/50248522/nginx-will-not-start-with-host-not-found-in-upstream
3944
# https://stackoverflow.com/questions/32845674/nginx-how-to-not-exit-if-host-not-found-in-upstream/32846603#32846603
4045
resolver 127.0.0.11 valid=30s;
41-
set $stand server.main;
42-
proxy_pass http://$stand:8080$request_uri;
46+
set $upstream locator;
47+
proxy_pass http://$upstream:8080/$1$is_args$args; # $request_uri contains full /-/..
4348
}
4449

45-
# /<stand>/api/foo -> http://<stand>:8080/api/foo
50+
################################################################
51+
# Server services on stands
52+
# /<stand>/api/info -> http://<stand>:8080/api/info
4653
location ~* ^/([^/]+)/api {
4754
resolver 127.0.0.11 valid=30s;
4855
set $stand $1; # take first path part as stand name
@@ -51,6 +58,8 @@ server {
5158
proxy_pass http://server.$stand:8080$uri$is_args$args; # $request_uri isn't rewritten so mimic it w/ uri/args
5259
}
5360

61+
################################################################
62+
# Client WebGL builds
5463
location / {
5564
root /usr/share/nginx/html;
5665
index index.html index.htm;

deploy/sandbox/compose.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ services:
2525
# # --external-ip='$$(detect-external-ip)'
2626
#
2727
# # Docker Desktop compose:
28-
# # rt -stun stun:host.docker.internal:3478
29-
# # rt -stun turn:192.168.65.3
30-
# # rt -stun turn:10.211.55.4
31-
# # turnutils_uclient 172.21.0.1 -DgX -u user -w pass -e 172.21.0.2 -n 1 -c -y
3228
# # --relay-ip=10.211.55.4 # --relay-ip=0.0.0.0
3329
# command: >
3430
# -n

src/Client/Assets/Scripts/Logic/ClientSession.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ public void Finish(string reason)
9595

9696
clientTap.SetActive(false);
9797

98-
_stateSyncer?.Dispose();
99-
_stateSyncer = null;
100-
10198
_dumpLink = null;
10299
_timeLink = null;
103100
_link?.Dispose();
@@ -106,6 +103,10 @@ public void Finish(string reason)
106103
_api = null;
107104
_meta?.Dispose();
108105
_meta = null;
106+
107+
// destroy after link to not fail on latest Received
108+
_stateSyncer?.Dispose();
109+
_stateSyncer = null;
109110
}
110111

111112
private void Update()

0 commit comments

Comments
 (0)