Production Docker infrastructure: multi-stage Dockerfile, nginx reverse proxy, hardened compose with health checks and env validation
Project description
bloque-docker-prod
Production Docker infrastructure for the Bloques ecosystem. Provides multi-stage Dockerfile, nginx reverse proxy, and hardened Docker Compose with health checks, env validation, and resource limits.
This is NOT dev infrastructure. For local development, see
bloque-docker-dev.
Services
| Service | Image | Exposed Port | Profile |
|---|---|---|---|
| nginx | nginx:alpine |
80, 443 | core, ai |
| app | Build from Dockerfile | Internal only | core, ai |
| PostgreSQL 16 | postgres:16-alpine |
Internal only | core, ai |
| Redis 7 | redis:7-alpine |
Internal only | core, ai |
| ChromaDB | chromadb/chroma:latest |
Internal only | ai |
Key difference vs dev: Only nginx exposes ports. All other services are internal to the Docker network.
Quick Start
# Copy env template and set real passwords
cp packages/python/bloque-docker-prod/.env.production.example .env
# Copy and customize Dockerfile
cp packages/python/bloque-docker-prod/Dockerfile.example Dockerfile
# Start core services (nginx + app + PostgreSQL + Redis)
docker compose -f packages/python/bloque-docker-prod/docker-compose.prod.yml --profile core up -d
# Start all services including ChromaDB
docker compose -f packages/python/bloque-docker-prod/docker-compose.prod.yml --profile ai up -d
Environment Validation
from bloque_docker_prod.validate import validate_env, validate_prod_config
# Check required env vars and placeholder passwords
result = validate_env()
if not result.valid:
for error in result.errors:
print(f"ERROR: {error}")
for warning in result.warnings:
print(f"WARNING: {warning}")
# Full config validation (env + SSL)
result = validate_prod_config()
Python API
Load environment variables
from bloque_docker_prod.env import load_prod_env
# Sets DATABASE_URL, REDIS_URL, etc. with Docker service names
defaults = load_prod_env()
print(defaults.postgres_url) # postgresql+asyncpg://bloques:CHANGE_ME@postgres:5432/bloques_prod
Health checks
import asyncio
from bloque_docker_prod.health import check_services, wait_for_services
# One-shot check (includes app + nginx)
status = asyncio.run(check_services())
# {"postgres": True, "redis": True, "app": True, "nginx": True}
# Wait until all services are ready
status = asyncio.run(wait_for_services(max_wait=60.0))
Nginx
nginx/nginx.conf- Main config (workers, gzip, includes)nginx/conf.d/default.conf- Upstream app, proxy, rate limiting, security headersnginx/conf.d/ssl.conf.example- TLS template (copy and set cert paths)
Init SQL
initdb/01-extensions.sql- pgcrypto, uuid-osspinitdb/02-production-defaults.sql- App user, statement_timeout, schema grants
Dependencies
ulfblk-core(required)httpx(HTTP health checks)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ulfblk_docker_prod-0.1.0.tar.gz.
File metadata
- Download URL: ulfblk_docker_prod-0.1.0.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02d4850700041d261ddd07bf7bcac56eaa4fac78cd37ef2320a41d2c0e2109c8
|
|
| MD5 |
401a17d904d26a23b414428a55b2ba39
|
|
| BLAKE2b-256 |
696bcc2a568fa9cf289db09e3172c6c3ca9d9dddbfe2133bbac39fb335805545
|
File details
Details for the file ulfblk_docker_prod-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ulfblk_docker_prod-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54f10669b496c20eace315b86f865615a6fd75d741bd0ef6d229a6a949f489aa
|
|
| MD5 |
0032a3769346e74346ba0b65cd55541a
|
|
| BLAKE2b-256 |
9b79f3da926a45dc7e786b6225e58b9f310c9bd674c3277965e5ccc26b6dbae1
|