Compare commits

..

2 Commits

Author SHA1 Message Date
Martin Asprusten
5d6138bdc2 Slightly better build process. Socket.io can now add CORS allowed origin 2025-04-20 17:28:43 +02:00
Martin Asprusten
da99a1bdd5 Added Dockerfile 2025-04-20 16:48:49 +02:00
3 changed files with 32 additions and 3 deletions

23
Dockerfile Normal file
View File

@ -0,0 +1,23 @@
FROM python:3.13-slim-bookworm AS build
WORKDIR /santa
RUN mkdir -p /santa/WebServer/static
COPY setup-server.sh /santa/setup-server.sh
RUN apt-get update && apt-get install -y curl bzip2
RUN /santa/setup-server.sh --download-only
COPY requirements.txt /santa/requirements.txt
COPY src/setup.py /santa/src/setup.py
COPY src/SantaExchange/ /santa/src/SantaExchange/
RUN pip install -r /santa/requirements.txt
RUN /santa/setup-server.sh
FROM python:3.13-slim-bookworm
RUN pip install flask flask-socketio gunicorn eventlet
COPY --from=build /santa/WebServer /WebServer
COPY WebServer/__init__.py WebServer/server.py /WebServer/
COPY WebServer/templates/ /WebServer/templates/
COPY WebServer/static/exchange_client.py WebServer/static/exchange_worker.js WebServer/static/style.css /WebServer/static/
WORKDIR /WebServer
EXPOSE 8000
CMD ["gunicorn", "--worker-class", "eventlet", "-w", "1", "--bind", "0.0.0.0:8000", "server:app"]

View File

@ -1,10 +1,12 @@
import json
from collections import defaultdict
import os
from flask import Flask, render_template
from flask_socketio import SocketIO, join_room, leave_room, send
app = Flask(__name__)
if 'CORS_ORIGIN' in os.environ and os.environ['CORS_ORIGIN'] is not None:
socketio = SocketIO(app, cors_allowed_origins=[os.environ['CORS_ORIGIN']])
else:
socketio = SocketIO(app)
if __name__ == 'main':

View File

@ -17,6 +17,10 @@ if ! test -f ./WebServer/static/socket.io.min.js; then
fi
echo "Socket.io is installed"
if [[ "$1" == "--download-only" ]]; then
exit 0
fi
echo "Building wheel file of SantaExchange package"
cd src/
python setup.py bdist_wheel