#!/bin/bash -ex
#
# NB: The order of files in the ./build statements controls the TAP_SCHEMA.schemas.schema_index
# values that control the presentation order of schemas.  This is respected by the Portal Aspect.
#

# Create a shared buildx builder
docker buildx create --name tap-schema --driver docker-container \
       --platform linux/amd64 --platform linux/arm64

./build mock

# TAP services based on production Qserv at USDF:
./build idfprod-tap ../yml/dp1.yaml ../yml/ivoa_obscore.yaml ../yml/dp02_dc2.yaml
./build usdf-prod-tap ../yml/dp1.yaml ../yml/ivoa_obscore.yaml ../yml/dp02_dc2.yaml

# TAP services based on development Qserv at USDF:
./build idfint-tap ../yml/dp1.yaml ../yml/ivoa_obscore.yaml ../yml/dp02_dc2.yaml
./build idfdev-tap ../yml/dp1.yaml ../yml/ivoa_obscore.yaml ../yml/dp02_dc2.yaml
./build idfdemo-tap ../yml/dp1.yaml ../yml/ivoa_obscore.yaml ../yml/dp02_dc2.yaml
./build usdf-dev-tap ../yml/dp1.yaml ../yml/ivoa_obscore.yaml ../yml/dp02_dc2.yaml

# TAP services based on "live ObsCore" from the Butler Postgres server
./build usdf-prod-livetap ../yml/oga_live_obscore.yaml
./build usdf-dev-livetap ../yml/oga_live_obscore.yaml

# TAP services based on the DP0.3 Postgres data
./build idfprod-sso ../yml/dp03_10yr.yaml ../yml/dp03_1yr.yaml
./build idfint-sso ../yml/dp03_10yr.yaml ../yml/dp03_1yr.yaml
./build idfdev-sso ../yml/dp03_10yr.yaml ../yml/dp03_1yr.yaml
./build idfdemo-sso ../yml/dp03_10yr.yaml ../yml/dp03_1yr.yaml
./build usdf-prod-sso ../yml/dp03_10yr.yaml ../yml/dp03_1yr.yaml
./build usdf-dev-sso ../yml/dp03_10yr.yaml ../yml/dp03_1yr.yaml

FELIS_UNIQUE_KEYS=1 ./build usdf-dev-cdb ../yml/{cdb,efd}_*.yaml
FELIS_UNIQUE_KEYS=1 ./build usdf-prod-cdb ../yml/{cdb,efd}_*.yaml

docker buildx rm tap-schema
