Compare commits
1 Commits
a5a1c7d2a7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
16e98b5663
|
@@ -16,3 +16,6 @@ indent_size = 2
|
||||
|
||||
[*.sh]
|
||||
indent_size = 2
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
|
||||
7
Makefile
7
Makefile
@@ -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
|
||||
.PHONY: help build load shell docs db
|
||||
|
||||
help:
|
||||
@echo "Usage:"
|
||||
@@ -19,6 +19,7 @@ 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:
|
||||
@@ -54,3 +55,7 @@ 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"
|
||||
|
||||
23
README.md
23
README.md
@@ -1,6 +1,6 @@
|
||||
# Laravel Docker Setup
|
||||
|
||||
- NGINX, MySQL, phpMyAdmin
|
||||
- PHP-FPM, NGINX, MySQL, phpMyAdmin (in `compose.yaml`)
|
||||
|
||||
## Create a project:
|
||||
|
||||
@@ -12,19 +12,34 @@ docker compose exec php-fpm bash
|
||||
# or `make shell`
|
||||
```
|
||||
|
||||
Rewrite below for yourself:
|
||||
**_Rewrite below for yourself:_**
|
||||
|
||||
*RECOMENDED:*
|
||||
|
||||
**The latest version** via [laravel/installer package](https://packagist.org/packages/laravel/installer)
|
||||
|
||||
```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
|
||||
|
||||
@@ -26,6 +26,7 @@ services:
|
||||
volumes:
|
||||
- ./:/var/www
|
||||
|
||||
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
ports:
|
||||
@@ -36,7 +37,8 @@ services:
|
||||
- MYSQL_PASSWORD=${DB_PASSWORD}
|
||||
- MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
|
||||
volumes:
|
||||
- mysql-data:/var/lib/mysql
|
||||
- mysql-data-development:/var/lib/mysql
|
||||
|
||||
|
||||
phpmyadmin:
|
||||
image: phpmyadmin:latest
|
||||
@@ -52,4 +54,4 @@ services:
|
||||
condition: service_started
|
||||
|
||||
volumes:
|
||||
mysql-data:
|
||||
mysql-data-development:
|
||||
|
||||
@@ -13,7 +13,6 @@ 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; \
|
||||
|
||||
@@ -9,10 +9,13 @@ if [ ! -f "artisan" ]; then
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
if [ ! -f .composer-hash ] || ! sha1sum -c .composer-hash > /dev/null 2>&1; then
|
||||
gosu www mkdir -p .hashes
|
||||
|
||||
if [ ! -f .hashes/.composer-hash ] || ! sha1sum -c .hashes/.composer-hash; then
|
||||
echo ">> composer.json or composer.lock changed, installing dependencies..."
|
||||
gosu www composer install --optimize-autoloader --no-interaction
|
||||
sha1sum composer.json composer.lock > .composer-hash
|
||||
gosu www sha1sum composer.json composer.lock > .hashes/.composer-hash
|
||||
chown www: .hashes/.composer-hash
|
||||
else
|
||||
echo ">> Composer dependencies up to date (hash match), skipping install."
|
||||
fi
|
||||
@@ -43,10 +46,12 @@ if composer show knuckleswtf/scribe > /dev/null 2>&1; then
|
||||
# Create combined hash of all .php files in those paths
|
||||
CURRENT_HASH=$(find $SCRIBE_SOURCES -type f -name "*.php" -exec sha1sum {} + | sha1sum)
|
||||
|
||||
if [ ! -f .scribe-hash ] || [ "$CURRENT_HASH" != "$(cat .scribe-hash)" ]; then
|
||||
if [ ! -f .hashes/.scribe-hash ] || [ "$CURRENT_HASH" != "$(cat .hashes/.scribe-hash)" ]; then
|
||||
echo ">> Generating API documentation..."
|
||||
gosu www php artisan scribe:generate --no-interaction || true
|
||||
echo "$CURRENT_HASH" > .scribe-hash
|
||||
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
|
||||
else
|
||||
echo ">> API docs up to date, skipping Scribe generation."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user