name: reactive-resume

services:
  postgres:
    image: postgres:16-alpine
    restart: unless-stopped
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - resume_net
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
      interval: 10s
      timeout: 5s
      retries: 10

  reactive-resume:
    image: amruthpillai/reactive-resume:latest
    restart: unless-stopped
    env_file:
      - .env
    ports:
      - "127.0.0.1:${LOCAL_APP_PORT}:3000"
    volumes:
      - reactive_resume_data:/app/data
    networks:
      - resume_net
    depends_on:
      postgres:
        condition: service_healthy
    healthcheck:
      test:
        [
          "CMD",
          "node",
          "-e",
          "fetch('http://127.0.0.1:3000/api/health').then((r) => { if (!r.ok) process.exit(1); }).catch(() => process.exit(1));",
        ]
      interval: 30s
      timeout: 10s
      retries: 5

  frpc:
    image: fatedier/frpc:v0.68.0
    restart: unless-stopped
    command: ["-c", "/etc/frp/frpc.yaml"]
    volumes:
      - ./frpc.yaml:/etc/frp/frpc.yaml:ro
    networks:
      - resume_net
    depends_on:
      reactive-resume:
        condition: service_healthy

networks:
  resume_net:
    driver: bridge

volumes:
  postgres_data:
  reactive_resume_data:
