#!/bin/sh
set -e

rsync -rlDog --chown $USER:$GROUPNAME --delete --exclude=/storage /src/ /var/www/html
install -d -m 0755 -o $USER -g $GROUPNAME \
  storage \
  storage/framework \
  storage/framework/cache \
  storage/framework/sessions \
  storage/framework/views \
  storage/app \
  storage/app/private \
  storage/logs

php artisan migrate --force

rm .dockerignore
rm .editorconfig
rm .env.example
rm .gitattributes
rm .gitignore
rm Makefile
rm README.md
rm docker-compose.dev
rm docker-compose.prod
rm justfile
rm phpunit.xml
rm -rf node_modules
rm composer.lock
rm package-lock.json
rm package.json
rm -rf docker
rm -rf database
rm -rf app/Installer

exec "php-fpm"
