From c6a7d2d8dfacbdfbd63b5aec7d98cb20ad0157d5 Mon Sep 17 00:00:00 2001 From: Persson-dev Date: Sat, 7 Jun 2025 11:05:09 +0200 Subject: [PATCH 1/2] enhance docker scripts --- Makefile | 34 +++++++++++++++++++++++----------- images/.env | 3 ++- images/Laravel_Dockerfile | 7 ++++--- images/init_laravel.sh | 11 +++++++++-- 4 files changed, 38 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index ef918f8..4790509 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,32 @@ -all: - run +DOCKER_CONTAINER_NAME=awa-laravel-1 +DOCKER_CMD=docker exec -it $(DOCKER_CONTAINER_NAME) +# Launch the container detached +all: + docker compose up -d + +# Launch the container run: docker compose up -init_vendor: - cd laravel && composer i - -init: - docker exec -i awa-laravel-1 /scripts/init_laravel.sh - -exec_container: - docker exec -i awa-laravel-1 bash +# Stop the container +stop: + docker compose down +# Stop the container and wipe the database down: docker compose down -v + + + +# These tasks need the docker container to be running + +exec_container: + $(DOCKER_CMD) bash + seed: - docker exec -i awa-laravel-1 php artisan db:seed --class=$(CLASS) \ No newline at end of file + $(DOCKER_CMD) php artisan db:seed --class=$(CLASS) + +migrate: + $(DOCKER_CMD) php artisan migrate \ No newline at end of file diff --git a/images/.env b/images/.env index 1e62264..2922e33 100644 --- a/images/.env +++ b/images/.env @@ -3,4 +3,5 @@ DB_HOST=mariadb DB_PORT=3306 DB_DATABASE=laravel_db DB_USERNAME=laravel_user -DB_PASSWORD=super_strong_password \ No newline at end of file +DB_PASSWORD=super_strong_password +APP_KEY="" \ No newline at end of file diff --git a/images/Laravel_Dockerfile b/images/Laravel_Dockerfile index 684fde1..339e443 100644 --- a/images/Laravel_Dockerfile +++ b/images/Laravel_Dockerfile @@ -1,7 +1,8 @@ FROM bitnami/laravel -COPY init_laravel.sh /scripts/init_laravel.sh +COPY init_laravel.sh /init/init_laravel.sh +COPY .env /init/.env -RUN chmod +x /scripts/init_laravel.sh +RUN chmod +x /init/init_laravel.sh -CMD composer i && php artisan serve --host=0.0.0.0 --port=8000 \ No newline at end of file +CMD bash /init/init_laravel.sh \ No newline at end of file diff --git a/images/init_laravel.sh b/images/init_laravel.sh index 8abd99b..398a543 100644 --- a/images/init_laravel.sh +++ b/images/init_laravel.sh @@ -1,4 +1,11 @@ #!/bin/sh composer install -php artisan migrate --force -php artisan db:seed \ No newline at end of file + +# Create .env if it does not exist +if ! [ -e ".env" ] ; then + cp /init/.env . + php artisan key:generate +fi + +php artisan migrate --force +php artisan serve --host=0.0.0.0 --port=8000 \ No newline at end of file From b30501c24c4a409fd9543e40ebd9362a4a4cb0f9 Mon Sep 17 00:00:00 2001 From: Persson-dev Date: Sat, 7 Jun 2025 11:05:23 +0200 Subject: [PATCH 2/2] add missing loggers --- laravel/config/logging.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/laravel/config/logging.php b/laravel/config/logging.php index 1345f6f..e783f19 100644 --- a/laravel/config/logging.php +++ b/laravel/config/logging.php @@ -127,6 +127,18 @@ return [ 'path' => storage_path('logs/laravel.log'), ], + "projectError" => [ + 'driver' => 'single', + 'path' => storage_path('logs/project.log'), + 'level' => 'error', + ], + + "projectInfo" => [ + 'driver' => 'single', + 'path' => storage_path('logs/project.log'), + 'level' => 'info', + ] + ], ];