From 372d9f88897ec345ccccc7881a35bddd5ab66500 Mon Sep 17 00:00:00 2001 From: Karl Date: Mon, 14 Jul 2025 14:09:53 +0100 Subject: [PATCH] rework docker i dockerfile --- dockerfile | 4 ++-- ktvmanager/config.py | 2 +- run.sh | 6 ------ run_docker.sh | 10 ++++++++++ 4 files changed, 13 insertions(+), 9 deletions(-) delete mode 100644 run.sh create mode 100644 run_docker.sh diff --git a/dockerfile b/dockerfile index 676cd64..f4301dc 100644 --- a/dockerfile +++ b/dockerfile @@ -20,7 +20,6 @@ RUN pip install --no-cache-dir -r requirements.txt COPY . . -RUN chmod +x run.sh ARG VERSION RUN echo $VERSION > VERSION @@ -28,4 +27,5 @@ RUN echo $VERSION > VERSION EXPOSE 3001 ENV FLASK_ENV=production -CMD ["./run.sh"] +RUN chmod +x run_docker.sh +CMD ["./run_docker.sh"] diff --git a/ktvmanager/config.py b/ktvmanager/config.py index 631cf73..5573eb0 100644 --- a/ktvmanager/config.py +++ b/ktvmanager/config.py @@ -19,4 +19,4 @@ class DevelopmentConfig(Config): DEBUG = True class ProductionConfig(Config): - PORT = os.environ.get('PORT', 5000) \ No newline at end of file + PORT = os.environ.get('PORT', 3001) \ No newline at end of file diff --git a/run.sh b/run.sh deleted file mode 100644 index fb28393..0000000 --- a/run.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -if [ "$FLASK_ENV" = "production" ]; then - gunicorn --bind 0.0.0.0:3001 "ktvmanager.main:create_app()" -else - flask run --host=0.0.0.0 --port=3001 -fi \ No newline at end of file diff --git a/run_docker.sh b/run_docker.sh new file mode 100644 index 0000000..a9b5844 --- /dev/null +++ b/run_docker.sh @@ -0,0 +1,10 @@ +#!/bin/bash +if [ -f VERSION ]; then + echo "Version: $(cat VERSION)" +fi + +# Extract port from config file +PORT=$(python -c "from ktvmanager.config import ProductionConfig; print(ProductionConfig.PORT)") + +echo "Starting in production mode on port $PORT..." +gunicorn --bind 0.0.0.0:$PORT "ktvmanager.main:create_app()" \ No newline at end of file