version: '3.8'

services:
  # PostgreSQL Database
  postgres:
    image: postgres:16-alpine
    container_name: memos-postgres
    restart: unless-stopped
    environment:
      POSTGRES_DB: memos
      POSTGRES_USER: memos
      POSTGRES_PASSWORD: zcA3LEfW
      PGDATA: /var/lib/postgresql/data/pgdata
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U memos -d memos"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - memos-network

  # Memos Application
  memos:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: memos-app
    restart: unless-stopped
    ports:
      - "8081:8081"
    environment:
      # Database configuration
      MEMOS_DRIVER: postgres
      MEMOS_DSN: "postgres://memos:zcA3LEfW@postgres:5432/memos?sslmode=disable"

      # Application configuration
      MEMOS_MODE: prod
      MEMOS_PORT: 8081
      MEMOS_DATA: /var/opt/memos

      # Optional: Set your instance URL
      # MEMOS_INSTANCE_URL: "https://your-domain.com"
    volumes:
      - memos_data:/var/opt/memos
    depends_on:
      postgres:
        condition: service_healthy
    networks:
      - memos-network

volumes:
  postgres_data:
    driver: local
  memos_data:
    driver: local

networks:
  memos-network:
    driver: bridge