added support for init

This commit is contained in:
Shihaam Abdul Rahman 2024-09-08 05:10:29 +05:00
parent 595667e24e
commit 3cf3770bea
Signed by: shihaam
GPG Key ID: 6DA2E87EBC227636
2 changed files with 64 additions and 0 deletions

30
compose.yml Normal file
View File

@ -0,0 +1,30 @@
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

34
helper
View File

@ -10,6 +10,40 @@ elif [[ "$1" == "fix_storage" ]]; then
docker compose exec fpm chmod -R ug+x bootstrap/cache
elif [[ "$1" == "mysql" ]]; then
docker compose exec database "$@"
elif [[ "$1" == "init" ]]; then
cat <<EOL > compose.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 "compose.yml file created successfully!"
else
docker compose exec fpm "$@"
fi