Compare commits

..

1 Commits

Author SHA1 Message Date
9315b97c66 refactor: переработка Docker-окружения Laravel 2025-12-10 19:37:35 +03:00
6 changed files with 14 additions and 44 deletions

View File

@@ -16,6 +16,3 @@ indent_size = 2
[*.sh]
indent_size = 2
[Makefile]
indent_style = tab

View File

@@ -7,7 +7,7 @@ IMAGE_TAG := latest
IMAGE := $(IMAGE_NAME):$(IMAGE_TAG)
TAR_FILE := $(IMAGE_NAME)_$(IMAGE_TAG).tar.gz
.PHONY: help build load shell docs db
.PHONY: help build load shell docs
help:
@echo "Usage:"
@@ -19,7 +19,6 @@ help:
@echo " Optional: SOURCE=url_or_file"
@echo " shell Enter php-fpm container as www"
@echo " docs Regenerate API documentation"
@echo " db Recreate DB"
build:
@@ -55,7 +54,3 @@ shell:
docs:
@echo "Regenerating API documentation..."
docker compose exec --user www php-fpm php artisan scribe:generate
db:
@echo "Recreate DB..."
docker compose exec --user www php-fpm bash -c "php artisan migrate:fresh && php artisan db:seed"

View File

@@ -1,6 +1,6 @@
# Laravel Docker Setup
- PHP-FPM, NGINX, MySQL, phpMyAdmin (in `compose.yaml`)
- NGINX, MySQL, phpMyAdmin
## Create a project:
@@ -12,34 +12,18 @@ docker compose exec php-fpm bash
# or `make shell`
```
**_Rewrite below for yourself:_**
*RECOMENDED:*
**The latest version** via [laravel/installer package](https://packagist.org/packages/laravel/installer)
# Rewrite below:
```bash
composer global require laravel/installer && \
composer global require laravel/installer
export PATH="$HOME/.composer/vendor/bin:$PATH"
# Check options via `laravel new -h`
laravel new example-app
mv example-app/* example-app/.* ./
rmdir example-app
```
*OR:*
**The specific version** via composer
```bash
composer create-project --prefer-dist laravel/laravel example-app ^11.0
mv example-app/* example-app/.* ./
rmdir example-app
```
## Quick Actions
```bash

View File

@@ -26,7 +26,6 @@ services:
volumes:
- ./:/var/www
mysql:
image: mysql:8.0
ports:
@@ -37,8 +36,7 @@ services:
- MYSQL_PASSWORD=${DB_PASSWORD}
- MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
volumes:
- mysql-data-development:/var/lib/mysql
- mysql-data:/var/lib/mysql
phpmyadmin:
image: phpmyadmin:latest
@@ -54,4 +52,4 @@ services:
condition: service_started
volumes:
mysql-data-development:
mysql-data:

View File

@@ -13,6 +13,7 @@ ARG UID
ARG GID
# Create a new user with the specified UID and GID, reusing an existing group if GID exists
# and update php-fpm to use the new user and group
RUN if getent group ${GID}; then \
group_name=$(getent group ${GID} | cut -d: -f1); \
useradd -m -u ${UID} -g ${GID} -s /bin/bash www; \

View File

@@ -9,13 +9,10 @@ if [ ! -f "artisan" ]; then
exec "$@"
fi
gosu www mkdir -p .hashes
if [ ! -f .hashes/.composer-hash ] || ! sha1sum -c .hashes/.composer-hash; then
if [ ! -f .composer-hash ] || ! sha1sum -c .composer-hash > /dev/null 2>&1; then
echo ">> composer.json or composer.lock changed, installing dependencies..."
gosu www composer install --optimize-autoloader --no-interaction
gosu www sha1sum composer.json composer.lock > .hashes/.composer-hash
chown www: .hashes/.composer-hash
sha1sum composer.json composer.lock > .composer-hash
else
echo ">> Composer dependencies up to date (hash match), skipping install."
fi
@@ -39,19 +36,17 @@ fi
echo ">> Running seeders..."
gosu www php artisan db:seed --force
if composer show knuckleswtf/scribe >/dev/null 2>&1; then
if composer show knuckleswtf/scribe > /dev/null 2>&1; then
# Define all directories/files Scribe cares about
SCRIBE_SOURCES="config/scribe.php routes/ app/Http/Controllers/ app/Http/Requests/ app/Models/"
# Create combined hash of all .php files in those paths
CURRENT_HASH=$(find $SCRIBE_SOURCES -type f -name "*.php" -exec sha1sum {} + | sha1sum)
if [ ! -f .hashes/.scribe-hash ] || [ "$CURRENT_HASH" != "$(cat .hashes/.scribe-hash)" ]; then
if [ ! -f .scribe-hash ] || [ "$CURRENT_HASH" != "$(cat .scribe-hash)" ]; then
echo ">> Generating API documentation..."
gosu www php artisan scribe:generate --no-interaction \
|| echo ">> Warning: Scribe generation failed, continuing..."
echo "$CURRENT_HASH" > .hashes/.scribe-hash
chown www: .hashes/.scribe-hash
gosu www php artisan scribe:generate --no-interaction || true
echo "$CURRENT_HASH" > .scribe-hash
else
echo ">> API docs up to date, skipping Scribe generation."
fi