version: "3"

services:

  common: &common
    image: foundationdb-build:0.0.4
    build:
      context: .
      dockerfile: Dockerfile

  build-setup: &build-setup
    <<: *common
    depends_on: [common]
    #debuginfo builds need the build path to be longer than
    #the path where debuginfo sources are places. Crazy, yes,
    #see the manual for CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX.
    volumes:
      - ../..:/foundationdb/deep/directory/as/debuginfo/doesnt/work/otherwise/foundationdb
      - ${BUILDDIR}:/foundationdb/deep/directory/as/debuginfo/doesnt/work/otherwise/build
    working_dir: /foundationdb/deep/directory/as/debuginfo/doesnt/work/otherwise/build

  configure: &configure
    <<: *build-setup
    command: scl enable devtoolset-7 rh-ruby24 rh-python36 python27 -- bash ../foundationdb/build/cmake/build.sh configure

  build: &build
    <<: *build-setup
    command: scl enable devtoolset-7 rh-ruby24 rh-python36 python27 -- bash ../foundationdb/build/cmake/build.sh build

  build-fast: &build-fast
    <<: *build-setup
    command: scl enable devtoolset-7 rh-ruby24 rh-python36 python27 -- bash ../foundationdb/build/cmake/build.sh build/fast

  rpm: &rpm
    <<: *build-setup
    command: scl enable devtoolset-7 rh-ruby24 rh-python36 python27 -- bash ../foundationdb/build/cmake/build.sh rpm

  deb: &deb
    <<: *build-setup
    command: scl enable devtoolset-7 rh-ruby24 rh-python36 python27 -- bash ../foundationdb/build/cmake/build.sh deb

  package: &package
    <<: *build-setup
    command: scl enable devtoolset-7 rh-ruby24 rh-python36 python27 -- bash ../foundationdb/build/cmake/build.sh package

  package-fast: &package-fast
    <<: *build-setup
    command: scl enable devtoolset-7 rh-ruby24 rh-python36 python27 -- bash ../foundationdb/build/cmake/build.sh package/fast

  test-fast: &test-fast
    <<: *build-setup
    command: scl enable devtoolset-7 rh-ruby24 rh-python36 python27 -- bash ../foundationdb/build/cmake/build.sh test-fast

  test: &test
    <<: *build-setup
    command: scl enable devtoolset-7 rh-ruby24 rh-python36 python27 -- bash ../foundationdb/build/cmake/build.sh test

  snowflake-ci: &snowflake-ci
    <<: *build-setup
    command: scl enable devtoolset-7 rh-ruby24 rh-python36 python27 -- bash ../foundationdb/build/cmake/build.sh package test-fast

  shell:
    <<: *build-setup
    command: scl enable devtoolset-7 rh-ruby24 rh-python36 python27 -- bash

