Skip to content

Instantly share code, notes, and snippets.

@dwoodard
Last active February 5, 2021 22:26
Show Gist options
  • Save dwoodard/6da0e5518493f090064460a7260fb18c to your computer and use it in GitHub Desktop.
Save dwoodard/6da0e5518493f090064460a7260fb18c to your computer and use it in GitHub Desktop.
#!/bin/bash
production_path='/root/crg'
env=$(if [ pwd = production_path ]; then echo "prod"; else echo "local"; fi)
# check if .env set
if [ ! -f ".env" ]; then
cp .env.example .env
echo '.env Added '
php artisan key:generate
if [ ! "$env" == 'prod' ]; then
echo 'set env production vars' # change this to artisan command
fi
fi
#check permissions
chmod -R 777 storage
# run laradock
if [ "$env" == 'prod' ]; then
docker-compose --env-file ./laradock/.env.prod -f laradock/docker-compose.yml up -d nginx mysql
else
docker-compose --env-file ./laradock/.env -f laradock/docker-compose.yml up -d nginx mysql phpmyadmin
fi
#check composer packages are installed
export COMPOSER_ALLOW_SUPERUSER=1
if [ ! -d "vendor" ]; then
docker exec -it laradock_workspace_1 sh -c 'composer -n install;'
else
echo 'composer was installed'
fi
#check npm packages are installed
if [ ! -d "node_modules" ]; then
echo 'No dependencies installed. Trying to run npm install.'
docker exec -it laradock_workspace_1 sh -c "npm install"
else
echo 'npm was installed'
fi
#run migrations
docker exec -it laradock_workspace_1 sh -c "php artisan migrate --seed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment