#!/usr/bin/env bash

set -e

role=${CONTAINER_ROLE:-app}
env=${APP_ENV:-production}

#if [ "$env" != "local" ]; then
##    echo "Caching configuration..."
##    (cd /var/www/html && php artisan config:cache && php artisan route:cache && php artisan view:cache)
#fi

if [ "$role" = "app" ]; then
    chown -R www-data:www-data /var/www/
    chmod -R 750 /var/www/app/
    chmod -R 770 /var/www/app/storage/
    exec /usr/sbin/apache2ctl -D FOREGROUND -f /etc/apache2/apache2.conf

else
    echo "Could not match the container role \"$role\""
    exit 1
fi
