#!/bin/bash

docker run --rm -it -v ${PWD}/app:/app composer install
docker run --rm -it -v ${PWD}/cli:/app composer install

find ./app -name "*.env.sample" | cat -n | while read n f; do
  cp "$f" "${f%.sample}"
done

cp ./cli/.env.sample ./cli/.env

cp ./.env.sample ./.env

echo "API_KEY=$(docker run --rm -it nginx openssl rand -hex 64)" > ./.key.env
printf "MYSQL_ROOT_PASSWORD=%s\nMYSQL_DATABASE=incoviba\nMYSQL_USER=incoviba\nMYSQL_PASSWORD=%s" "$(docker run --rm -it nginx openssl rand -hex 16)" "$(docker run --rm -it nginx openssl rand -hex 64)" > ./app/.db.env

