version: "3"

services:
  ama-frontend:
    network_mode: bridge
    build:
      context: ./ama-frontend
      dockerfile: Dockerfile
    env_file:
      - ./env.ama-frontend
    ports:
      - '19000'
      - '19001'
      - '19002'
    volumes:
      - ./ama-frontend/src:/usr/src/app/src
      - ./ama-frontend/App.tsx:/usr/src/app/App.tsx
    command: npm run expo --non-interactive login && npm start
  ama-backend:
    network_mode: bridge
    depends_on:
      rti-user-preferences-service:
        condition: service_healthy
    build: 
      context: ./ama-frontend
      dockerfile: Dockerfile
    env_file:
      - ./env.ama-backend
    ports:
      - '8080'
  rti-user-preferences-service:
    network_mode: bridge
    depends_on:
      rti-user-preferences-service-database:
        condition: service_healthy
    build: 
      context: ./rti-user-preferences-service
      dockerfile: Dockerfile
    ports:
       - '3333'
    healthcheck:
      test: ["CMD-SHELL", "curl", "localhost:3333/_healthcheck"]
      interval: 10s
      timeout: 5s
      retries: 5
  rti-user-preferences-service-database:
    network_mode: bridge
    build: 
      context: ./rti-user-preferences-service/postgres
      dockerfile: Dockerfile
    ports:
       - '5432'
    healthcheck:
      test: ["CMD-SHELL", "pg_isready"]
      interval: 10s
      timeout: 5s
      retries: 5

# TODO: add image cache
#volumes:
#  image-cache:
#   rti-image-service:
#     command: '-verbose -cache /app/cache -addr 0.0.0.0:8080'
#     image: 'ghcr.io/willnorris/imageproxy:sha256-d1302be69109f2123120c5a6aeb843d7f1ab755812d200c1bf3ec69938ac515a.sig'
#     expose:
#       - 8080
#     ports:
#       - '127.0.0.1:42388:8080'
#     volumes:
#       - image-cache:/app/cache

# TODO: bind mount ama-frontend files and dirs

# # Restart the app
#
# .eslintignor 
# .eslintrc
# metro.config.js
# tsconfig.json
# app.config.json
# app.config.ts
# babel.config.js

# # Normal dev
# src ./src
# assets ./assets
# App.tsx
