version: '3'

services:
  payload:
    image: node:22-alpine
    ports:
      - '3000:3000'
    volumes:
      - .:/home/node/app
      - node_modules:/home/node/app/node_modules
    working_dir: /home/node/app/
    command: sh -c "corepack enable && corepack prepare pnpm@9.0.0 --activate && pnpm install && pnpm dev"
    depends_on:
      - postgres
    env_file:
      - .env
    networks:
      - payload-network

  postgres:
    restart: always
    image: postgres:16-alpine
    volumes:
      - pgdata:/var/lib/postgresql/data
    ports:
      - '5432:5432'
    environment:
      POSTGRES_USER: payload
      POSTGRES_PASSWORD: payloadpass
      POSTGRES_DB: payload
    networks:
      - payload-network

networks:
  payload-network:
    driver: bridge

volumes:
  pgdata:
  node_modules:
