Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8b12cbf
feat: update staging compose for demo/preview deployments
mihow Mar 18, 2026
b3d9771
fix: upgrade gunicorn 20.1.0 → 23.0.0
mihow Mar 18, 2026
1bb2646
fix: address PR review feedback
mihow Mar 18, 2026
d5e8f6f
fix: remove host port bindings from internal services
mihow Mar 18, 2026
7f75f98
docs: add staging deployment guide
mihow Mar 18, 2026
6b699b7
fix: increase DATA_UPLOAD_MAX_MEMORY_SIZE for ML worker results
mihow Mar 24, 2026
91a7f49
fix(celery): use Redis DB 1 for result backend, separate from cache
mihow Mar 25, 2026
c845143
docs(celery): add comments explaining CELERY_RESULT_EXTENDED impact
mihow Mar 25, 2026
14c26f5
fix(redis): add redis.conf, disable bgsave, add CELERY_RESULT_EXPIRES
mihow Mar 26, 2026
bd649a9
Merge branch 'main' into feat/update-staging-compose
mihow Apr 1, 2026
f12610f
chore(staging): add .compose-example and deploy.sh script
mihow Apr 1, 2026
fea3af2
fix(settings): use urllib.parse for Redis DB URL rewriting
mihow Apr 1, 2026
87b8c12
docs(staging): add reverse proxy section with nginx example
mihow Apr 1, 2026
1f2db69
fix(staging): deploy.sh should pull, not just fetch
mihow Apr 1, 2026
47e9fdd
fix(staging): add branch/host echo to deploy.sh before deploying
mihow Apr 1, 2026
095c6fa
docs(staging): clarify staging vs production, explain .envs/.producti…
mihow Apr 1, 2026
9a3b020
docs(staging): note potential rename to demo in future release
mihow Apr 1, 2026
076258f
fix: sort stdlib imports in base.py (isort)
mihow Apr 1, 2026
d0a8f1d
fix: unused import
mihow Apr 1, 2026
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
37 changes: 37 additions & 0 deletions compose/staging/docker-compose.db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Optional local PostgreSQL for staging environments.
#
# Use this when you don't have an external database (e.g., for local testing
# or isolated branch previews). Creates a containerized PostgreSQL instance
# that the staging compose stack connects to via the Docker network.
#
# Usage:
# # Start the database first
# docker compose -f compose/staging/docker-compose.db.yml up -d
#
# # Then start the app (DATABASE_IP points to the host's Docker bridge)
# docker compose -f docker-compose.staging.yml --env-file .envs/.production/.compose up -d
#
# The app's .envs/.production/.postgres should use POSTGRES_HOST=db and the
# DATABASE_IP in .envs/.production/.compose should be set to the host IP
# of the machine running this database container (e.g., 172.17.0.1 for the
# default Docker bridge, or the host's LAN IP).
#
# For ood-style setups where the DB runs on the same host, set:
# DATABASE_IP=172.17.0.1 (or use host.docker.internal on Docker Desktop)

volumes:
staging_postgres_data: {}

services:
postgres:
build:
context: ../../
dockerfile: ./compose/local/postgres/Dockerfile
volumes:
- staging_postgres_data:/var/lib/postgresql/data
- ../../data/db/snapshots:/backups
env_file:
- ../../.envs/.production/.postgres
ports:
- "5432:5432"
restart: always
74 changes: 38 additions & 36 deletions docker-compose.staging.yml
Original file line number Diff line number Diff line change
@@ -1,79 +1,81 @@
# Identical to production.yml, but with the following differences:
# Uses the django production settings file, but staging .env file.
# Uses "local" database
# Staging / demo / branch preview deployment.
#
# 1. The database is a service in the Docker Compose configuration rather than external as in production.
# 2. Redis is a service in the Docker Compose configuration rather than external as in production.
# 3. Port 5001 is exposed for the Django application.

volumes:
ami_local_postgres_data: {}
# Like production, but runs Redis, RabbitMQ, and NATS as local containers
# instead of requiring external infrastructure services.
# Database is always external — set DATABASE_IP in .envs/.production/.compose.
#
# Usage:
# docker compose -f docker-compose.staging.yml --env-file .envs/.production/.compose up -d
#
# For a local database, see compose/staging/docker-compose.db.yml.
#
# Required env files:
# .envs/.production/.compose — DATABASE_IP
# .envs/.production/.django — Django settings, CELERY_BROKER_URL, NATS_URL, etc.
# .envs/.production/.postgres — POSTGRES_HOST=db, POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD

services:
django: &django
build:
context: .
# This is the most important setting to test the production configuration of Django.
dockerfile: ./compose/production/django/Dockerfile

image: insectai/ami_backend
depends_on:
- postgres
- redis
# - nats
- rabbitmq
- nats
env_file:
- ./.envs/.production/.django
- ./.envs/.local/.postgres
- ./.envs/.production/.postgres
volumes:
- ./config:/app/config
ports:
- "5001:5000"
extra_hosts:
- "db:${DATABASE_IP}"
command: /start
restart: always

postgres:
build:
context: .
# There is not a local/staging version of the Postgres Dockerfile.
dockerfile: ./compose/local/postgres/Dockerfile
# Share the local Postgres image with the staging configuration.
# Production uses an external Postgres service.
volumes:
- ami_local_postgres_data:/var/lib/postgresql/data
- ./data/db/snapshots:/backups
env_file:
- ./.envs/.local/.postgres
restart: always

redis:
image: redis:6
restart: always

celeryworker:
<<: *django
scale: 1
ports: []
command: /start-celeryworker
restart: always

celerybeat:
<<: *django
ports: []
command: /start-celerybeat
restart: always

flower:
<<: *django
ports:
- "5550:5555"
command: /start-flower
restart: always
volumes:
- ./data/flower/:/data/

redis:
image: redis:6
restart: always

rabbitmq:
image: rabbitmq:3.13-management-alpine
hostname: rabbitmq
ports:
- "15672:15672"
restart: always

nats:
image: nats:2.10-alpine
container_name: ami_local_nats
hostname: nats
ports:
- "4222:4222" # Client port
- "8222:8222" # HTTP monitoring port
command: ["-js", "-m", "8222"] # Enable JetStream and monitoring
- "4222:4222"
- "8222:8222"
command: ["-js", "-m", "8222"]
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8222/healthz"]
interval: 10s
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,5 @@ pytest-django==4.5.2 # https://github.com/pytest-dev/pytest-django
# ------------------------------------------------------------------------------

newrelic==9.6.0
gunicorn==20.1.0 # https://github.com/benoitc/gunicorn
gunicorn==23.0.0 # https://github.com/benoitc/gunicorn
# psycopg[c]==3.1.9 # https://github.com/psycopg/psycopg
Loading