#!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

. $SCRIPT_DIR/_settings.sh || {
  echo "no settings" && exit 1
}

cd "$SCRIPT_DIR/.."

set -e

for PHP_VERSION in "${PHP_VERSIONS[@]}"; do
    echo
    echo "Rebuilding: PHP ${PHP_VERSION}"
    echo

    PHP_SERVICE="php${PHP_VERSION}"
    WORKSPACE_SERVICE="workspace${PHP_VERSION}"

    bash -ic "dc build ${PHP_SERVICE}"
    bash -ic "dc up -d --force-recreate ${PHP_SERVICE}"

    bash -ic "dc build ${WORKSPACE_SERVICE}"
    bash -ic "dc up -d --force-recreate ${WORKSPACE_SERVICE}"

    echo
done
