# Strapi CMS only – run locally in Docker, using PostgreSQL on the HOST machine
# From this folder: docker compose up -d
# Then open http://localhost:1337/admin
#
# Uses host network to avoid Docker bridge/iptables issues. Strapi and Meilisearch
# use the host network; Postgres is on the host (127.0.0.1).

services:
  meilisearch:
    image: getmeili/meilisearch:v1.11
    container_name: nrel-cms-meilisearch
    restart: unless-stopped
    network_mode: host
    environment:
      MEILI_MASTER_KEY: ${MEILISEARCH_MASTER_KEY:-}
      MEILI_ENV: production
    volumes:
      - meilisearch_data:/meili_data

  strapi:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: nrel-cms
    restart: unless-stopped
    network_mode: host
    env_file: .env
    environment:
      NODE_ENV: production
      HOST: 0.0.0.0
      PORT: 1337
      DATABASE_CLIENT: postgres
      DATABASE_HOST: 127.0.0.1
      DATABASE_PORT: ${DATABASE_PORT:-5432}
      DATABASE_NAME: ${DATABASE_NAME:-nre}
      DATABASE_USERNAME: ${DATABASE_USERNAME:-postgres}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD:-postgres}
      DATABASE_SSL: "false"
      MEILISEARCH_HOST: http://127.0.0.1:7700
      PUBLIC_URL: ${STRAPI_PUBLIC_URL:-http://localhost:1337}
      FRONTEND_URL: ${FRONTEND_URL:-http://localhost:3000}
    volumes:
      - cms_uploads:/app/public/uploads
    depends_on:
      - meilisearch

volumes:
  meilisearch_data:
  cms_uploads:
