mirror of
https://github.com/Fluffy-Bean/GameExpo23.git
synced 2025-05-20 18:24:52 +00:00
Save database data
This commit is contained in:
parent
76d8e6ad27
commit
dbd6a81c78
5 changed files with 23 additions and 10 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -163,3 +163,6 @@ cython_debug/
|
||||||
# Remove dockerfile generated files
|
# Remove dockerfile generated files
|
||||||
Caddy/data/
|
Caddy/data/
|
||||||
Caddy/config/
|
Caddy/config/
|
||||||
|
|
||||||
|
# Remove Highscore-Server generated files
|
||||||
|
Highscore-Server/data/
|
|
@ -8,8 +8,7 @@ WORKDIR /data
|
||||||
COPY requirements.txt requirements.txt
|
COPY requirements.txt requirements.txt
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
RUN mkdir /highscore
|
RUN mkdir /storage
|
||||||
COPY /highscore /highscore
|
COPY /highscore/ .
|
||||||
WORKDIR /highscore
|
|
||||||
|
|
||||||
CMD ["gunicorn", "--bind", "highscore:8080", "server:app"]
|
CMD ["gunicorn", "--bind", "highscore:8080", "server:app"]
|
||||||
|
|
|
@ -2,3 +2,6 @@ SECRET_KEY = 'dev'
|
||||||
|
|
||||||
SQLALCHEMY_DATABASE_URI = 'sqlite:///db.sqlite'
|
SQLALCHEMY_DATABASE_URI = 'sqlite:///db.sqlite'
|
||||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||||
|
|
||||||
|
MIGRATION_DIR = '/data/storage/migrations'
|
||||||
|
INSTANCE_DIR = '/data/storage/instance'
|
|
@ -1,18 +1,24 @@
|
||||||
|
import os
|
||||||
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from flask_migrate import init as migrate_init
|
from flask_migrate import init as migrate_init
|
||||||
from extensions import db, migrate, cache
|
from extensions import db, migrate, cache
|
||||||
|
from config import MIGRATION_DIR, INSTANCE_DIR
|
||||||
from views import blueprint
|
from views import blueprint
|
||||||
|
|
||||||
|
app = Flask(__name__, instance_path=INSTANCE_DIR)
|
||||||
app = Flask(__name__)
|
|
||||||
app.config.from_pyfile('config.py')
|
app.config.from_pyfile('config.py')
|
||||||
|
|
||||||
db.init_app(app)
|
db.init_app(app)
|
||||||
migrate.init_app(app, db)
|
migrate.init_app(app, db, directory=MIGRATION_DIR)
|
||||||
cache.init_app(app)
|
cache.init_app(app)
|
||||||
|
|
||||||
with app.app_context():
|
if not os.path.exists(os.path.join(INSTANCE_DIR, 'db.sqlite')):
|
||||||
|
with app.app_context():
|
||||||
db.create_all()
|
db.create_all()
|
||||||
migrate_init()
|
|
||||||
|
if not os.path.exists(MIGRATION_DIR):
|
||||||
|
with app.app_context():
|
||||||
|
migrate_init(directory=MIGRATION_DIR)
|
||||||
|
|
||||||
app.register_blueprint(blueprint)
|
app.register_blueprint(blueprint)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
version: "3.9"
|
version: "3.9"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
caddy:
|
caddy:
|
||||||
image: caddy:alpine
|
image: caddy:alpine
|
||||||
|
@ -11,7 +12,8 @@ services:
|
||||||
- ./Caddy/config:/config
|
- ./Caddy/config:/config
|
||||||
links:
|
links:
|
||||||
- highscore
|
- highscore
|
||||||
|
|
||||||
highscore:
|
highscore:
|
||||||
build: ./Highscore-Server
|
build: ./Highscore-Server
|
||||||
volumes:
|
volumes:
|
||||||
- ./Highscore-Server/data:/data
|
- ./Highscore-Server/data:/data/storage
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue