version: "3.9"

services:
  app:
    image: node:20-alpine
    container_name: info-node-app
    working_dir: /app
    command: sh -c "npm install && node server.js"
    volumes:
      - ./app:/app
      - ./checks:/app/checks
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - "3000:3000"
    depends_on:
      - db
    environment:
      DB_HOST: db
      DB_USER: postgres
      DB_PASSWORD: postgres
      DB_NAME: infodb
      DB_PORT: 5432
    restart: unless-stopped

  db:
    image: postgres:16-alpine
    container_name: info-postgres
    restart: unless-stopped
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: infodb
    volumes:
      - ./pgdata:/var/lib/postgresql/data
      - ./db/init.sql:/docker-entrypoint-initdb.d/init.sql
    ports:
      - "5432:5432"
