services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    environment:
      - TINA_PUBLIC_IS_LOCAL=false
      - NEXTAUTH_SECRET=${NEXTAUTH_SECRET}
      - NEXTAUTH_URL=${NEXTAUTH_URL:-http://localhost:3000}
      - TINA_GIT_BRANCH=${TINA_GIT_BRANCH:-main}
      - KV_REST_API_URL=http://redis-http:80
      - KV_REST_API_TOKEN=${KV_REST_API_TOKEN}
      - NEXT_PUBLIC_SITE_URL=${NEXT_PUBLIC_SITE_URL:-https://docs.linumiq.com}
    depends_on:
      redis-http:
        condition: service_started
      redis:
        condition: service_started
    networks:
      - tinadocs
    restart: unless-stopped

  redis:
    image: redis:7-alpine
    command: redis-server --requirepass ${REDIS_PASSWORD}
    volumes:
      - redis-data:/data
    networks:
      - tinadocs
    restart: unless-stopped

  redis-http:
    image: hiett/serverless-redis-http:latest
    environment:
      - SRH_MODE=env
      - SRH_TOKEN=${KV_REST_API_TOKEN}
      - SRH_CONNECTION_STRING=redis://:${REDIS_PASSWORD}@redis:6379
    depends_on:
      redis:
        condition: service_started
    networks:
      - tinadocs
    restart: unless-stopped

volumes:
  redis-data:

networks:
  tinadocs:
    driver: bridge
