sbt-idp/docker-compose.yml

199 lines
5.7 KiB
YAML
Raw Normal View History

2023-12-15 10:34:24 +00:00
2023-11-30 11:19:06 +00:00
# TODO: use docker-compose extend: for compact purpose
2023-12-06 12:39:53 +00:00
version: '3.0'
2023-11-30 11:19:06 +00:00
networks:
2023-12-05 05:59:37 +00:00
ctel-sbt:
2023-11-30 11:19:06 +00:00
driver: bridge
services:
2023-12-11 06:36:49 +00:00
cope2n-fi-sbt:
2023-11-30 11:19:06 +00:00
shm_size: 10gb
2023-12-21 05:55:14 +00:00
mem_limit: 10gb
2023-12-11 13:14:19 +00:00
restart: always
2023-12-21 05:55:14 +00:00
image: public.ecr.aws/v4n9y6r8/sidp/cope2n-ai-fi-sbt:{{tag}}
2023-11-30 11:19:06 +00:00
networks:
2023-12-05 05:59:37 +00:00
- ctel-sbt
2023-11-30 11:19:06 +00:00
privileged: true
environment:
2023-12-11 06:36:49 +00:00
- CELERY_BROKER=amqp://${RABBITMQ_DEFAULT_USER}:${RABBITMQ_DEFAULT_PASS}@rabbitmq-sbt:5672
2023-11-30 11:19:06 +00:00
working_dir: /workspace/cope2n-ai-fi
command: bash run.sh
2023-12-05 05:59:37 +00:00
deploy:
mode: replicated
2023-12-21 05:55:14 +00:00
replicas: 2
2023-11-30 11:19:06 +00:00
# Back-end services
2023-12-11 06:36:49 +00:00
be-ctel-sbt:
2023-11-30 11:19:06 +00:00
environment:
- MEDIA_ROOT=${MEDIA_ROOT}
- DB_ENGINE=${DB_ENGINE}
- DB_SCHEMA=${DB_SCHEMA}
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}
2023-12-06 12:39:53 +00:00
- DB_HOST=${DB_HOST}
2023-11-30 11:19:06 +00:00
- DB_PORT=${DB_PUBLIC_PORT}
- DEBUG=${DEBUG}
- CORS_ALLOWED_ORIGINS=${CORS_ALLOWED_ORIGINS}
- BASE_PORT=${BASE_PORT}
- CTEL_KEY=${CTEL_KEY}
- SECRET_KEY=${SECRET_KEY}
2023-12-14 03:54:03 +00:00
- DB_INTERNAL_KEY=${DB_INTERNAL_KEY}
2023-11-30 11:19:06 +00:00
- ALLOWED_HOSTS=${ALLOWED_HOSTS}
2023-12-11 06:36:49 +00:00
- BROKER_URL=amqp://${RABBITMQ_DEFAULT_USER}:${RABBITMQ_DEFAULT_PASS}@rabbitmq-sbt:5672
- BASE_URL=http://be-ctel-sbt:${BASE_PORT}
2023-11-30 11:19:06 +00:00
- BASE_UI_URL=http://fe:${VITE_PORT}
- AUTH_TOKEN_LIFE_TIME=${AUTH_TOKEN_LIFE_TIME}
- IMAGE_TOKEN_LIFE_TIME=${IMAGE_TOKEN_LIFE_TIME}
- INTERNAL_SDS_KEY=${INTERNAL_SDS_KEY}
- FI_USER_NAME=${FI_USER_NAME}
- FI_PASSWORD=${FI_PASSWORD}
2023-12-15 09:19:46 +00:00
- S3_ENDPOINT=${S3_ENDPOINT}
2023-11-30 11:19:06 +00:00
- S3_ACCESS_KEY=${S3_ACCESS_KEY}
- S3_SECRET_KEY=${S3_SECRET_KEY}
- S3_BUCKET_NAME=${S3_BUCKET_NAME}
2023-12-13 09:01:31 +00:00
restart: always
2023-12-21 05:55:14 +00:00
mem_limit: 10gb
image: public.ecr.aws/v4n9y6r8/sidp/cope2n-be-fi-sbt:{{tag}}
2023-11-30 11:19:06 +00:00
networks:
2023-12-05 05:59:37 +00:00
- ctel-sbt
2023-11-30 11:19:06 +00:00
volumes:
- ${HOST_MEDIA_FOLDER}:${MEDIA_ROOT}
2023-12-21 05:55:14 +00:00
- BE_static:/app/static
2023-11-30 11:19:06 +00:00
working_dir: /app
2023-12-12 05:54:34 +00:00
depends_on:
db-sbt:
condition: service_started
2023-12-15 10:34:24 +00:00
command: sh -c "chmod -R 777 /app/static; sleep 5; python manage.py collectstatic --no-input &&
2023-11-30 11:19:06 +00:00
python manage.py migrate &&
python manage.py compilemessages &&
2023-12-12 10:07:46 +00:00
gunicorn fwd.asgi:application -k uvicorn.workers.UvicornWorker --timeout 300 -b 0.0.0.0:9000" # pre-makemigrations on prod
2023-12-12 05:54:34 +00:00
minio:
image: minio/minio
environment:
2023-12-14 03:54:03 +00:00
- MINIO_ROOT_USER=${S3_ACCESS_KEY}
- MINIO_ROOT_PASSWORD=${S3_SECRET_KEY}
2023-12-12 05:54:34 +00:00
- MINIO_ACCESS_KEY=${S3_ACCESS_KEY}
- MINIO_SECRET_KEY=${S3_SECRET_KEY}
volumes:
- ./data/minio_data:/data
networks:
- ctel-sbt
2023-12-15 07:12:23 +00:00
restart: always
2023-12-12 05:54:34 +00:00
command: server --address :9884 --console-address :9885 /data
2023-12-14 03:54:03 +00:00
profiles: ["local"]
createbuckets:
image: minio/mc
depends_on:
- minio
entrypoint: >
/bin/sh -c "
/usr/bin/mc alias set myminio http://minio:9884 ${S3_ACCESS_KEY} ${S3_SECRET_KEY};
/usr/bin/mc mb myminio/${S3_BUCKET_NAME};
/usr/bin/mc policy set public myminio/${S3_BUCKET_NAME};
exit 0;
"
networks:
- ctel-sbt
profiles: ["local"]
2023-11-30 11:19:06 +00:00
2023-12-13 11:43:10 +00:00
result-cache:
image: redis:6.2-alpine
restart: always
2023-12-21 05:55:14 +00:00
mem_limit: 10gb
2023-12-13 11:43:10 +00:00
command: redis-server --save 20 1 --loglevel warning
networks:
- ctel-sbt
2023-12-11 06:36:49 +00:00
be-celery-sbt:
2023-11-30 11:19:06 +00:00
environment:
- MEDIA_ROOT=${MEDIA_ROOT}
- PYTHONPATH=${PYTHONPATH}:/app # For import module
- PYTHONUNBUFFERED=1 # For show print log
2023-12-05 05:59:37 +00:00
- DB_ENGINE=${DB_ENGINE}
2023-11-30 11:19:06 +00:00
- DB_SCHEMA=${DB_SCHEMA}
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}
2023-12-06 12:39:53 +00:00
- DB_HOST=${DB_HOST}
2023-12-05 05:59:37 +00:00
- DB_PORT=${DB_PUBLIC_PORT}
2023-12-11 06:36:49 +00:00
- BROKER_URL=amqp://${RABBITMQ_DEFAULT_USER}:${RABBITMQ_DEFAULT_PASS}@rabbitmq-sbt:5672
2023-12-15 10:34:24 +00:00
- BASE_UI_URL=http://fe:${VITE_PORT}
2023-11-30 11:19:06 +00:00
- DEBUG=${DEBUG}
2023-12-14 03:54:03 +00:00
- DB_INTERNAL_KEY=${DB_INTERNAL_KEY}
2023-12-06 12:39:53 +00:00
- IMAGE_TOKEN_LIFE_TIME=${IMAGE_TOKEN_LIFE_TIME}
- CTEL_KEY=${CTEL_KEY}
- SECRET_KEY=${SECRET_KEY}
- ALLOWED_HOSTS=${ALLOWED_HOSTS}
2023-12-15 09:19:46 +00:00
- S3_ENDPOINT=${S3_ENDPOINT}
2023-11-30 11:19:06 +00:00
- S3_ACCESS_KEY=${S3_ACCESS_KEY}
- S3_SECRET_KEY=${S3_SECRET_KEY}
- S3_BUCKET_NAME=${S3_BUCKET_NAME}
2023-12-11 06:36:49 +00:00
- BASE_URL=http://be-ctel-sbt:${BASE_PORT}
2023-12-13 11:43:10 +00:00
- REDIS_HOST=result-cache
- REDIS_PORT=6379
2023-12-15 07:12:23 +00:00
restart: always
2023-12-21 05:55:14 +00:00
image: public.ecr.aws/v4n9y6r8/sidp/cope2n-be-fi-sbt:{{tag}}
2023-11-30 11:19:06 +00:00
networks:
2023-12-05 05:59:37 +00:00
- ctel-sbt
2023-11-30 11:19:06 +00:00
depends_on:
2023-12-11 06:36:49 +00:00
db-sbt:
2023-11-30 11:19:06 +00:00
condition: service_started
2023-12-11 06:36:49 +00:00
rabbitmq-sbt:
2023-11-30 11:19:06 +00:00
condition: service_started
volumes:
- ${HOST_MEDIA_FOLDER}:${MEDIA_ROOT}
working_dir: /app
2023-12-15 09:19:46 +00:00
command: sh -c "celery -A fwd_api.celery_worker.worker worker -l INFO -c 5"
2023-12-12 05:54:34 +00:00
2023-11-30 11:19:06 +00:00
# Back-end persistent
2023-12-11 06:36:49 +00:00
db-sbt:
2023-12-15 07:12:23 +00:00
restart: always
2023-11-30 11:19:06 +00:00
mem_reservation: 500m
image: postgres:14.7-alpine
volumes:
2023-12-12 05:54:34 +00:00
- ./data/postgres_data:/var/lib/postgresql/data
2023-11-30 11:19:06 +00:00
networks:
2023-12-05 05:59:37 +00:00
- ctel-sbt
2023-11-30 11:19:06 +00:00
environment:
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_DB=${DB_SCHEMA}
2023-12-21 05:55:14 +00:00
profiles: ["local"]
2023-11-30 11:19:06 +00:00
2023-12-11 06:36:49 +00:00
rabbitmq-sbt:
2023-11-30 11:19:06 +00:00
mem_reservation: 600m
restart: always
image: rabbitmq:3.10-alpine
working_dir: /workspace/cope2n-api
networks:
2023-12-05 05:59:37 +00:00
- ctel-sbt
2023-11-30 11:19:06 +00:00
environment:
- RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER}
- RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASS}
2023-12-13 09:01:31 +00:00
2023-11-30 11:19:06 +00:00
# Front-end services
2023-12-06 10:14:37 +00:00
fe-sbt:
2023-12-15 07:12:23 +00:00
restart: always
2023-12-21 05:55:14 +00:00
mem_limit: 4gb
2023-12-06 10:14:37 +00:00
shm_size: 10gb
2023-12-21 05:55:14 +00:00
image: public.ecr.aws/v4n9y6r8/sidp/cope2n-fe-fi-sbt:{{tag}}
2023-12-06 10:14:37 +00:00
privileged: true
ports:
2023-12-15 10:34:24 +00:00
- 80:80
2023-12-06 10:14:37 +00:00
depends_on:
2023-12-11 06:36:49 +00:00
be-ctel-sbt:
2023-12-06 10:14:37 +00:00
condition: service_started
2023-12-11 06:36:49 +00:00
be-celery-sbt:
2023-12-06 10:14:37 +00:00
condition: service_started
2023-11-30 11:19:06 +00:00
environment:
2023-12-11 06:36:49 +00:00
- VITE_PROXY=http://be-ctel-sbt:${BASE_PORT}
2023-12-06 12:39:53 +00:00
- VITE_API_BASE_URL=http://fe-sbt:80
volumes:
2023-12-21 05:55:14 +00:00
- BE_static:/backend-static
2023-11-30 11:19:06 +00:00
networks:
2023-12-05 05:59:37 +00:00
- ctel-sbt
2023-12-06 12:39:53 +00:00
2023-11-30 11:19:06 +00:00
volumes:
db_data:
2023-12-21 05:55:14 +00:00
BE_static: