#!/bin/bash

set -e
cd "$(dirname "$0")/.."

# load .env
. functions.sh
load_env

if [ -z "$ENABLE_WEBHOOKS" ]; then
    echo "ERROR: ENABLE_WEBHOOKS must be set to true, otherwise the image would not be built"
    exit 1
fi

if [ -z "$ENABLE_RECORDING" ]; then
    echo "ERROR: ENABLE_RECORDING must be set to true, otherwise the image would not be built"
    exit 1
fi


# generate compose file
./scripts/generate-compose

# ensure submodules are matching tags.env
./scripts/checkout-submodules

# build and push java base image
docker build -t alangecker/bbb-docker-base-java:latest mod/base-java

# buld and push other images
docker compose build

# push images
docker push alangecker/bbb-docker-base-java:latest
docker compose push \
    html5-backend-1 \
    bbb-web \
    freeswitch \
    apps-akka \
    bbb-pads \
    etherpad \
    fsesl-akka \
    jodconverter \
    nginx \
    periodic \
    recordings \
    webhooks \
    webrtc-sfu