diff --git a/scripts/gunicorn_managing_uvicorn_workers/.env.example b/scripts/gunicorn_managing_uvicorn_workers/.env.example index 1c1e585..84968a9 100644 --- a/scripts/gunicorn_managing_uvicorn_workers/.env.example +++ b/scripts/gunicorn_managing_uvicorn_workers/.env.example @@ -4,7 +4,7 @@ # This file contains example values for development/testing purposes only. # # SECURITY CRITICAL: Before deploying to production, you MUST: -# 1. Copy this file to src/.env +# 1. Copy this file to a .env file at the project root # 2. Generate a new SECRET_KEY using: openssl rand -hex 32 # 3. Change all passwords (POSTGRES_PASSWORD, ADMIN_PASSWORD, etc.) # 4. Update all sensitive configuration values @@ -20,7 +20,7 @@ CONTACT_NAME="Me" CONTACT_EMAIL="my.email@example.com" LICENSE_NAME="MIT" -# ------------- database ------------- +# ------------- database ------------- POSTGRES_USER="postgres" POSTGRES_PASSWORD=1234 POSTGRES_SERVER="db" diff --git a/scripts/gunicorn_managing_uvicorn_workers/docker-compose.yml b/scripts/gunicorn_managing_uvicorn_workers/docker-compose.yml index 8b4cefd..8ec38e8 100644 --- a/scripts/gunicorn_managing_uvicorn_workers/docker-compose.yml +++ b/scripts/gunicorn_managing_uvicorn_workers/docker-compose.yml @@ -1,6 +1,6 @@ services: web: - build: + build: context: . dockerfile: Dockerfile # -------- Both of the following commands should be commented to run with nginx -------- @@ -9,7 +9,7 @@ services: # command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload command: gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8000 env_file: - - ./src/.env + - .env # -------- replace with expose if you are using nginx -------- ports: - "8000:8000" @@ -20,26 +20,26 @@ services: - redis volumes: - ./src/app:/code/app - - ./src/.env:/code/.env + - .env:/.env worker: - build: + build: context: . dockerfile: Dockerfile command: arq app.core.worker.settings.WorkerSettings env_file: - - ./src/.env + - .env depends_on: - db - redis volumes: - ./src/app:/code/app - - ./src/.env:/code/.env + - .env:/.env db: image: postgres:13 env_file: - - ./src/.env + - .env volumes: - postgres-data:/var/lib/postgresql/data expose: @@ -64,11 +64,11 @@ services: #-------- uncomment to create first superuser -------- create_superuser: - build: + build: context: . dockerfile: Dockerfile env_file: - - ./src/.env + - .env depends_on: - db - web @@ -78,11 +78,11 @@ services: #-------- uncomment to run tests -------- # pytest: - # build: + # build: # context: . - # dockerfile: Dockerfile + # dockerfile: Dockerfile # env_file: - # - ./src/.env + # - .env # depends_on: # - db # - create_superuser @@ -93,11 +93,11 @@ services: #-------- uncomment to create first tier -------- # create_tier: - # build: + # build: # context: . # dockerfile: Dockerfile # env_file: - # - ./src/.env + # - .env # depends_on: # - create_superuser # - db @@ -109,4 +109,3 @@ services: volumes: postgres-data: redis-data: - \ No newline at end of file diff --git a/scripts/local_with_uvicorn/.env.example b/scripts/local_with_uvicorn/.env.example index c4bf803..8d2b5b6 100644 --- a/scripts/local_with_uvicorn/.env.example +++ b/scripts/local_with_uvicorn/.env.example @@ -4,7 +4,7 @@ # This file contains example values for development/testing purposes only. # # SECURITY CRITICAL: Before deploying to production, you MUST: -# 1. Copy this file to src/.env +# 1. Copy this file to a .env file at the project root # 2. Generate a new SECRET_KEY using: openssl rand -hex 32 # 3. Change all passwords (POSTGRES_PASSWORD, ADMIN_PASSWORD, etc.) # 4. Update all sensitive configuration values diff --git a/scripts/local_with_uvicorn/Dockerfile b/scripts/local_with_uvicorn/Dockerfile index 13c1d92..14571c9 100644 --- a/scripts/local_with_uvicorn/Dockerfile +++ b/scripts/local_with_uvicorn/Dockerfile @@ -33,6 +33,9 @@ COPY --from=builder --chown=app:app /app/.venv /app/.venv # Ensure the virtual environment is in the PATH ENV PATH="/app/.venv/bin:$PATH" +# Force file watching to use polling, which is more reliable in some Docker environments (like WSL/macOS) +ENV WATCHFILES_FORCE_POLLING=true + # Switch to the non-root user USER app diff --git a/scripts/local_with_uvicorn/docker-compose.yml b/scripts/local_with_uvicorn/docker-compose.yml index 12a0ee8..e41c2c9 100644 --- a/scripts/local_with_uvicorn/docker-compose.yml +++ b/scripts/local_with_uvicorn/docker-compose.yml @@ -13,7 +13,7 @@ services: - redis volumes: - ./src/app:/code/app - - ./src/.env:/code/.env + - .env:/code/.env worker: build: @@ -21,18 +21,18 @@ services: dockerfile: Dockerfile command: arq app.core.worker.settings.WorkerSettings env_file: - - ./src/.env + - .env depends_on: - db - redis volumes: - ./src/app:/code/app - - ./src/.env:/code/.env + - .env:/code/.env db: image: postgres:13 env_file: - - ./src/.env + - .env volumes: - postgres-data:/var/lib/postgresql/data expose: @@ -61,7 +61,7 @@ services: context: . dockerfile: Dockerfile env_file: - - ./src/.env + - .env depends_on: - db - web @@ -75,7 +75,7 @@ services: context: . dockerfile: Dockerfile env_file: - - ./src/.env + - .env depends_on: - db - create_superuser @@ -90,7 +90,7 @@ services: # context: . # dockerfile: Dockerfile # env_file: - # - ./src/.env + # - .env # depends_on: # - create_superuser # - db diff --git a/scripts/production_with_nginx/.env.example b/scripts/production_with_nginx/.env.example index 6f9c5d6..faacc1a 100644 --- a/scripts/production_with_nginx/.env.example +++ b/scripts/production_with_nginx/.env.example @@ -4,7 +4,7 @@ # This file contains example values for development/testing purposes only. # # SECURITY CRITICAL: Before deploying to production, you MUST: -# 1. Copy this file to src/.env +# 1. Copy this file to a .env file at the project root # 2. Generate a new SECRET_KEY using: openssl rand -hex 32 # 3. Change all passwords (POSTGRES_PASSWORD, ADMIN_PASSWORD, etc.) # 4. Update all sensitive configuration values @@ -20,7 +20,7 @@ CONTACT_NAME="Me" CONTACT_EMAIL="my.email@example.com" LICENSE_NAME="MIT" -# ------------- database ------------- +# ------------- database ------------- POSTGRES_USER="postgres" POSTGRES_PASSWORD=1234 POSTGRES_SERVER="db" diff --git a/scripts/production_with_nginx/docker-compose.yml b/scripts/production_with_nginx/docker-compose.yml index 77c6296..9ed7f9a 100644 --- a/scripts/production_with_nginx/docker-compose.yml +++ b/scripts/production_with_nginx/docker-compose.yml @@ -1,6 +1,6 @@ services: web: - build: + build: context: . dockerfile: Dockerfile # -------- Both of the following commands should be commented to run with nginx -------- @@ -9,7 +9,7 @@ services: # command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload command: gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8000 env_file: - - ./src/.env + - .env # -------- replace ports with expose if you are using nginx -------- # ports: # - "8000:8000" @@ -20,26 +20,26 @@ services: - redis volumes: - ./src/app:/code/app - - ./src/.env:/code/.env + - .env:/.env worker: - build: + build: context: . dockerfile: Dockerfile command: arq app.core.worker.settings.WorkerSettings env_file: - - ./src/.env + - .env depends_on: - db - redis volumes: - ./src/app:/code/app - - ./src/.env:/code/.env + - .env:/.env db: image: postgres:13 env_file: - - ./src/.env + - .env volumes: - postgres-data:/var/lib/postgresql/data expose: @@ -64,11 +64,11 @@ services: #-------- uncomment to create first superuser -------- # create_superuser: - # build: + # build: # context: . # dockerfile: Dockerfile # env_file: - # - ./src/.env + # - .env # depends_on: # - db # - web @@ -78,11 +78,11 @@ services: #-------- uncomment to run tests -------- # pytest: - # build: + # build: # context: . - # dockerfile: Dockerfile + # dockerfile: Dockerfile # env_file: - # - ./src/.env + # - .env # depends_on: # - web # - redis @@ -92,11 +92,11 @@ services: #-------- uncomment to create first tier -------- # create_tier: - # build: + # build: # context: . # dockerfile: Dockerfile # env_file: - # - ./src/.env + # - .env # depends_on: # - create_superuser # - db diff --git a/setup.py b/setup.py index ea0c717..25b720f 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -""" -FastAPI Boilerplate Setup Script +"""FastAPI Boilerplate Setup Script. Automates copying the correct configuration files for different deployment scenarios. """ @@ -29,7 +28,7 @@ def show_help(): - """Display help information""" + """Display help information.""" print("FastAPI Boilerplate Setup") print("=" * 25) print() @@ -47,7 +46,7 @@ def show_help(): def copy_files(deployment_type: str): - """Copy configuration files for the specified deployment type""" + """Copy configuration files for the specified deployment type.""" if deployment_type not in DEPLOYMENTS: print(f"❌ Unknown deployment type: {deployment_type}") print() @@ -68,7 +67,7 @@ def copy_files(deployment_type: str): files_to_copy = [ ("Dockerfile", "Dockerfile"), ("docker-compose.yml", "docker-compose.yml"), - (".env.example", "src/.env"), + (".env.example", ".env"), ] success = True @@ -115,7 +114,7 @@ def copy_files(deployment_type: str): def interactive_setup(): - """Interactive setup when no arguments provided""" + """Interactive setup when no arguments provided.""" print("FastAPI Boilerplate Setup") print("=" * 25) print() @@ -152,7 +151,7 @@ def interactive_setup(): def main(): - """Main entry point""" + """Main entry point.""" if len(sys.argv) > 1 and sys.argv[1] in ["-h", "--help", "help"]: show_help() return