Skip to content

Commit

Permalink
Move docker-compose to frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
thenav56 committed Apr 30, 2024
1 parent 84b7a73 commit 1b7e943
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ build-ssr
*.sw?

.env
.env.prod
.eslintcache
tsconfig.tsbuildinfo

Expand Down
2 changes: 1 addition & 1 deletion backend
126 changes: 126 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: alert-hub # NOTE: Define COMPOSE_PROJECT_NAME in .env to use custom name

x-server: &base_server_setup
build:
context: ./backend/
# To attach to container with stdin `docker attach <container_name>`
# Used for python debugging.
stdin_open: true
tty: true
extra_hosts:
- 'host.docker.internal:host-gateway'
env_file:
- .env
environment: &base_server_setup_environment
DJANGO_APP_ENVIRONMENT: ${DJANGO_APP_ENVIRONMENT:-development}
DJANGO_APP_TYPE: web
DJANGO_DEBUG: ${DJANGO_DEBUG:-true}
DJANGO_SECRET_KEY: ${DJANGO_SECRET_KEY?error},
# -- Domain configurations
DJANGO_ALLOWED_HOSTS: ${DJANGO_ALLOWED_HOSTS:-*}
APP_DOMAIN: localhost:8000
APP_HTTP_PROTOCOL: ${APP_HTTP_PROTOCOL:-http}
APP_FRONTEND_HOST: ${APP_FRONTEND_HOST:-http://localhost:3000}
SESSION_COOKIE_DOMAIN: ${SESSION_COOKIE_DOMAIN:-localhost}
CSRF_COOKIE_DOMAIN: ${CSRF_COOKIE_DOMAIN:-localhost}
# Database config
DB_HOST: ${DB_HOST:-db}
DB_PORT: ${DB_PORT:-5432}
DB_NAME: ${DB_NAME:-postgres}
DB_USER: ${DB_USER:-postgres}
DB_PASSWORD: ${DB_PASSWORD:-postgres}
# Redis config
CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis:6379/0}
CACHE_REDIS_URL: ${CACHE_REDIS_URL:-redis://redis:6379/1}
# Email config
EMAIL_HOST: ${EMAIL_HOST:-mailpit}
EMAIL_PORT: ${EMAIL_PORT:-1025}
EMAIL_HOST_USER: ${EMAIL_HOST_USER:-mailpit}
EMAIL_HOST_PASSWORD: ${EMAIL_HOST_PASSWORD:-mailpit}
DEFAULT_FROM_EMAIL: ${DEFAULT_FROM_EMAIL:-alert-hub-dev <[email protected]>}
volumes:
- ./backend/:/code
- backend_data:/data/
- ipython_data_local:/root/.ipython/profile_default # persist ipython data, including ipython history
depends_on:
- db
- redis
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "5"


x-worker: &base_worker_setup
<<: *base_server_setup
environment:
<<: *base_server_setup_environment
DJANGO_APP_TYPE: worker
healthcheck:
test: ["CMD-SHELL", "celery -A main inspect ping -d celery@$$HOSTNAME || exit 1"]
interval: 30s
timeout: 5s
retries: 3
start_period: 30s


services:
db:
image: postgis/postgis:13-3.1-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
volumes:
- postgres-data13:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER"]
interval: 10s
timeout: 5s
retries: 5

redis:
image: redis:6-alpine
volumes:
- redis-data:/data
healthcheck:
test: ["CMD-SHELL", "redis-cli ping"]
interval: 10s
timeout: 5s
retries: 5

mailpit:
image: axllent/mailpit
ports:
- 127.0.0.1:8025:8025 # HTTP
environment:
MP_MAX_MESSAGES: 5000
MP_DATA_FILE: /data/mailpit.db
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_AUTH_ALLOW_INSECURE: 1
volumes:
- mailpit-data:/data

web:
<<: *base_server_setup
command: bash -c 'wait-for-it $$DB_HOST:$$DB_PORT && ./manage.py runserver 0.0.0.0:8000'
ports:
- 127.0.0.1:8000:8000

worker:
<<: *base_worker_setup
# TODO: Use run_celery_dev
command: bash -c 'celery -A main worker -l info --pool=solo'

worker-beat:
<<: *base_worker_setup
command: bash -c 'celery -A main beat -l info'


volumes:
postgres-data13:
redis-data:
ipython_data_local:
mailpit-data:
backend_data:

0 comments on commit 1b7e943

Please sign in to comment.