other method to do env

This commit is contained in:
2025-05-26 16:09:06 +02:00
parent 4b8396a3bc
commit 1814c6669a
3 changed files with 2 additions and 6 deletions

4
app.py
View File

@@ -20,9 +20,7 @@ def create_app():
app = Flask(__name__)
# Configure the database
# Use 'db' as host when running in Docker, 'localhost' for local development
db_host = 'db' if os.getenv('DOCKER_ENV') else 'localhost'
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URL', f'postgresql://postgres:1253@{db_host}:5432/docupulse')
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URL')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY', 'your-secret-key-here')
app.config['UPLOAD_FOLDER'] = os.path.join(app.root_path, 'static', 'uploads')

View File

@@ -9,8 +9,6 @@ services:
- ./uploads:/app/uploads
env_file:
- stack.env
environment:
- DOCKER_ENV=true
depends_on:
- db

View File

@@ -2,7 +2,7 @@
FLASK_APP=app.py
FLASK_ENV=production
UPLOAD_FOLDER=/app/uploads
DATABASE_URL=postgresql://postgres:1253@localhost:5432/docupulse
DATABASE_URL=postgresql://postgres:1253@db:5432/docupulse
SECRET_KEY=your-secure-secret-key-here
# Database service environment variables