version: "3"

services:
  kutt:
    build: .
    depends_on: # comment out of using postgres outside of docker
      - postgres
      - redis
    volumes:
      - .:/usr/src/app  # Mount the source code for development
      - /usr/src/app/node_modules  # Use node_modules from inside the container
    ports:
      - "3000:3000" #local machine port: docker port
    env_file:
      - .env  
    environment:
      NODE_ENV: development
      # DB_HOST: postgres
      # DB_USER: zachao
      REDIS_HOST: redis
    command: npm run dev  # Assuming this starts your app in a development mode with hot reloading
  redis: #comment out to use redis outside of docker on local machine
    image: redis:6.0-alpine
    volumes:
      - redis_data:/data
  postgres: # comment these out if using postgres outside of docker
    image: postgres:12-alpine
    environment:
      POSTGRES_USER: zachao
      POSTGRES_PASSWORD:
      POSTGRES_DB: kutt
    volumes:
      - postgres_data:/opt/homebrew/var/postgresql@14
volumes: # comment these out if using postgres outside of docker
  redis_data:
  postgres_data: