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:

142 changes: 89 additions & 53 deletions scripts/local_with_uvicorn/.env.example
Original file line number Diff line number Diff line change
@@ -1,72 +1,108 @@
# ============================================================================
# WARNING: EXAMPLE CONFIGURATION - DO NOT USE IN PRODUCTION AS-IS
# ENVIRONMENT CONFIGURATION EXAMPLE
# ============================================================================
# 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
# 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
# WARNING:
# This file contains example values for LOCAL DEVELOPMENT AND TESTING only.
#
# DOCKER COMPOSE USAGE:
# This file is NOT required when running locally with docker-compose.
# Default settings in the application code work out of the box.
#
# WHEN TO USE THIS FILE:
# - Testing with external databases or services
# - Overriding default settings found in /src/app/core/config.py
#
# DEPLOYMENTS:
# DO NOT use an .env file to modify the default settings.
# Instead, set environment variables in your deployment host or platform.
#
# SECURITY NOTE:
# Before deploying, you MUST use different sensitive values:
# • SECRET_KEY (generate a new one: openssl rand -hex 32)
# • All passwords (POSTGRES_PASSWORD, ADMIN_PASSWORD, etc.)
# • Usernames for admin and database users
#
# Using these example values in production is a SECURITY RISK.
# ============================================================================

# ------------- app settings -------------
APP_NAME="My Project"
APP_DESCRIPTION="My Project Description"
APP_VERSION="0.1"
CONTACT_NAME="Me"
CONTACT_EMAIL="[email protected]"
LICENSE_NAME="MIT"
# APP_NAME="My Project"
# APP_VERSION="0.1"
# APP_DESCRIPTION="My Project Description"
# LICENSE_NAME="MIT"
# CONTACT_NAME="Me"
# CONTACT_EMAIL="[email protected]"

# ------------- environment -------------
# ENVIRONMENT="local"

# ------------- database -------------
POSTGRES_USER="postgres"
POSTGRES_PASSWORD=1234
POSTGRES_SERVER="db"
POSTGRES_PORT=5432
POSTGRES_DB="postgres"
POSTGRES_ASYNC_PREFIX="postgresql+asyncpg://"
# ------------- crypt settings -------------
# SECRET_KEY=de2132a4a3a029d6a93a2aefcb519f0219990f92ca258a7c5ed938a444dbe1c8
# ALGORITHM=HS256
# ACCESS_TOKEN_EXPIRE_MINUTES=30
# REFRESH_TOKEN_EXPIRE_DAYS=7

# ------------- crypt -------------
SECRET_KEY=de2132a4a3a029d6a93a2aefcb519f0219990f92ca258a7c5ed938a444dbe1c8
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=60
# ------------- postgres settings -------------
# POSTGRES_USER="myappuser"
# POSTGRES_PASSWORD=r8andomP@ssw0rd!
# POSTGRES_SERVER="10.0.0.50"
# POSTGRES_PORT=5432
# POSTGRES_DB="myappdb"
# POSTGRES_SYNC_PREFIX="postgresql://"
# POSTGRES_ASYNC_PREFIX="postgresql+asyncpg://"

# ------------- admin -------------
ADMIN_NAME="admin"
ADMIN_EMAIL="[email protected]"
ADMIN_USERNAME="admin"
ADMIN_PASSWORD="Str1ngst!"
# ------------- first user settings -------------
# ADMIN_NAME="admin"
# ADMIN_EMAIL="[email protected]"
# ADMIN_USERNAME="admin"
# ADMIN_PASSWORD="Str1ngst!"

# ------------- redis cache -------------
REDIS_CACHE_HOST="redis"
REDIS_CACHE_PORT=6379
# ------------- test settings -------------
# TEST_NAME="Tester User"
# TEST_EMAIL="[email protected]"
# TEST_USERNAME="testeruser"
# TEST_PASSWORD="Str1ngT3st!"

# ------------- redis queue -------------
REDIS_QUEUE_HOST="redis"
REDIS_QUEUE_PORT=6379
# ------------- redis cache settings -------------
# REDIS_CACHE_HOST="10.0.0.90"
# REDIS_CACHE_PORT=6379

# ------------- redis rate limit -------------
REDIS_RATE_LIMIT_HOST="redis"
REDIS_RATE_LIMIT_PORT=6379
# ------------- redis queue settings -------------
# REDIS_QUEUE_HOST="10.0.0.90"
# REDIS_QUEUE_PORT=6379

# ------------- client side cache -------------
CLIENT_CACHE_MAX_AGE=60
# ------------- redis rate limiter settings -------------
# REDIS_RATE_LIMIT_HOST="10.0.0.90"
# REDIS_RATE_LIMIT_PORT=6379

# ------------- CORS -------------
CORS_ORIGINS=["*"]
CORS_METHODS=["*"]
CORS_HEADERS=["*"]
# ------------- client side cache settings -------------
# CLIENT_CACHE_MAX_AGE=60

# ------------- test -------------
TEST_NAME="Tester User"
TEST_EMAIL="[email protected]"
TEST_USERNAME="testeruser"
TEST_PASSWORD="Str1ngT3st!"
# ------------- default rate limit settings -------------
# DEFAULT_RATE_LIMIT_LIMIT=10
# DEFAULT_RATE_LIMIT_PERIOD=3600

# ------------- environment -------------
ENVIRONMENT="local"
# ------------- crud admin settings -------------
# CRUD_ADMIN_ENABLED=True
# CRUD_ADMIN_MOUNT_PATH="/admin"
# CRUD_ADMIN_ALLOWED_IPS_LIST=None
# CRUD_ADMIN_ALLOWED_NETWORKS_LIST=None
# CRUD_ADMIN_MAX_SESSIONS=10
# CRUD_ADMIN_SESSION_TIMEOUT=1440
# SESSION_SECURE_COOKIES=True
# CRUD_ADMIN_TRACK_EVENTS=True
# CRUD_ADMIN_TRACK_SESSIONS=True
# CRUD_ADMIN_REDIS_ENABLED=False
# CRUD_ADMIN_REDIS_HOST="localhost"
# CRUD_ADMIN_REDIS_PORT=6379
# CRUD_ADMIN_REDIS_DB=0
# CRUD_ADMIN_REDIS_PASSWORD=None
# CRUD_ADMIN_REDIS_SSL=False

# ------------- CORS -------------
# CORS_ORIGINS=["*"]
# CORS_METHODS=["*"]
# CORS_HEADERS=["*"]

# ------------- first tier -------------
TIER_NAME="free"
# TIER_NAME="free"
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"]
Loading