name: 'your-application-name'

services:
  ${APP_NAME}:
    image: '${APP_IMAGE}'
    container_name: '${APP_NAME}'
    working_dir: '${WORKDIR}'
    ports:
      - '${APP_PORT}:${APP_PORT}'
    env_file:
      - .env
    environment:
      - NODE_ENV=production
      - PORT=${APP_PORT}
    volumes:
      - ./:${WORKDIR}:ro
      # - logs:/var/log/${APP_NAME}
    depends_on:
      db:
        condition: service_healthy
    networks:
      - app-net
    restart: unless-stopped
    healthcheck:
      test: ['CMD', 'curl', '-f', 'http://localhost:${APP_PORT}/health']
      interval: 30s
      timeout: 5s
      retries: 3

  db:
    image: postgres:latest
    container_name: '${APP_NAME}-db'
    environment:
      POSTGRES_USER: user
      POSTGRES_PASSWORD: password
      POSTGRES_DB: ${APP_NAME}_db
    volumes:
      - db-data:/var/lib/postgresql/data
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U user']
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - app-net

networks:
  your-app-networks:
    driver: bridge
