version: '3'

services:
  app:
    build: 
      context: .
      dockerfile: Dockerfile
    volumes:
      - ..:/workspace:cached

    environment: 
      # FIXME: sqlx-cli and the app use different URIs
      DATABASE_URL: postgresql://postgres:postgres@localhost/postgres
      MAS_DATABASE_URI: postgresql://postgres:postgres@localhost/postgres
      MAS_COOKIES_SECRET: a093e76c2ddc87d9de7afc1f9059d60a12176b2cdf8966029c00bc2146518a61
      
    # Overrides default command so things don't shut down after the process ends.
    command: sleep infinity

    # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
    network_mode: service:db

  db:
    image: postgres:latest
    restart: unless-stopped
    volumes:
      - postgres-data:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: postgres
      POSTGRES_USER: postgres
      POSTGRES_DB: postgres

volumes:
  postgres-data: