#!/bin/bash # Function to handle PHP Artisan commands php() { docker compose exec fpm "${@}" } # 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 handle NPM commands npm() { docker compose exec node npm "${@}" } # Function to initialize the composer.yml file init() { cat < 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 node: hostname: node image: node:lts volumes: - ./:/var/www/html/ working_dir: /var/www/html EOL echo "composer.yml file created successfully!" }