version: "3.4"

x-obs: &obs
  image: registry.opensuse.org/opensuse/tools/images/containers153/osrt_miniobs:latest

x-testenv: &testenv
  image: registry.opensuse.org/opensuse/tools/images/containers_tumbleweed/osrt_testenv_tumbleweed:latest
  volumes:
    - "../..:/code"
  privileged: true

services:
  db:
    <<: *obs
    command: /usr/lib/mysql/mysql-systemd-helper start
  cache:
    <<: *obs
    command: /usr/sbin/memcached -u memcached
  api:
    <<: *obs
    command: >
      chroot --userspec=wwwrun / /bin/bash -c "cd /srv/www/obs/api &&
         RAILS_ENV=production rake ts:rebuild &&
         RAILS_ENV=production ./script/delayed_job.api.rb --queues=staging,quick start &&
         /usr/bin/bundle exec rails s -e production"
    depends_on:
      - db
      - cache
      - srcserver
      - repserver
      - servicedispatch
    ports:
      - "0.0.0.0:${OSRT_EXPOSED_OBS_PORT:-3000}:3000"
  srcserver:
    <<: *obs
    command: chroot --userspec=obsrun / /usr/lib/obs/server/bs_srcserver
  repserver:
    <<: *obs
    command: chroot --userspec=obsrun / /usr/lib/obs/server/bs_repserver
  servicedispatch:
    <<: *obs
    command: chroot --userspec=obsrun / /usr/lib/obs/server/bs_servicedispatch
  smtp:
    <<: *testenv
    command: python3 /code/dist/ci/smtp/eml-server.py
  test:
    <<: *testenv
    depends_on:
      - api
      - smtp
    command: /code/dist/ci/docker-compose-test.sh
    cap_add:
      - SYS_PTRACE
  flaker:
    <<: *testenv
    command: /code/dist/ci/docker-compose-flaker.sh

