changes
This commit is contained in:
parent
2e2997afb6
commit
b572dfe002
8
Makefile
8
Makefile
@ -28,6 +28,14 @@ up:
|
||||
$(DOCKER_COMPOSE) up --build -d
|
||||
@$(MAKE) wait
|
||||
|
||||
up-nobuild:
|
||||
@if [ ! -f $(ENV_FILE) ]; then \
|
||||
echo "[⚙] Generating .env from example..."; \
|
||||
cp $(ENV_EXAMPLE) $(ENV_FILE); \
|
||||
fi
|
||||
$(DOCKER_COMPOSE) up -d
|
||||
@$(MAKE) wait
|
||||
|
||||
down:
|
||||
$(DOCKER_COMPOSE) down
|
||||
|
||||
|
@ -7,25 +7,30 @@ db = SQLAlchemy()
|
||||
migrate = Migrate()
|
||||
login_manager = LoginManager()
|
||||
|
||||
|
||||
def create_app():
|
||||
app = Flask(__name__)
|
||||
app.config.from_object('config.Config')
|
||||
|
||||
# Initialize core extensions
|
||||
db.init_app(app)
|
||||
migrate.init_app(app, db)
|
||||
login_manager.init_app(app)
|
||||
login_manager.login_view = 'auth.login' # Optional: redirect for @login_required
|
||||
|
||||
# Register Blueprints
|
||||
from .core.routes import core
|
||||
from .core.auth import auth
|
||||
app.register_blueprint(core)
|
||||
app.register_blueprint(auth)
|
||||
app.register_blueprint(auth, url_prefix="/auth")
|
||||
|
||||
# CLI command registration must be inside create_app
|
||||
# Register CLI commands
|
||||
from .cli import seed_admin
|
||||
app.cli.add_command(seed_admin)
|
||||
|
||||
return app
|
||||
|
||||
|
||||
@login_manager.user_loader
|
||||
def load_user(user_id):
|
||||
from .core.models import User
|
||||
|
@ -17,6 +17,10 @@ ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg'}
|
||||
def allowed_file(filename):
|
||||
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
||||
|
||||
@core.route("/health")
|
||||
def health_check():
|
||||
return "OK", 200
|
||||
|
||||
@core.route('/')
|
||||
def index():
|
||||
submissions = Submission.query.order_by(Submission.timestamp.desc()).limit(6).all()
|
||||
|
@ -18,9 +18,9 @@ services:
|
||||
depends_on:
|
||||
- db
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:5000"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
command: >
|
||||
bash -c "
|
||||
@ -32,6 +32,12 @@ services:
|
||||
echo '[✔] Waiting for MySQL to be ready...'
|
||||
until nc -z ${MYSQL_HOST} ${MYSQL_PORT}; do sleep 1; done
|
||||
|
||||
echo '[✔] Ensuring migration structure...'
|
||||
if [ ! -d 'migrations' ]; then
|
||||
echo '[ℹ] Running flask db init...'
|
||||
flask db init
|
||||
fi
|
||||
|
||||
echo '[ℹ] Autogenerating migration...'
|
||||
flask db migrate -m 'auto' || echo '[ℹ] No changes detected.'
|
||||
|
||||
@ -49,6 +55,7 @@ services:
|
||||
flask run --host=0.0.0.0
|
||||
"
|
||||
|
||||
|
||||
db:
|
||||
image: mysql:8
|
||||
restart: unless-stopped
|
||||
|
Loading…
x
Reference in New Issue
Block a user