Files
backend/stack.yaml
2025-12-03 00:16:16 +05:00

203 lines
4.3 KiB
YAML

version: "3.8"
services:
postgres:
image: postgres:17.1-alpine
environment:
- POSTGRES_USER=postgres
- POSTGRES_DB=uzxarid
- POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password
secrets:
- postgres_password
networks:
- uzxarid
volumes:
- pg_data:/var/lib/postgresql/data:rw
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.role == manager
restart_policy:
condition: any
max_attempts: 0
update_config:
parallelism: 1
order: start-first
failure_action: rollback
monitor: 30s
delay: 30s
max_failure_ratio: 0.2
resources:
limits:
cpus: '1.00'
memory: 512M
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres -d uzxarid" ]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
redis:
image: redis:7-alpine
command: [ "redis-server", "--appendonly", "yes" ]
networks:
- uzxarid
volumes:
- redis_data:/data:rw
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.role == manager
restart_policy:
condition: any
update_config:
parallelism: 1
order: start-first
failure_action: rollback
monitor: 30s
delay: 30s
max_failure_ratio: 0.2
resources:
limits:
cpus: '0.50'
memory: 256M
healthcheck:
test: [ "CMD", "redis-cli", "ping" ]
interval: 15s
timeout: 10s
retries: 5
start_period: 15s
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
web:
image: jscorptech/uzxarid:latest
env_file:
- .env
environment:
- PYTHONPYCACHEPREFIX=/var/cache/pycache
- DJANGO_SETTINGS_MODULE=config.settings.production
networks:
- uzxarid
volumes:
- logs:/code/resources/logs/:rw
- media:/code/resources/media/:rw
- static:/code/resources/staticfiles/:rw
- pycache:/var/cache/pycache:rw
tmpfs:
- /tmp
- /run
deploy:
mode: replicated
replicas: 1
restart_policy:
condition: any
update_config:
parallelism: 1
order: start-first
failure_action: rollback
monitor: 30s
delay: 30s
max_failure_ratio: 0.2
resources:
limits:
cpus: '1.50'
memory: 1024M
healthcheck:
test: [ "CMD-SHELL", "curl -f http://localhost:8000/health/ || exit 1" ]
interval: 15s
timeout: 15s
retries: 5
start_period: 30s
logging:
driver: json-file
options:
max-size: "50m"
max-file: "5"
nginx:
image: jscorptech/nginx:latest
ports:
- mode: ingress
target: 80
published: 8034
protocol: tcp
volumes:
- type: bind
source: ./resources/layout/nginx.conf
target: /etc/nginx/nginx.conf
read_only: true
- media:/usr/share/nginx/html/resources/media/:ro
- static:/usr/share/nginx/html/resources/staticfiles/:ro
networks:
- uzxarid
deploy:
mode: global
placement:
constraints:
- node.role == manager
restart_policy:
condition: any
update_config:
parallelism: 1
order: start-first
failure_action: rollback
monitor: 10s
delay: 10s
max_failure_ratio: 0.2
resources:
limits:
cpus: '0.50'
memory: 256M
tmpfs:
- /var/cache/nginx
- /var/run
- /var/tmp
healthcheck:
test: [ "CMD-SHELL", "curl -f http://localhost/health/ || exit 1" ]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
networks:
uzxarid:
driver: overlay
attachable: true
volumes:
media:
driver: local
pg_data:
driver: local
redis_data:
driver: local
pycache:
driver: local
static:
driver: local
logs:
driver: local
secrets:
postgres_password:
external: true