]> git.lizzy.rs Git - cheatdb.git/commitdiff
Improve docker image and deployment scripts
authorrubenwardy <rw@rubenwardy.com>
Thu, 14 Nov 2019 22:24:37 +0000 (22:24 +0000)
committerrubenwardy <rw@rubenwardy.com>
Thu, 14 Nov 2019 22:24:37 +0000 (22:24 +0000)
Dockerfile
app/__init__.py
docker-compose.yml
requirements.txt
utils/run.sh [new file with mode: 0755]
utils/rundebug.sh [deleted file]
utils/runprod.sh [deleted file]
utils/runprodguni.sh [deleted file]

index 73b620d82b3ee79ed49672aa69281756326463a6..09b127236046d9321f03401a615283a61fd19bfe 100644 (file)
@@ -5,13 +5,8 @@ WORKDIR /home/cdb
 COPY requirements.txt requirements.txt
 RUN pip install -r ./requirements.txt
 RUN pip install gunicorn
-RUN pip install psycopg2
 
-COPY runprodguni.sh ./
-COPY rundebug.sh ./
-RUN chmod +x runprodguni.sh
-
-COPY setup.py ./setup.py
+COPY utils utils
 COPY app app
 COPY migrations migrations
 COPY config.cfg ./config.cfg
index 2768fb0f16ea95f86c143cbc250da765aa033e5c..c5d80008bec6db0d77112415f8815b86850091d2 100644 (file)
@@ -48,7 +48,7 @@ gravatar = Gravatar(app,
                use_ssl=True,
                base_url=None)
 
-if not app.debug:
+if not app.debug and app.config["MAIL_UTILS_ERROR_SEND_TO"]:
        from .maillogger import register_mail_error_handler
        register_mail_error_handler(app, mail)
 
index be02d7613b63402540d01541632e9cce4c4d9793..10731fbc0dc7341c4b73af1ce45a68c43a889a03 100644 (file)
@@ -15,7 +15,9 @@ services:
 
   app:
     build: .
-    command: ./rundebug.sh
+    command: ./utils/run.sh
+    env_file:
+      - config.env
     ports:
       - 5123:5123
     volumes:
@@ -28,7 +30,7 @@ services:
 
   worker:
     build: .
-    command: celery -A app.tasks.celery worker
+    command: FLASK_CONFIG=../config.cfg celery -A app.tasks.celery worker
     env_file:
       - config.env
     volumes:
index 7f19020b433f0a85b0ec930c1a2c1e5ff3fb7a98..4067ca084889fa702dddb42be5a15bdb73a48d31 100644 (file)
@@ -19,3 +19,4 @@ lxml~=4.2
 pillow~=5.3
 pyScss~=1.3
 redis==2.10.6
+psycopg2~=2.7
diff --git a/utils/run.sh b/utils/run.sh
new file mode 100755 (executable)
index 0000000..3d19d84
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+# Debug
+# FLASK_APP=app/__init__.py FLASK_CONFIG=../config.cfg FLASK_DEBUG=1 python3 -m flask run -h 0.0.0.0 -p 5123
+
+if [ -z "$FLASK_DEBUG" ]; then
+       echo "FLASK_DEBUG is required in config.env"
+       exit 1
+fi
+
+gunicorn -w 4 -b :5123 -e FLASK_APP=app/__init__.py -e FLASK_CONFIG=../config.cfg -e FLASK_DEBUG=$FLASK_DEBUG app:app
diff --git a/utils/rundebug.sh b/utils/rundebug.sh
deleted file mode 100755 (executable)
index 31e9137..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-FLASK_APP=app/__init__.py FLASK_CONFIG=../config.cfg FLASK_DEBUG=1 python3 -m flask run -h 0.0.0.0 -p 5123
diff --git a/utils/runprod.sh b/utils/runprod.sh
deleted file mode 100755 (executable)
index c64450c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-FLASK_APP=app/__init__.py FLASK_CONFIG=../config.cfg FLASK_DEBUG=0 python3 -m flask run -h 0.0.0.0 -p 5123
diff --git a/utils/runprodguni.sh b/utils/runprodguni.sh
deleted file mode 100644 (file)
index 68c6962..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-gunicorn -w 4 -b :5123 -e FLASK_APP=app/__init__.py -e FLASK_CONFIG=../config.cfg -e FLASK_DEBUG=0 app:app