From 3eb8f65872f59e7215ed84b22a7eba4bf9ea90fa Mon Sep 17 00:00:00 2001 From: Alexander Mahr Date: Sun, 29 Sep 2024 11:29:56 +0200 Subject: [PATCH] add nginx + wss/chat --- client-test-websocket/Dockerfile | 5 +++ .../entrypoint.py | 2 +- .../entrypoint.sh | 0 client/Dockerfile | 5 --- compose.yml | 20 ++++++--- nginx/Dockerfile | 20 +++++++++ .../00-handle-bind-mounts.sh | 5 +++ nginx/etc/nginx/conf.d/default.conf | 19 ++++++++ nginx/srv/www/lovespeech/index.html | 44 +++++++++++++++++++ server/Dockerfile | 5 --- websocket-server/Dockerfile | 5 +++ {server => websocket-server}/entrypoint.py | 0 {server => websocket-server}/entrypoint.sh | 0 13 files changed, 113 insertions(+), 17 deletions(-) create mode 100644 client-test-websocket/Dockerfile rename {client => client-test-websocket}/entrypoint.py (92%) rename {client => client-test-websocket}/entrypoint.sh (100%) delete mode 100644 client/Dockerfile create mode 100644 nginx/Dockerfile create mode 100644 nginx/docker-entrypoint.d/00-handle-bind-mounts.sh create mode 100644 nginx/etc/nginx/conf.d/default.conf create mode 100644 nginx/srv/www/lovespeech/index.html delete mode 100644 server/Dockerfile create mode 100644 websocket-server/Dockerfile rename {server => websocket-server}/entrypoint.py (100%) rename {server => websocket-server}/entrypoint.sh (100%) diff --git a/client-test-websocket/Dockerfile b/client-test-websocket/Dockerfile new file mode 100644 index 0000000..603b14c --- /dev/null +++ b/client-test-websocket/Dockerfile @@ -0,0 +1,5 @@ +FROM alpine:edge +RUN apk update && apk add py3-websockets +COPY --chmod=0555 ./entrypoint.sh /entrypoint.sh +COPY --chmod=0555 ./entrypoint.py /entrypoint.py +ENTRYPOINT ["/entrypoint.sh"] diff --git a/client/entrypoint.py b/client-test-websocket/entrypoint.py similarity index 92% rename from client/entrypoint.py rename to client-test-websocket/entrypoint.py index ab0f076..88016e1 100755 --- a/client/entrypoint.py +++ b/client-test-websocket/entrypoint.py @@ -6,7 +6,7 @@ import asyncio from websockets.asyncio.client import connect async def test(): - uri = "ws://server:1080" + uri = "ws://websocket-server:1080" async with connect(uri) as websocket: print(f"Get username via:\n name = os.environ.get('USER')") msg = os.environ.get('USER') diff --git a/client/entrypoint.sh b/client-test-websocket/entrypoint.sh similarity index 100% rename from client/entrypoint.sh rename to client-test-websocket/entrypoint.sh diff --git a/client/Dockerfile b/client/Dockerfile deleted file mode 100644 index 2c7dbb9..0000000 --- a/client/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM alpine:edge -RUN apk update && apk add py3-websockets -COPY --chmod=0555 entrypoint.sh /entrypoint.sh -COPY --chmod=0555 entrypoint.py /entrypoint.py -ENTRYPOINT ["/entrypoint.sh"] diff --git a/compose.yml b/compose.yml index 41c95a4..10ad697 100644 --- a/compose.yml +++ b/compose.yml @@ -1,19 +1,27 @@ services: - # the server - server: + # the websocket-server + nginx: + stop_grace_period: 1s + build: 'nginx' + ports: + - 443:443 + volumes: + - ./nginx/ssl.d:/ssl.d + # the websocket-server + websocket-server: stop_grace_period: 1s environment: PYTHONUNBUFFERED: true - build: 'server' + build: 'websocket-server' expose: - 1080 # the client - client: + client-test-websocket: stop_grace_period: 1s environment: USER: ${USER} - build: 'client' + build: 'client-test-websocket' restart: on-failure depends_on: - server: + websocket-server: condition: service_started diff --git a/nginx/Dockerfile b/nginx/Dockerfile new file mode 100644 index 0000000..7d8f267 --- /dev/null +++ b/nginx/Dockerfile @@ -0,0 +1,20 @@ +FROM nginx:latest +RUN < + + +

test websocket

+
+ + +
+
+ diff --git a/server/Dockerfile b/server/Dockerfile deleted file mode 100644 index 2c7dbb9..0000000 --- a/server/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM alpine:edge -RUN apk update && apk add py3-websockets -COPY --chmod=0555 entrypoint.sh /entrypoint.sh -COPY --chmod=0555 entrypoint.py /entrypoint.py -ENTRYPOINT ["/entrypoint.sh"] diff --git a/websocket-server/Dockerfile b/websocket-server/Dockerfile new file mode 100644 index 0000000..603b14c --- /dev/null +++ b/websocket-server/Dockerfile @@ -0,0 +1,5 @@ +FROM alpine:edge +RUN apk update && apk add py3-websockets +COPY --chmod=0555 ./entrypoint.sh /entrypoint.sh +COPY --chmod=0555 ./entrypoint.py /entrypoint.py +ENTRYPOINT ["/entrypoint.sh"] diff --git a/server/entrypoint.py b/websocket-server/entrypoint.py similarity index 100% rename from server/entrypoint.py rename to websocket-server/entrypoint.py diff --git a/server/entrypoint.sh b/websocket-server/entrypoint.sh similarity index 100% rename from server/entrypoint.sh rename to websocket-server/entrypoint.sh