mirror of
https://github.com/kevinveenbirkenbach/homepage.veen.world.git
synced 2025-07-07 03:25:12 +02:00
Solved wrong environment bug
This commit is contained in:
parent
9c24a8658f
commit
86fd72b623
@ -14,4 +14,5 @@ services:
|
|||||||
- ./.env:/app./.env
|
- ./.env:/app./.env
|
||||||
environment:
|
environment:
|
||||||
- PORT=${PORT:-5000}
|
- PORT=${PORT:-5000}
|
||||||
|
- FLASK_ENV=${FLASK_ENV:-production}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
14
main.py
14
main.py
@ -33,14 +33,14 @@ else:
|
|||||||
print(f"⚠️ Warning: No .env file found at {dotenv_path}")
|
print(f"⚠️ Warning: No .env file found at {dotenv_path}")
|
||||||
PORT = int(os.getenv("PORT", 5000))
|
PORT = int(os.getenv("PORT", 5000))
|
||||||
|
|
||||||
def run_command(command, dry_run=False):
|
def run_command(command, dry_run=False, env=None):
|
||||||
"""Utility function to run a shell command."""
|
"""Utility function to run a shell command."""
|
||||||
print(f"Executing: {' '.join(command)}")
|
print(f"Executing: {' '.join(command)}")
|
||||||
if dry_run:
|
if dry_run:
|
||||||
print("Dry run enabled: command not executed.")
|
print("Dry run enabled: command not executed.")
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(command)
|
subprocess.check_call(command, env=env)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print(f"Error: Command failed with exit code {e.returncode}")
|
print(f"Error: Command failed with exit code {e.returncode}")
|
||||||
sys.exit(e.returncode)
|
sys.exit(e.returncode)
|
||||||
@ -147,18 +147,12 @@ def logs(args):
|
|||||||
def dev(args):
|
def dev(args):
|
||||||
"""
|
"""
|
||||||
Run the application in development mode using docker-compose.
|
Run the application in development mode using docker-compose.
|
||||||
|
|
||||||
Command:
|
|
||||||
FLASK_ENV=development docker-compose up -d
|
|
||||||
|
|
||||||
This command sets the FLASK_ENV environment variable to 'development'
|
|
||||||
and starts the application using docker-compose, enabling hot-reloading.
|
|
||||||
"""
|
"""
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env["FLASK_ENV"] = "development"
|
env["FLASK_ENV"] = "development"
|
||||||
command = ["docker-compose", "up", "-d"]
|
command = ["docker-compose", "up", "-d"]
|
||||||
print("Setting FLASK_ENV=development")
|
print("▶️ Starting in development mode (FLASK_ENV=development)")
|
||||||
run_command(command, args.dry_run)
|
run_command(command, args.dry_run, env=env)
|
||||||
|
|
||||||
def prod(args):
|
def prod(args):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user