Improve docker image and deployment scripts

This commit is contained in:
rubenwardy 2019-11-14 22:24:37 +00:00
parent 9f678d8fde
commit df247b021e
8 changed files with 18 additions and 18 deletions

View File

@ -5,13 +5,8 @@ WORKDIR /home/cdb
COPY requirements.txt requirements.txt COPY requirements.txt requirements.txt
RUN pip install -r ./requirements.txt RUN pip install -r ./requirements.txt
RUN pip install gunicorn RUN pip install gunicorn
RUN pip install psycopg2
COPY runprodguni.sh ./ COPY utils utils
COPY rundebug.sh ./
RUN chmod +x runprodguni.sh
COPY setup.py ./setup.py
COPY app app COPY app app
COPY migrations migrations COPY migrations migrations
COPY config.cfg ./config.cfg COPY config.cfg ./config.cfg

View File

@ -48,7 +48,7 @@ gravatar = Gravatar(app,
use_ssl=True, use_ssl=True,
base_url=None) 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 from .maillogger import register_mail_error_handler
register_mail_error_handler(app, mail) register_mail_error_handler(app, mail)

View File

@ -15,7 +15,9 @@ services:
app: app:
build: . build: .
command: ./rundebug.sh command: ./utils/run.sh
env_file:
- config.env
ports: ports:
- 5123:5123 - 5123:5123
volumes: volumes:
@ -28,7 +30,7 @@ services:
worker: worker:
build: . build: .
command: celery -A app.tasks.celery worker command: FLASK_CONFIG=../config.cfg celery -A app.tasks.celery worker
env_file: env_file:
- config.env - config.env
volumes: volumes:

View File

@ -19,3 +19,4 @@ lxml~=4.2
pillow~=5.3 pillow~=5.3
pyScss~=1.3 pyScss~=1.3
redis==2.10.6 redis==2.10.6
psycopg2~=2.7

11
utils/run.sh Executable file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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