mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 22:12:24 +01:00
Add Docker support
This commit is contained in:
parent
0db49efe4a
commit
a45df0e173
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,6 @@
|
|||||||
config.cfg
|
config.cfg
|
||||||
config.prod.cfg
|
config.prod.cfg
|
||||||
|
*.env
|
||||||
*.sqlite
|
*.sqlite
|
||||||
custom.css
|
custom.css
|
||||||
tmp
|
tmp
|
||||||
@ -8,6 +9,7 @@ log.txt
|
|||||||
uploads
|
uploads
|
||||||
thumbnails
|
thumbnails
|
||||||
celerybeat-schedule
|
celerybeat-schedule
|
||||||
|
/data
|
||||||
|
|
||||||
# Created by https://www.gitignore.io/api/linux,macos,python,windows
|
# Created by https://www.gitignore.io/api/linux,macos,python,windows
|
||||||
|
|
||||||
|
19
Dockerfile
Normal file
19
Dockerfile
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
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"]
|
29
docker-compose.yml
Normal file
29
docker-compose.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
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
|
@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/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
|
||||||
|
13
setup.py
13
setup.py
@ -20,7 +20,9 @@ import os, sys, datetime
|
|||||||
if not "FLASK_CONFIG" in os.environ:
|
if not "FLASK_CONFIG" in os.environ:
|
||||||
os.environ["FLASK_CONFIG"] = "../config.cfg"
|
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.models import *
|
||||||
from app.utils import make_flask_user_password
|
from app.utils import make_flask_user_password
|
||||||
@ -333,13 +335,14 @@ Uses the CTF PvP Engine.
|
|||||||
db.session.add(dep)
|
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"):
|
if delete_db and os.path.isfile("db.sqlite"):
|
||||||
os.remove("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...")
|
print("Filling database...")
|
||||||
|
|
||||||
ruben = User("rubenwardy")
|
ruben = User("rubenwardy")
|
||||||
|
Loading…
Reference in New Issue
Block a user