diff --git a/.env b/.env index fedc247..5ab0110 100644 --- a/.env +++ b/.env @@ -2,12 +2,12 @@ SERVER_ROOT=/var/www/public APP_CODE_PATH_HOST=/tmp/laravel APP_CODE_CONTAINER_FLAG=:cached APP_CODE_PATH_LARAVEL=/var/www -PHP_VERSION=7.4 +PHP_VERSION=8.2 LARAVEL_HOST_HTTP_PORT=53487 DISPLAY_PHPERROR=true XDEBUG=false -LARAVEL_VERSION=8 +LARAVEL_VERSION=11 BACK_END=nginx INSTALL_ADDITIONAL_EXTENSIONS= USER_ID=1000 -GROUP_ID=1000 \ No newline at end of file +GROUP_ID=1000 diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 37b08f1..4f2c004 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -9,8 +9,24 @@ on: jobs: Laravel: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 + - name: Build the image with php 8.2 Laravel 11 and nginx + run: docker-compose -f "docker-compose.yml" up -d --build + env: + PHP_VERSION: "8.2" + LARAVEL_VERSION: 11 + BACK_END: nginx + LARAVEL_INSTALL: true + XDEBUG: true + DISPLAY_PHPERROR: true + - name: Build the image with php 8.1 Laravel 11 and nginx + run: docker-compose -f "docker-compose.yml" up -d --build + env: + PHP_VERSION: "8.1" + LARAVEL_VERSION: 11 + BACK_END: nginx + LARAVEL_INSTALL: true + XDEBUG: true + DISPLAY_PHPERROR: true - name: Build the image with php 8.2 Laravel 10 and nginx run: docker-compose -f "docker-compose.yml" up -d --build env: @@ -172,4 +188,4 @@ jobs: BACK_END: apache LARAVEL_INSTALL: true XDEBUG: true - DISPLAY_PHPERROR: true \ No newline at end of file + DISPLAY_PHPERROR: true diff --git a/.gitignore b/.gitignore index 9186015..da75c3c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_Store -data \ No newline at end of file +data +.idea diff --git a/laravel/apache/Dockerfile-8.3 b/laravel/apache/Dockerfile-8.3 index 34799c6..e5b67ed 100644 --- a/laravel/apache/Dockerfile-8.3 +++ b/laravel/apache/Dockerfile-8.3 @@ -14,7 +14,7 @@ RUN sed -i "s#{SERVER_ROOT}#/var/preview#g" /etc/apache2/httpd.conf RUN sed -i "s#{SERVER_ROOT}#/var/www/public#g" /app/httpd.conf # Persistent runtime dependencies -# Example RUN apk add --no-cache php82-openssl php82-sysvmsg php82-curl +# Example RUN apk add --no-cache php83-openssl php83-sysvmsg php83-curl WORKDIR /var/www ENV PHP_VERSION=83 @@ -58,7 +58,7 @@ RUN apk --no-cache add shadow sudo RUN usermod -u ${USER_ID} apache && groupmod -g ${GROUP_ID} apache # sudo command without password -RUN echo "apache ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers +RUN echo "apache ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers RUN composer config --global process-timeout 6000 RUN sed -i "s#{USER_ID}#${USER_ID}#g" /docker-entrypoint.sh diff --git a/laravel/apache/docker-entrypoint.sh b/laravel/apache/docker-entrypoint.sh index 9f37c3c..b971fa5 100644 --- a/laravel/apache/docker-entrypoint.sh +++ b/laravel/apache/docker-entrypoint.sh @@ -1,51 +1,66 @@ #!/bin/bash -set +x -if [[ $(curl -Is https://laravel.com | head -n 1 | cut -d ' ' -f 2 ) == "200" ]]; then -if [[ -f "/var/www/composer.json" ]] ; -then - cd /var/www/ - if [[ -d "/var/www/vendor" ]] ; - then - echo "Steps to use Composer optimise autoloader" - sudo composer update --prefer-dist --no-interaction --optimize-autoloader --no-dev - echo "Steps to Clear All Development inputs" - sudo php artisan view:clear - sudo php artisan route:clear - sudo php artisan config:clear - sudo php artisan clear-compiled - else - echo "If composer vendor folder is not installed follow the below steps" - sudo composer install --prefer-dist --no-interaction --optimize-autoloader --no-dev +set +x # Disable verbose debugging output + +# Check if Laravel website is accessible (indicating internet connectivity) +if [[ $(curl -Is https://laravel.com | head -n 1 | cut -d ' ' -f 2) == "200" ]]; then + + # Check if we're in a Composer project directory + if [[ -f "/var/www/composer.json" ]]; then + cd /var/www/ # Change to project directory + + # Check if vendor directory exists (Composer dependencies installed) + if [[ -d "/var/www/vendor" ]]; then + echo "Steps to use Composer optimise autoloader" + sudo composer update --prefer-dist --no-interaction --optimize-autoloader --no-dev + + echo "Steps to Clear All Development inputs" + sudo php artisan view:clear + sudo php artisan route:clear + sudo php artisan config:clear + sudo php artisan clear-compiled + else + echo "If composer vendor folder is not installed follow the below steps" + sudo composer install --prefer-dist --no-interaction --optimize-autoloader --no-dev + fi fi -fi -if [[ "$(ls -A "/var/www/")" ]] ; - then + # Check if the project directory is empty (excluding hidden files) + if [[ "$(ls -A "/var/www/")" ]]; then echo "If the Directory is not empty, please delete the hidden files and directory" else - sudo composer config --global process-timeout 6000 - sudo composer create-project --prefer-dist laravel/laravel:^{LARAVEL_VERSION}.0 . + sudo composer config --global process-timeout 6000 # Set longer timeout + + # Install Laravel based on version (or latest if not specified) + if [[ "{LARAVEL_VERSION}" == "latest" ]]; then + sudo composer create-project --prefer-dist laravel/laravel . + else + sudo composer create-project --prefer-dist laravel/laravel:^{LARAVEL_VERSION}.0 . + fi + + # If Laravel installation fails, execute the default entrypoint script if [ $? != 0 ]; then - sh /docker-entrypoint.sh + sh /docker-entrypoint.sh fi -fi -echo "Steps to check application environment variable" -if [[ ! -f ".env" ]] ; -then - echo ".env file not found" - sudo cp .env.example .env -else - echo ".env file exit" -fi -sudo cp /app/httpd.conf /etc/apache2/httpd.conf -httpd -k graceful -sudo chown -R apache:apache /var/www 2> /dev/null -rm -rf /var/preview 2> /dev/null + fi -sudo php artisan key:generate + echo "Steps to check application environment variable" + # Ensure .env file exists for environment configuration + if [[ ! -f ".env" ]]; then + echo ".env file not found" + sudo cp .env.example .env + else + echo ".env file exists" + fi -exec "$@" + # Configure Apache, set permissions, clean up + sudo cp /app/httpd.conf /etc/apache2/httpd.conf + httpd -k graceful # Restart Apache gracefully + sudo chown -R apache:apache /var/www 2> /dev/null + rm -rf /var/preview 2> /dev/null + sudo php artisan key:generate # Generate Laravel application key + + exec "$@" # Execute any passed arguments else echo "Internet not working check your Internet connection or network"; -fi \ No newline at end of file +fi diff --git a/laravel/nginx/Dockerfile-8.3 b/laravel/nginx/Dockerfile-8.3 index 593499f..5c48a24 100644 --- a/laravel/nginx/Dockerfile-8.3 +++ b/laravel/nginx/Dockerfile-8.3 @@ -15,7 +15,7 @@ RUN sed -i "s#{SERVER_ROOT}#/var/www/public#g" /app/default.conf # Persistent runtime dependencies -# Example RUN apk add --no-cache php82-openssl php82-sysvmsg php82-curl +# Example RUN apk add --no-cache php83-openssl php83-sysvmsg php83-curl WORKDIR /var/www ENV PHP_VERSION=83 diff --git a/laravel/nginx/docker-entrypoint.sh b/laravel/nginx/docker-entrypoint.sh index 623987a..12599d0 100644 --- a/laravel/nginx/docker-entrypoint.sh +++ b/laravel/nginx/docker-entrypoint.sh @@ -1,52 +1,68 @@ #!/bin/bash -set +x -if [[ $(curl -Is https://laravel.com | head -n 1 | cut -d ' ' -f 2 ) == "200" ]]; then -if [[ -f "/var/www/composer.json" ]] ; -then - cd /var/www/ - if [[ -d "/var/www/vendor" ]] ; - then - echo "Steps to use Composer optimise autoloader" - sudo composer update --prefer-dist --no-interaction --optimize-autoloader --no-dev - echo "Steps to Clear All Development inputs" - sudo php artisan view:clear - sudo php artisan route:clear - sudo php artisan config:clear - sudo php artisan clear-compiled - else - echo "If composer vendor folder is not installed follow the below steps" - sudo composer install --prefer-dist --no-interaction --optimize-autoloader --no-dev +set +x # Disable verbose debugging output + +# Check if Laravel website is accessible (indicating internet connectivity) +if [[ $(curl -Is https://laravel.com | head -n 1 | cut -d ' ' -f 2) == "200" ]]; then + + # Check if we're in a Composer project directory + if [[ -f "/var/www/composer.json" ]]; then + cd /var/www/ # Change to project directory + + # Check if vendor directory exists (Composer dependencies installed) + if [[ -d "/var/www/vendor" ]]; then + echo "Steps to use Composer optimise autoloader" + sudo composer update --prefer-dist --no-interaction --optimize-autoloader --no-dev + + echo "Steps to Clear All Development inputs" + sudo php artisan view:clear + sudo php artisan route:clear + sudo php artisan config:clear + sudo php artisan clear-compiled + else + echo "If composer vendor folder is not installed follow the below steps" + sudo composer install --prefer-dist --no-interaction --optimize-autoloader --no-dev + fi fi -fi -if [[ "$(ls -A "/var/www/")" ]] ; - then + # Check if the project directory is empty (excluding hidden files) + if [[ "$(ls -A "/var/www/")" ]]; then echo "If the Directory is not empty, please delete the hidden files and directory" else - sudo composer config --global process-timeout 6000 - sudo composer create-project --prefer-dist laravel/laravel:^{LARAVEL_VERSION}.0 . + sudo composer config --global process-timeout 6000 # Set longer timeout + + # Install Laravel based on version (or latest if not specified) + if [[ "{LARAVEL_VERSION}" == "latest" ]]; then + # If LARAVEL_VERSION is empty or "latest", install the latest version + sudo composer create-project --prefer-dist laravel/laravel . + else + # Otherwise, install the specified version + sudo composer create-project --prefer-dist laravel/laravel:^{LARAVEL_VERSION}.0 . + fi + + # If Laravel installation fails, execute the default entrypoint script if [ $? != 0 ]; then - sh /docker-entrypoint.sh + sh /docker-entrypoint.sh fi -fi -echo "Steps to check application environment variable" -if [[ ! -f ".env" ]] ; -then - echo ".env file not found" - sudo cp .env.example .env -else - echo ".env file exit" -fi + fi -sudo cp /app/default.conf /etc/nginx/conf.d/default.conf -nginx -s reload -sudo chown -R nobody:nobody /var/www 2> /dev/null + echo "Steps to check application environment variable" + # Ensure .env file exists for environment configuration + if [[ ! -f ".env" ]]; then + echo ".env file not found" + sudo cp .env.example .env + else + echo ".env file exists" + fi -sudo rm -rf /var/preview 2> /dev/null + # Configure Nginx, set permissions, clean up + sudo cp /app/default.conf /etc/nginx/conf.d/default.conf + nginx -s reload # Reload Nginx configuration + sudo chown -R nobody:nobody /var/www 2> /dev/null # Set ownership to Nginx user + sudo rm -rf /var/preview 2> /dev/null -sudo php artisan key:generate + sudo php artisan key:generate # Generate Laravel application key -exec "$@" + exec "$@" # Execute any passed arguments else echo "Internet not working check your Internet connection or network"; -fi \ No newline at end of file +fi diff --git a/laravel/nginx/package.sh b/laravel/nginx/package.sh index dded0ce..ae6ccf5 100644 --- a/laravel/nginx/package.sh +++ b/laravel/nginx/package.sh @@ -4,4 +4,4 @@ for (( n=1; n<=$word; n++ )) do SERVER_ARRAY=`echo ${INSTALL_ADDITIONAL_EXTENSIONS} | awk '{print $'$n'}' | sed 's/.*-//'` sudo apk add --no-cache php${PHP_VERSION}-`echo ${SERVER_ARRAY}` -done`` \ No newline at end of file +done diff --git a/settings.yml b/settings.yml index a9ab733..f0709e5 100644 --- a/settings.yml +++ b/settings.yml @@ -12,6 +12,7 @@ user: - nginx target: BACK_END + php_version: label: PHP version @@ -20,13 +21,14 @@ user: type: select values: - - 7.4 + - "7.4" - "8.0" - - 8.1 + - "8.1" - "8.2" + - "8.3" target: PHP_VERSION - + backend_ws: disabled_post_install: true label: @@ -36,10 +38,11 @@ user: type: select values: - - 7 - 8 - 9 - - "10" + - 10 + - 11 + - "latest" target: LARAVEL_VERSION @@ -48,7 +51,7 @@ user: Enable PHP error reporting? type: checkbox - hint: Check the box to display PHP errors + hint: Check the box to display PHP errors target: DISPLAY_PHPERROR php_xdebug: @@ -59,7 +62,7 @@ user: hint: Check the box to display extension xdebug target: XDEBUG - + # mysql_version: # label: # MySQL version