config.cfg
config.prod.cfg
+*.env
*.sqlite
custom.css
tmp
uploads
thumbnails
celerybeat-schedule
+/data
# Created by https://www.gitignore.io/api/linux,macos,python,windows
--- /dev/null
+FROM python:3.7
+
+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 ./
+RUN chmod +x runprodguni.sh
+
+COPY setup.py ./setup.py
+COPY app app
+COPY migrations migrations
+COPY config.prod.cfg ./config.prod.cfg
+
+EXPOSE 5123
+ENTRYPOINT ["./runprodguni.sh"]
--- /dev/null
+version: '3'
+services:
+ db:
+ image: "postgres:9.6.5"
+ restart: always
+ volumes:
+ - "./data/db:/var/lib/postgresql/data"
+ env_file:
+ - db.env
+ networks:
+ - db_nw
+
+ app:
+ build: .
+ ports:
+ - 5123:5123
+ volumes:
+ - "./data/uploads:/home/app/public/uploads"
+ networks:
+ - db_nw
+ - web_nw
+ depends_on:
+ - db
+
+networks:
+ db_nw:
+ driver: bridge
+ web_nw:
+ driver: bridge
#!/bin/bash
-gunicorn -w 4 -b 127.0.0.1:5123 -e FLASK_APP=app/__init__.py -e FLASK_CONFIG=../config.prod.cfg -e FLASK_DEBUG=0 app:app
+gunicorn -w 4 -b :5123 -e FLASK_APP=app/__init__.py -e FLASK_CONFIG=../config.prod.cfg -e FLASK_DEBUG=0 app:app
if not "FLASK_CONFIG" in os.environ:
os.environ["FLASK_CONFIG"] = "../config.cfg"
-test_data = len(sys.argv) >= 2 and sys.argv[1].strip() == "-t"
+delete_db = len(sys.argv) >= 2 and sys.argv[1].strip() == "-d"
+create_db = not (len(sys.argv) >= 2 and sys.argv[1].strip() == "-o")
+test_data = len(sys.argv) >= 2 and sys.argv[1].strip() == "-t" or not create_db
from app.models import *
from app.utils import make_flask_user_password
db.session.add(dep)
-
-delete_db = len(sys.argv) >= 2 and sys.argv[1].strip() == "-d"
if delete_db and os.path.isfile("db.sqlite"):
os.remove("db.sqlite")
-print("Creating database tables...")
-db.create_all()
+
+if create_db:
+ print("Creating database tables...")
+ db.create_all()
+
print("Filling database...")
ruben = User("rubenwardy")