From 091ebc6b096bc2c3d403146f9dbdc61f02080e7b Mon Sep 17 00:00:00 2001 From: Jonas Kaninda Date: Sun, 11 May 2025 09:39:25 +0200 Subject: [PATCH] Optimization of entrypoint (#39) --- .github/workflows/tests.yml | 7 ++ src/entrypoint.sh | 189 ++++++++++++++++++------------------ version | 0 3 files changed, 99 insertions(+), 97 deletions(-) create mode 100644 version diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4d0ee41..d909d37 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,6 +6,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + # Build the Docker image + - name: Build Docker Image + run: | + docker buildx build -f src/docker/Dockerfile --build-arg phpVersion=8.4 -t ${{ vars.BUILDKIT_IMAGE }}:latest --load . + - name: Verify Docker images + run: | + docker images - name: Create Laravel project run: | composer create-project laravel/laravel laravel diff --git a/src/entrypoint.sh b/src/entrypoint.sh index a2c0dd9..4e97686 100644 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -1,104 +1,96 @@ #!/bin/sh +set -e + echo "" echo "***********************************************************" echo " Starting NGINX PHP-FPM Docker Container " echo "***********************************************************" -set -e -set -e -info() { - { set +x; } 2> /dev/null - echo '[INFO] ' "$@" -} -warning() { - { set +x; } 2> /dev/null - echo '[WARNING] ' "$@" -} -fatal() { - { set +x; } 2> /dev/null - echo '[ERROR] ' "$@" >&2 - exit 1 -} -## Check if the artisan file exists -if [ -f /var/www/html/artisan ]; then - info "Artisan file found, creating laravel supervisor config" - # Set DocumentRoot to the Laravel project directory - export DOCUMENT_ROOT=/var/www/html/public - ##Create Laravel Scheduler process - TASK=/etc/supervisor/conf.d/laravel-worker.conf - touch $TASK - cat > "$TASK" <&2; exit 1; } + +ARTISAN_FILE="/var/www/html/artisan" +SUPERVISOR_CONF_DIR="/etc/supervisor/conf.d" +NGINX_CONF_DIR="/etc/nginx/conf.d" +CUSTOM_NGINX_CONF="/var/www/html/conf/nginx" +CUSTOM_SUPERVISOR_CONF="/var/www/html/conf/worker/supervisor.conf" +DOCUMENT_ROOT="/var/www/html/public" + +# Laravel Supervisor Setup +setup_laravel_supervisor() { + info "Artisan file found, creating Laravel supervisor config" + export DOCUMENT_ROOT + + cat > "$SUPERVISOR_CONF_DIR/laravel-worker.conf" < "$TASK" < "$NGINX_CONF_DIR/default.conf" <