#
# Usage: docker-compose --env-file .env.test -f config/docker/docker-compose.test.yaml -p danbooru run -T danbooru
#
# Docker Compose file to create an instance of danbooru along with a test database and run the test suite.
#
# https://docs.docker.com/compose/compose-file/
#

version: '3'
services:
  danbooru:
    build:
      context: ../..
      dockerfile: config/docker/Dockerfile.danbooru
    environment:
      - DATABASE_URL=postgresql://danbooru:danbooru@postgres/danbooru
      - ARCHIVE_DATABASE_URL=postgresql://danbooru:danbooru@postgres/danbooru
      - PARALLEL_WORKERS=8 # number of parallel tests to run
      - DANBOORU_SECRET_KEY_BASE=1234
      - DANBOORU_AWS_SQS_ENABLED
      - DANBOORU_TWITTER_API_KEY
      - DANBOORU_TWITTER_API_SECRET
      - DANBOORU_PIXIV_LOGIN
      - DANBOORU_PIXIV_PASSWORD
      - DANBOORU_NIJIE_LOGIN
      - DANBOORU_NIJIE_PASSWORD
      - DANBOORU_NICO_SEIGA_LOGIN
      - DANBOORU_NICO_SEIGA_PASSWORD
      - DANBOORU_TUMBLR_CONSUMER_KEY
      - DANBOORU_DEVIANTART_CLIENT_ID
      - DANBOORU_DEVIANTART_CLIENT_SECRET
      - DANBOORU_PAWOO_CLIENT_ID
      - DANBOORU_PAWOO_CLIENT_SECRET
      - DANBOORU_RAKISMET_KEY
      - DANBOORU_RAKISMET_URL
      - DANBOORU_IP_REGISTRY_API_KEY
    depends_on:
      - postgres
    user: root
    entrypoint: ["bash", "-c", "apt-get -y install build-essential ruby-dev zlib1g-dev postgresql-server-dev-all git && config/docker/prepare-tests.sh && bin/rails test"]
  postgres:
    build:
      context: .
      dockerfile: Dockerfile.postgres
    environment:
      POSTGRES_USER: danbooru
      POSTGRES_PASSWORD: danbooru
