2024-09-08 05:31:15 +05:00

67 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# Function to handle PHP Artisan commands
php() {
if [[ "$1" == "artisan" ]]; then
docker compose exec fpm php artisan "${@:2}"
else
echo "Unknown php command"
fi
}
# Function to handle Composer commands
composer() {
docker compose run --rm composer composer "${@}"
}
# Function to handle MySQL commands
mysql() {
docker compose exec database "$@"
}
# Function to fix storage permissions
fix_storage() {
docker compose exec fpm chown -R www-data:www-data storage/
docker compose exec fpm chmod -R ug+rw storage
docker compose exec fpm chmod -R ug+x storage/framework storage/logs
docker compose exec fpm chmod -R ug+rw bootstrap/cache
docker compose exec fpm chmod -R ug+x bootstrap/cache
}
# Function to initialize the composer.yml file
init() {
cat <<EOL > composer.yml
services:
fpm:
hostname: fpm
image: git.shihaam.dev/dockerfiles/php-fpm:8.3
volumes:
- ./:/var/www/html/
nginx:
hostname: nginx
image: git.shihaam.dev/dockerfiles/nginx-fpm:latest
volumes_from:
- fpm
ports:
- 9000:80
composer:
hostname: composer
image: composer:2.7.9
volumes:
- ./:/var/www/html/
working_dir: /var/www/html
database:
image: mariadb:lts
hostname: database
restart: always
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes
- MYSQL_USER=cusport
- MYSQL_PASSWORD=cusport
- MYSQL_DATABASE=cusport
volumes:
- ./.db:/var/lib/mysql
EOL
echo "composer.yml file created successfully!"
}