Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ filterwarnings = [
dev = [
"pre-commit>=4.3.0",
"pytest-asyncio>=1.0.0",
"watchfiles>=1.1.1",
]

[tool.mypy]
Expand Down
4 changes: 2 additions & 2 deletions scripts/gunicorn_managing_uvicorn_workers/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,7 +20,7 @@ CONTACT_NAME="Me"
CONTACT_EMAIL="[email protected]"
LICENSE_NAME="MIT"

# ------------- database -------------
# ------------- database -------------
POSTGRES_USER="postgres"
POSTGRES_PASSWORD=1234
POSTGRES_SERVER="db"
Expand Down
29 changes: 14 additions & 15 deletions scripts/gunicorn_managing_uvicorn_workers/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
web:
build:
build:
context: .
dockerfile: Dockerfile
# -------- Both of the following commands should be commented to run with nginx --------
Expand All @@ -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"
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -109,4 +109,3 @@ services:
volumes:
postgres-data:
redis-data:

2 changes: 1 addition & 1 deletion scripts/local_with_uvicorn/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion scripts/local_with_uvicorn/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ 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

# Set the working directory
WORKDIR /code

# -------- replace with comment to run with gunicorn --------
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload", "--reload-include", ".env"]
# CMD ["gunicorn", "app.main:app", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "-b", "0.0.0.0:8000"]
40 changes: 16 additions & 24 deletions scripts/local_with_uvicorn/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,38 @@
services:
web:
build:
build:
context: .
dockerfile: Dockerfile
# -------- Both of the following commands should be commented to run with nginx --------

# -------- replace with comment to run with gunicorn --------
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
# -------- replace with expose if you are using nginx --------
environment:
# Enable polling for file changes on macOS/Windows Docker Desktop
- WATCHFILES_FORCE_POLLING=true
ports:
- "8000:8000"
# expose:
# - "8000"
depends_on:
- db
- redis
volumes:
- ./src/app:/code/app
- ./src/.env:/code/.env
- .env:/code/.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:/code/.env

db:
image: postgres:13
env_file:
- ./src/.env
- .env
volumes:
- postgres-data:/var/lib/postgresql/data
expose:
Expand All @@ -64,11 +57,11 @@ services:

#-------- uncomment to create first superuser --------
create_superuser:
build:
build:
context: .
dockerfile: Dockerfile
env_file:
- ./src/.env
- .env
depends_on:
- db
- web
Expand All @@ -78,11 +71,11 @@ services:

#-------- uncomment to run tests --------
pytest:
build:
build:
context: .
dockerfile: Dockerfile
dockerfile: Dockerfile
env_file:
- ./src/.env
- .env
depends_on:
- db
- create_superuser
Expand All @@ -93,11 +86,11 @@ services:

#-------- uncomment to create first tier --------
# create_tier:
# build:
# build:
# context: .
# dockerfile: Dockerfile
# env_file:
# - ./src/.env
# - .env
# depends_on:
# - create_superuser
# - db
Expand All @@ -109,4 +102,3 @@ services:
volumes:
postgres-data:
redis-data:

4 changes: 2 additions & 2 deletions scripts/production_with_nginx/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,7 +20,7 @@ CONTACT_NAME="Me"
CONTACT_EMAIL="[email protected]"
LICENSE_NAME="MIT"

# ------------- database -------------
# ------------- database -------------
POSTGRES_USER="postgres"
POSTGRES_PASSWORD=1234
POSTGRES_SERVER="db"
Expand Down
28 changes: 14 additions & 14 deletions scripts/production_with_nginx/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
web:
build:
build:
context: .
dockerfile: Dockerfile
# -------- Both of the following commands should be commented to run with nginx --------
Expand All @@ -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"
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading