---
version: '3'
services:
  umami:
    build: ../
    #image: ghcr.io/umami-software/umami:postgresql-latest
    ports:
      - '3000:3000'
    environment:
      DATABASE_URL: postgresql://umami:umami@db:5432/umami
      DATABASE_TYPE: postgresql
      APP_SECRET: replace-me-with-a-random-string
    depends_on:
      db:
        condition: service_healthy
    restart: always
    healthcheck:
      test: ['CMD-SHELL', 'curl http://localhost:3000/api/heartbeat']
      interval: 5s
      timeout: 5s
      retries: 5
  db:
    image: postgres:15-alpine
    environment:
      POSTGRES_DB: umami
      POSTGRES_USER: umami
      POSTGRES_PASSWORD: umami
    volumes:
      - umami-db-data:/var/lib/postgresql/data
    restart: always
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}']
      interval: 5s
      timeout: 5s
      retries: 5
  cypress:
    image: 'cypress/included:13.6.0'
    depends_on:
      - umami
      - db
    environment:
      - CYPRESS_baseUrl=http://umami:3000
      - CYPRESS_umami_user=admin
      - CYPRESS_umami_password=umami
    volumes:
      - ./tsconfig.json:/tsconfig.json
      - ../cypress.config.ts:/cypress.config.ts
      - ./:/cypress
      - ../node_modules/:/node_modules
      - ../src/lib/crypto.ts:/src/lib/crypto.ts
volumes:
  umami-db-data:
