version: "3"

services:
  common: &common
    image: foundationdb/foundationdb-build:0.1.24

  build-setup: &build-setup
    <<: *common
    depends_on: [common]
    volumes:
      - ..:/__this_is_some_very_long_name_dir_needed_to_fix_a_bug_with_debug_rpms__/foundationdb
    working_dir: /__this_is_some_very_long_name_dir_needed_to_fix_a_bug_with_debug_rpms__/foundationdb
    environment:
      - MAKEJOBS=1
      - USE_CCACHE=1
      - BUILD_DIR=./work

  release-setup: &release-setup
    <<: *build-setup
    environment:
      - MAKEJOBS=1
      - USE_CCACHE=1
      - RELEASE=true
      - BUILD_DIR=./work

  snapshot-setup: &snapshot-setup
    <<: *build-setup

  build-docs:
    <<: *build-setup
    volumes:
      - ..:/foundationdb
    working_dir: /foundationdb
    command: scl enable devtoolset-8 python27 rh-python36 rh-ruby24 -- bash -c 'make -j "$${MAKEJOBS}" docpackage'


  release-packages: &release-packages
    <<: *release-setup
    command: scl enable devtoolset-8 rh-python36 rh-ruby24 -- bash -c 'make -j "$${MAKEJOBS}" packages'

  snapshot-packages: &snapshot-packages
    <<: *build-setup
    command: scl enable devtoolset-8 rh-python36 rh-ruby24 -- bash -c 'make -j "$${MAKEJOBS}" packages'

  prb-packages:
    <<: *snapshot-packages


  release-bindings: &release-bindings
    <<: *release-setup
    command: scl enable devtoolset-8 rh-python36 rh-ruby24 -- bash -c 'make -j "$${MAKEJOBS}" bindings'

  snapshot-bindings: &snapshot-bindings
    <<: *build-setup
    command: scl enable devtoolset-8 rh-python36 rh-ruby24 -- bash -c 'make -j "$${MAKEJOBS}" bindings'

  prb-bindings:
    <<: *snapshot-bindings


  snapshot-cmake: &snapshot-cmake
    <<: *build-setup
    command: scl enable devtoolset-8 rh-python36 rh-ruby24 -- bash -c 'mkdir -p "$${BUILD_DIR}" && cd "$${BUILD_DIR}" && cmake -G "Ninja" -DFDB_RELEASE=0 -DUSE_WERROR=ON /__this_is_some_very_long_name_dir_needed_to_fix_a_bug_with_debug_rpms__/foundationdb && ninja -v -j "$${MAKEJOBS}" "packages" "strip_targets" && cpack'

  prb-cmake:
    <<: *snapshot-cmake


  snapshot-bindings-cmake: &snapshot-bindings-cmake
    <<: *build-setup
    command: scl enable devtoolset-8 rh-python36 rh-ruby24 -- bash -c 'mkdir -p "$${BUILD_DIR}" && cd "$${BUILD_DIR}" && cmake -G "Ninja" -DFDB_RELEASE=0 -DUSE_WERROR=ON /__this_is_some_very_long_name_dir_needed_to_fix_a_bug_with_debug_rpms__/foundationdb && ninja -v -j "$${MAKEJOBS}" "bindings/all"'

  prb-bindings-cmake:
    <<: *snapshot-bindings-cmake


  snapshot-cmake: &snapshot-testpackages
    <<: *build-setup
    command: scl enable devtoolset-8 rh-python36 rh-ruby24 -- bash -c 'mkdir -p "$${BUILD_DIR}" && cd "$${BUILD_DIR}" && cmake -G "Ninja" -DFDB_RELEASE=0 /__this_is_some_very_long_name_dir_needed_to_fix_a_bug_with_debug_rpms__/foundationdb && ninja -v -j "$${MAKEJOBS}"'

  prb-testpackages:
    <<: *snapshot-testpackages


  snapshot-ctest: &snapshot-ctest
    <<: *build-setup
    command: scl enable devtoolset-8 rh-python36 rh-ruby24 -- bash -c 'mkdir -p "$${BUILD_DIR}" && cd "$${BUILD_DIR}" && cmake -G "Ninja" -DFDB_RELEASE=1 -DUSE_WERROR=ON /__this_is_some_very_long_name_dir_needed_to_fix_a_bug_with_debug_rpms__/foundationdb && ninja -v -j "$${MAKEJOBS}" && ctest -j "$${MAKEJOBS}" --output-on-failure'

  prb-ctest:
    <<: *snapshot-ctest


  snapshot-correctness: &snapshot-correctness
    <<: *build-setup
    command: scl enable devtoolset-8 rh-python36 rh-ruby24 -- bash -c 'mkdir -p "$${BUILD_DIR}" && cd "$${BUILD_DIR}" && cmake -G "Ninja" -DFDB_RELEASE=1 -DUSE_WERROR=ON /__this_is_some_very_long_name_dir_needed_to_fix_a_bug_with_debug_rpms__/foundationdb && ninja -v -j "$${MAKEJOBS}" && ctest -j "$${MAKEJOBS}" --output-on-failure'

  prb-correctness:
    <<: *snapshot-correctness


  shell:
    <<: *build-setup
    volumes:
      - ..:/foundationdb
    entrypoint: /bin/bash
