version: '3'

services:
  app:
    user: 'node'
    build: 
      context: .
      dockerfile: ./Dockerfile-development
    command: sh -c "yarn install --frozen-lockfile && ./scripts/wait-for-it.sh postgres:5432 -s -t 40 -- npx pubsweet server"
    ports:
      - ${PORT:-3000}:3000
    volumes:
      - ./:/home/xpub
    depends_on:
      - postgres
    environment:
      NODE_ENV: development
      PGHOST: postgres
      PGUSER: $USER

  postgres:
    image: postgres:10
    ports:
      - 5432:5432
    environment:
      POSTGRES_USER: $USER
    volumes:
      - postgres-volume:/var/lib/postgresql/data
      - ./scripts/test.sql:/docker-entrypoint-initdb.d/test.sql

volumes:
  postgres-volume:

