feat: add one-click deploy script + project optimization
- deploy.sh: one-click deployment (squid + venv + pip + gunicorn + systemd) - gunicorn_config.py: unified gunicorn config with env var overrides - .env.example: env var template for SECRET_KEY, port, workers, security - wsgi.py: create all runtime dirs (uploads, ssl_certs); optional dotenv loading - requirements.txt: add python-dotenv + cryptography - .gitignore: cover runtime dirs, .env, pyc files
This commit is contained in:
@@ -7,10 +7,19 @@ Or via systemd unit.
|
||||
"""
|
||||
import os
|
||||
|
||||
# Ensure instance dir exists before app imports (it references the SQLite path)
|
||||
# Ensure runtime dirs exist before app imports (it references SQLite path etc.)
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
os.makedirs(os.path.join(BASE_DIR, "instance"), exist_ok=True)
|
||||
os.makedirs(os.path.join(BASE_DIR, "backups"), exist_ok=True)
|
||||
for _d in ("instance", "backups", "uploads", "ssl_certs"):
|
||||
os.makedirs(os.path.join(BASE_DIR, _d), exist_ok=True)
|
||||
|
||||
# Optional: load .env file if python-dotenv is available
|
||||
try:
|
||||
from dotenv import load_dotenv
|
||||
_env_path = os.path.join(BASE_DIR, ".env")
|
||||
if os.path.isfile(_env_path):
|
||||
load_dotenv(_env_path)
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
from app import app, db, seed_admin
|
||||
|
||||
|
||||
Reference in New Issue
Block a user