feat(docker): updated docker-compose to use environment variables

This commit is contained in:
Laureηt 2021-11-11 00:39:47 +01:00
parent 3382b69bc3
commit de10dc984a
No known key found for this signature in database
GPG key ID: D88C6B294FD40994
4 changed files with 26 additions and 6 deletions

6
.env Normal file
View file

@ -0,0 +1,6 @@
REDIS_HOST=redis
REDIS_PORT=6379
WEBSOCKET_LISTEN=0.0.0.0
WEBSOCKET_PORT=6789
RTMP_HOST=rtmp
RTMP_PORT=1935

View file

@ -4,22 +4,36 @@ services:
build:
context: .
entrypoint: poetry run python src/server.py
restart: unless-stopped
environment:
- REDIS_HOST=$REDIS_HOST
- REDIS_PORT=$REDIS_PORT
- WEBSOCKET_LISTEN=$WEBSOCKET_LISTEN
- WEBSOCKET_PORT=$WEBSOCKET_PORT
ports:
- 6789:6789
- $WEBSOCKET_PORT:$WEBSOCKET_PORT
depends_on:
- "redis"
emulator:
build:
context: .
entrypoint: poetry run python src/emulator.py
restart: unless-stopped
environment:
- REDIS_HOST=$REDIS_HOST
- REDIS_PORT=$REDIS_PORT
- RTMP_HOST=$RTMP_HOST
- RTMP_PORT=$RTMP_PORT
depends_on:
- "rtmp"
- "redis"
redis:
image: "redis:alpine"
restart: unless-stopped
ports:
- 6379:6379
- $REDIS_PORT:6379
rtmp:
image: "tiangolo/nginx-rtmp"
restart: unless-stopped
ports:
- 1935:1935
- $RTMP_PORT:1935

View file

@ -79,7 +79,7 @@
</table>
<script>
var websocket = new WebSocket("ws://147.127.160.190:6789/");
var websocket = new WebSocket("ws://localhost:6789/");
var a = document.getElementById('a'),
b = document.getElementById('b'),

View file

@ -5,8 +5,8 @@ WEBSOCKET_PORT: int = int(getenv("WEBSOCKET_PORT", 6789))
WEBSOCKET_URI: str = f"ws://{WEBSOCKET_HOST}:{WEBSOCKET_PORT}/"
WEBSOCKET_LISTEN: str = getenv("WEBSOCKET_LISTEN", "localhost")
RTMP_HOST: str = getenv("WEBSOCKET_HOST", "localhost")
RTMP_PORT: int = int(getenv("WEBSOCKET_PORT", 1935))
RTMP_HOST: str = getenv("RTMP_HOST", "localhost")
RTMP_PORT: int = int(getenv("RTMP_PORT", 1935))
RTMP_URI: str = f"rtmp://{RTMP_HOST}:{RTMP_PORT}/"
RTMP_STREAM_PATH: str = getenv("RTMP_STREAM_PATH", "live")
RTMP_STREAM_KEY: str = getenv("RTMP_STREAM_KEY", "test")