version: "3.4"

services:

  backend:
    image: ${BACKEND_CI_DEV_IMAGE:-baserow_backend_dev:latest}
    environment:
      SECRET_KEY: test
      PUBLIC_BACKEND_URL: http://backend:8000
      PUBLIC_WEB_FRONTEND_URL: http://web-frontend:3000
      BASEROW_AMOUNT_OF_WORKERS: 2
      BASEROW_TRIGGER_SYNC_TEMPLATES_AFTER_MIGRATION: false
      DJANGO_SETTINGS_MODULE: 'baserow.config.settings.e2e'
      AWS_ACCESS_KEY_ID: anyvalue
      AWS_SECRET_ACCESS_KEY: anyvalue
      AWS_STORAGE_BUCKET_NAME: testbucket
      AWS_S3_ENDPOINT_URL: http://s3mock:9090
      AWS_S3_CUSTOM_DOMAIN: localhost:9090/testbucket
      AWS_S3_USE_SSL: no
      AWS_S3_URL_PROTOCOL: "http:"
    command:
      - gunicorn

  web-frontend:
    image: ${WEBFRONTEND_CI_DEV_IMAGE:-baserow_web-frontend_dev:latest}
    environment:
      PUBLIC_BACKEND_URL: http://backend:8000
      PUBLIC_WEB_FRONTEND_URL: http://web-frontend:3000
    command:
      - nuxt-dev-no-attach

  celery:
    image: ${BACKEND_CI_DEV_IMAGE:-baserow_backend_dev:latest}
    environment:
      BASEROW_RUN_MINIMAL: 'yes'
      BASEROW_AMOUNT_OF_WORKERS: 1
      SECRET_KEY: test
      AWS_ACCESS_KEY_ID: anyvalue
      AWS_SECRET_ACCESS_KEY: anyvalue
      AWS_STORAGE_BUCKET_NAME: testbucket
      AWS_S3_ENDPOINT_URL: http://s3mock:9090
      AWS_S3_CUSTOM_DOMAIN: localhost:9090/testbucket
      AWS_S3_USE_SSL: no
      AWS_S3_URL_PROTOCOL: "http:"
    command: celery-worker

  e2e-tests:
    image: ${E2E_TEST_IMAGE:-baserow_e2e-tests:latest}
    build:
      dockerfile: ./Dockerfile
      context: .
    environment:
      PUBLIC_BACKEND_URL: http://backend:8000
      PUBLIC_WEB_FRONTEND_URL: http://web-frontend:3000
      CI: 1
      DEBUG: "pw:api"
    depends_on:
      - backend
      - web-frontend
    volumes:
      - /baserow/e2e-tests/node_modules
      - $PWD:/baserow/e2e-tests
    command: "bash -c './wait-for-services.sh && yarn run ${E2E_TEST_YARN_RUN_CMD:-test}'"
    stdin_open: true
    tty: true

  db:
    image: postgres:${POSTGRES_IMAGE_VERSION:-12}
    environment:
      - POSTGRES_USER=baserow
      - POSTGRES_PASSWORD=baserow
      - POSTGRES_DB=baserow

  s3mock:
    container_name: s3mock
    image: adobe/s3mock:latest
    environment:
      initialBuckets: testbucket

  redis:
    image: redis:6