networks: houshan-network: volumes: houshan-postgres: services: # --------------------------------- # API Service (Your Python App) # --------------------------------- app: build: . container_name: basa_api networks: - houshan-network env_file: - .api.env restart: always labels: - "autoheal=true" healthcheck: test: [ "CMD", "curl", "--fail", "--max-time", "10", "http://localhost:8000/category/", ] interval: 30s timeout: 10s retries: 2 # --------------------------------- # Autoheal Service # --------------------------------- autoheal: image: willfarrell/autoheal restart: unless-stopped environment: - AUTOHEAL_CONTAINER_LABEL=autoheal - AUTOHEAL_DEFAULT_STOP_TIMEOUT=10 volumes: - /var/run/docker.sock:/var/run/docker.sock networks: - houshan-network # --------------------------------- # Database Service # --------------------------------- # postgres: # image: postgres:17-alpine # volumes: # - houshan-postgres:/var/lib/postgresql/data # environment: # POSTGRES_DB: ${API_DB_NAME} # POSTGRES_USER: ${API_DB_USER} # POSTGRES_PASSWORD: ${API_DB_PASS} # ports: # - 54921:5432 # networks: # - houshan-network # healthcheck: # test: [ "CMD", "pg_isready", "-q", "-d", "${API_DB_NAME}", "-U", "${API_DB_USER}" ] # interval: 10s # timeout: 5s # retries: 3 # start_period: 60s # restart: unless-stopped # --------------------------------- # Database Backup Service # --------------------------------- # backups: # image: postgres:17-alpine # command: >- # sh -c 'echo "Starting backups service" && sleep "${API_DB_BACKUP_DELAY}" && # while true; do # echo "Running pg_dump" && pg_dump -h postgres -p 5432 -d "${API_DB_NAME}" -U "${API_DB_USER}" | gzip > "/srv/houshan-postgres/backups/houshan-postgres-backup-$(date "+%Y-%m-%d_%H-%M").sql" && # echo "Keeping last 3 backups" && ls -1t "/srv/houshan-postgres/backups/houshan-postgres-backup-"*.gz | tail -n +4 | xargs rm -f && # echo "Sleeping for ${API_DB_BACKUP_INTERVAL}" && sleep "${API_DB_BACKUP_INTERVAL}"; done' # volumes: # - ./db-backup/houshan-postgres-backup:/var/lib/postgresql/data # - ./db-backup/houshan-database-backups:/srv/houshan-postgres/backups # environment: # PGPASSWORD: ${API_DB_PASS} # networks: # - houshan-network # restart: unless-stopped # depends_on: # postgres: # condition: service_healthy # backups: # image: postgres:17-alpine # command: ["/bin/sh", "/usr/local/bin/backup.sh"] # volumes: # - ./backup.sh:/usr/local/bin/backup.sh # - ./db-backup/houshan-database-backups:/srv/houshan-postgres/backups # environment: # PGPASSWORD: ${API_DB_PASS} # API_DB_BACKUP_DELAY: ${API_DB_BACKUP_DELAY} # API_DB_BACKUP_INTERVAL: ${API_DB_BACKUP_INTERVAL} # API_DB_NAME: ${API_DB_NAME} # API_DB_USER: ${API_DB_USER} # networks: # - houshan-network # restart: unless-stopped # depends_on: # postgres: # condition: service_healthy # --------------------------------- # Frontend Service (Your Flutter App) # --------------------------------- # web: #build: # context: ./frontend # networks: # - houshan-network # restart: unless-stopped # --------------------------------- # Main Reverse Proxy (Nginx) # --------------------------------- proxy: image: nginx:alpine ports: - "80:80" volumes: - ./proxy/nginx.conf:/etc/nginx/conf.d/default.conf:ro networks: - houshan-network restart: unless-stopped