From e654bb41103643d8ab038945ddfd2c0426de6cb3 Mon Sep 17 00:00:00 2001 From: James Carlo Luchavez Date: Tue, 28 May 2024 16:33:35 +0800 Subject: [PATCH 1/5] - On .env, changed the default PHP version from 7.4 to 8.3. - On .env, changed the default Laravel version from 8 to 11. - Added Laravel 11 and PHP 8.3 steps on docker-image.yml. - Added Dockerfiles for PHP 8.3 on nginx and apache. - Added 8.3 on php_version options on settings.yml. - Added 11 on Laravel options on settings.yml. --- .env | 6 +- .github/workflows/docker-image.yml | 29 +++++++++- .gitignore | 3 +- laravel/apache/Dockerfile-8.3 | 88 +++++++++++++++++++++++++++++ laravel/nginx/Dockerfile-8.3 | 91 ++++++++++++++++++++++++++++++ settings.yml | 15 +++-- 6 files changed, 221 insertions(+), 11 deletions(-) create mode 100644 laravel/apache/Dockerfile-8.3 create mode 100644 laravel/nginx/Dockerfile-8.3 diff --git a/.env b/.env index fedc247..5174ff8 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.3 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..7d95ade 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -11,6 +11,33 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Build the image with php 8.3 Laravel 11 and nginx + run: docker-compose -f "docker-compose.yml" up -d --build + env: + PHP_VERSION: "8.3" + LARAVEL_VERSION: 11 + BACK_END: nginx + LARAVEL_INSTALL: true + XDEBUG: true + DISPLAY_PHPERROR: true + - 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 +199,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 new file mode 100644 index 0000000..e5b67ed --- /dev/null +++ b/laravel/apache/Dockerfile-8.3 @@ -0,0 +1,88 @@ +ARG BACK_END +FROM ghcr.io/deck-app/apache:v8.3 +LABEL maintainer Naba Das + +ARG LARAVEL_VERSION +RUN mkdir -p /app +RUN mkdir -p /var/preview +COPY httpd.conf /app/httpd.conf +COPY httpd.conf /etc/apache2/httpd.conf +RUN wget -O /var/preview/index.html https://raw.githubusercontent.com/deck-app/stack-preview-screen/main/install/index.html + +ARG SERVER_ROOT +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 php83-openssl php83-sysvmsg php83-curl + +WORKDIR /var/www +ENV PHP_VERSION=83 +ADD package.sh /package.sh + +COPY php.ini /etc/php${PHP_VERSION}/php.ini +ARG DISPLAY_PHPERROR +RUN if [ ${DISPLAY_PHPERROR} = true ]; then \ +sed -i "s#{DISPLAY}#On#g" /etc/php${PHP_VERSION}/php.ini \ +;else \ +sed -i "s#{DISPLAY}#Off#g" /etc/php${PHP_VERSION}/php.ini \ +;fi + +#Xdebug enable or disable +ARG XDEBUG +RUN if [ ${XDEBUG} = true ]; then \ +apk add php${PHP_VERSION}-pecl-xdebug \ +&& echo "[xdebug]" >> /etc/php${PHP_VERSION}/php.ini \ +&& echo "zend_extension = xdebug" >> /etc/php${PHP_VERSION}/php.ini \ +&& echo "xdebug.mode = debug" >> /etc/php${PHP_VERSION}/php.ini \ +&& echo "xdebug.remote_autostart = 0" >> /etc/php${PHP_VERSION}/php.ini \ +&& echo "xdebug.remote_enable = 1" >> /etc/php${PHP_VERSION}/php.ini \ +&& echo "xdebug.log_level = 0" >> /etc/php${PHP_VERSION}/php.ini \ +&& echo "xdebug.discover_client_host = 1" >> /etc/php${PHP_VERSION}/php.ini \ +&& echo "xdebug.client_host = host.docker.internal" >> /etc/php${PHP_VERSION}/php.ini \ +&& echo "xdebug.start_with_request = yes" >> /etc/php${PHP_VERSION}/php.ini \ +;fi + + +RUN apk add php${PHP_VERSION}-zip php${PHP_VERSION}-pdo_mysql php${PHP_VERSION}-gd +RUN apk add zip nano +ARG LARAVEL_VERSION +COPY docker-entrypoint.sh /docker-entrypoint.sh +RUN sed -i "s#{LARAVEL_VERSION}#${LARAVEL_VERSION}#g" /docker-entrypoint.sh +RUN chmod +x /docker-entrypoint.sh + +## Linux permission issue +ARG USER_ID +ARG GROUP_ID +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 composer config --global process-timeout 6000 + +RUN sed -i "s#{USER_ID}#${USER_ID}#g" /docker-entrypoint.sh +RUN sed -i "s#{GROUP_ID}#${GROUP_ID}#g" /docker-entrypoint.sh + +## apache2 permission issue +RUN usermod --home /home apache +RUN touch /env +RUN chown -R apache:apache /env +RUN chown -R apache:apache /home +RUN chown -R apache:apache /var/preview/ +RUN chown -R apache:apache /usr/sbin/httpd +RUN chown -R apache:apache /etc/service/apache +RUN chown -R apache:apache /sbin/ +RUN chown -R apache:apache /etc/service/ +RUN chown -R apache:apache /var/run/apache2 +RUN chown -R apache:apache /etc/apache2 +RUN chown -R apache:apache /var/log/apache2 +ARG INSTALL_ADDITIONAL_EXTENSIONS +ENV INSTALL_ADDITIONAL_EXTENSIONS=$INSTALL_ADDITIONAL_EXTENSIONS +RUN if [ -z "$INSTALL_ADDITIONAL_EXTENSIONS" ] ; then \ +echo "No additional PHP extensions added" \ +;else \ +bash /package.sh \ +;fi +USER apache +CMD /docker-entrypoint.sh & /sbin/runit-wrapper diff --git a/laravel/nginx/Dockerfile-8.3 b/laravel/nginx/Dockerfile-8.3 new file mode 100644 index 0000000..5c48a24 --- /dev/null +++ b/laravel/nginx/Dockerfile-8.3 @@ -0,0 +1,91 @@ +ARG BACK_END +FROM ghcr.io/deck-app/nginx:v8.3 +LABEL maintainer Naba Das + +ARG LARAVEL_VERSION +RUN mkdir -p /app +RUN mkdir -p /var/preview +COPY default.conf /app/default.conf +COPY default.conf /etc/nginx/conf.d/default.conf +RUN wget -O /var/preview/index.html https://raw.githubusercontent.com/deck-app/stack-preview-screen/main/install/index.html + +ARG SERVER_ROOT +RUN sed -i "s#{SERVER_ROOT}#/var/preview#g" /etc/nginx/conf.d/default.conf +RUN sed -i "s#{SERVER_ROOT}#/var/www/public#g" /app/default.conf + + +# Persistent runtime dependencies +# Example RUN apk add --no-cache php83-openssl php83-sysvmsg php83-curl + +WORKDIR /var/www +ENV PHP_VERSION=83 +ADD package.sh /package.sh + +COPY php.ini /etc/php${PHP_VERSION}/php.ini +ARG DISPLAY_PHPERROR +RUN if [ ${DISPLAY_PHPERROR} = true ]; then \ +sed -i "s#{DISPLAY}#On#g" /etc/php${PHP_VERSION}/php.ini \ +;else \ +sed -i "s#{DISPLAY}#Off#g" /etc/php${PHP_VERSION}/php.ini \ +;fi + +#Xdebug enable or disable +ARG XDEBUG +RUN if [ ${XDEBUG} = true ]; then \ +apk add php${PHP_VERSION}-pecl-xdebug \ +&& echo "[xdebug]" >> /etc/php${PHP_VERSION}/php.ini \ +&& echo "zend_extension = xdebug" >> /etc/php${PHP_VERSION}/php.ini \ +&& echo "xdebug.mode = debug" >> /etc/php${PHP_VERSION}/php.ini \ +&& echo "xdebug.remote_autostart = 0" >> /etc/php${PHP_VERSION}/php.ini \ +&& echo "xdebug.remote_enable = 1" >> /etc/php${PHP_VERSION}/php.ini \ +&& echo "xdebug.log_level = 0" >> /etc/php${PHP_VERSION}/php.ini \ +&& echo "xdebug.discover_client_host = 1" >> /etc/php${PHP_VERSION}/php.ini \ +&& echo "xdebug.client_host = host.docker.internal" >> /etc/php${PHP_VERSION}/php.ini \ +&& echo "xdebug.start_with_request = yes" >> /etc/php${PHP_VERSION}/php.ini \ +;fi + +RUN apk add php${PHP_VERSION}-zip php${PHP_VERSION}-pdo_mysql php${PHP_VERSION}-gd +RUN apk add zip nano +ARG LARAVEL_VERSION +COPY docker-entrypoint.sh /docker-entrypoint.sh +RUN sed -i "s#{LARAVEL_VERSION}#${LARAVEL_VERSION}#g" /docker-entrypoint.sh +RUN chmod +x /docker-entrypoint.sh + +## Linux permission issue +ARG USER_ID +ARG GROUP_ID +RUN apk --no-cache add shadow sudo +RUN usermod -u ${USER_ID} nobody && groupmod -g ${GROUP_ID} nobody + +# sudo command without password +RUN echo "nobody 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 +RUN sed -i "s#{GROUP_ID}#${GROUP_ID}#g" /docker-entrypoint.sh +RUN sed -i "s#{BACK_END}#${BACK_END}#g" /docker-entrypoint.sh + +## nobody permission issue +RUN usermod --home /home nobody +COPY www.conf /etc/php${PHP_VERSION}/php-fpm.d/www.conf +COPY nginx.conf /etc/nginx/nginx.conf +RUN touch /env +RUN chown -R nobody:nobody /env +RUN chown -R nobody:nobody /home +RUN chown -R nobody:nobody /var/preview/ +RUN chown -R nobody:nobody /sbin/ +RUN chown -R nobody:nobody /etc/php${PHP_VERSION}/ +RUN chown -R nobody:nobody /etc/service/ +RUN chown -R nobody:nobody /var/run/ +RUN chown -R nobody:nobody /var/log/ +RUN chown -R nobody:nobody /var/lib/nginx +RUN chown -R nobody:nobody /etc/nginx +ARG INSTALL_ADDITIONAL_EXTENSIONS +ENV INSTALL_ADDITIONAL_EXTENSIONS=$INSTALL_ADDITIONAL_EXTENSIONS +RUN if [ -z "$INSTALL_ADDITIONAL_EXTENSIONS" ] ; then \ +echo "No additional PHP extensions added" \ +;else \ +bash /package.sh \ +;fi +USER nobody +CMD /docker-entrypoint.sh & /sbin/runit-wrapper diff --git a/settings.yml b/settings.yml index a9ab733..89d68f2 100644 --- a/settings.yml +++ b/settings.yml @@ -12,6 +12,7 @@ user: - nginx target: BACK_END + php_version: label: PHP version @@ -21,12 +22,13 @@ user: select values: - 7.4 - - "8.0" + - 8.0 - 8.1 - - "8.2" + - 8.2 + - 8.3 target: PHP_VERSION - + backend_ws: disabled_post_install: true label: @@ -39,7 +41,8 @@ user: - 7 - 8 - 9 - - "10" + - 10 + - 11 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 From e331a9b90e47355f01d721c92611be6a18dcae49 Mon Sep 17 00:00:00 2001 From: James Carlo Luchavez Date: Mon, 3 Jun 2024 00:24:01 +0800 Subject: [PATCH 2/5] Removed PHP 8.3 from options - On .env, changed PHP_VERSION from 8.3 to 8.2 since there's no Docker image yet for that. - Removed any steps related to PHP 8.3 from docker-image.yml. - Removed PHP 8.3 from options at settings.yml. --- .env | 2 +- .github/workflows/docker-image.yml | 11 ---- laravel/apache/Dockerfile-8.3 | 88 ----------------------------- laravel/nginx/Dockerfile-8.3 | 91 ------------------------------ settings.yml | 9 ++- 5 files changed, 5 insertions(+), 196 deletions(-) delete mode 100644 laravel/apache/Dockerfile-8.3 delete mode 100644 laravel/nginx/Dockerfile-8.3 diff --git a/.env b/.env index 5174ff8..5ab0110 100644 --- a/.env +++ b/.env @@ -2,7 +2,7 @@ SERVER_ROOT=/var/www/public APP_CODE_PATH_HOST=/tmp/laravel APP_CODE_CONTAINER_FLAG=:cached APP_CODE_PATH_LARAVEL=/var/www -PHP_VERSION=8.3 +PHP_VERSION=8.2 LARAVEL_HOST_HTTP_PORT=53487 DISPLAY_PHPERROR=true XDEBUG=false diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 7d95ade..4f2c004 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -9,17 +9,6 @@ on: jobs: Laravel: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Build the image with php 8.3 Laravel 11 and nginx - run: docker-compose -f "docker-compose.yml" up -d --build - env: - PHP_VERSION: "8.3" - LARAVEL_VERSION: 11 - BACK_END: nginx - LARAVEL_INSTALL: true - XDEBUG: true - DISPLAY_PHPERROR: true - name: Build the image with php 8.2 Laravel 11 and nginx run: docker-compose -f "docker-compose.yml" up -d --build env: diff --git a/laravel/apache/Dockerfile-8.3 b/laravel/apache/Dockerfile-8.3 deleted file mode 100644 index e5b67ed..0000000 --- a/laravel/apache/Dockerfile-8.3 +++ /dev/null @@ -1,88 +0,0 @@ -ARG BACK_END -FROM ghcr.io/deck-app/apache:v8.3 -LABEL maintainer Naba Das - -ARG LARAVEL_VERSION -RUN mkdir -p /app -RUN mkdir -p /var/preview -COPY httpd.conf /app/httpd.conf -COPY httpd.conf /etc/apache2/httpd.conf -RUN wget -O /var/preview/index.html https://raw.githubusercontent.com/deck-app/stack-preview-screen/main/install/index.html - -ARG SERVER_ROOT -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 php83-openssl php83-sysvmsg php83-curl - -WORKDIR /var/www -ENV PHP_VERSION=83 -ADD package.sh /package.sh - -COPY php.ini /etc/php${PHP_VERSION}/php.ini -ARG DISPLAY_PHPERROR -RUN if [ ${DISPLAY_PHPERROR} = true ]; then \ -sed -i "s#{DISPLAY}#On#g" /etc/php${PHP_VERSION}/php.ini \ -;else \ -sed -i "s#{DISPLAY}#Off#g" /etc/php${PHP_VERSION}/php.ini \ -;fi - -#Xdebug enable or disable -ARG XDEBUG -RUN if [ ${XDEBUG} = true ]; then \ -apk add php${PHP_VERSION}-pecl-xdebug \ -&& echo "[xdebug]" >> /etc/php${PHP_VERSION}/php.ini \ -&& echo "zend_extension = xdebug" >> /etc/php${PHP_VERSION}/php.ini \ -&& echo "xdebug.mode = debug" >> /etc/php${PHP_VERSION}/php.ini \ -&& echo "xdebug.remote_autostart = 0" >> /etc/php${PHP_VERSION}/php.ini \ -&& echo "xdebug.remote_enable = 1" >> /etc/php${PHP_VERSION}/php.ini \ -&& echo "xdebug.log_level = 0" >> /etc/php${PHP_VERSION}/php.ini \ -&& echo "xdebug.discover_client_host = 1" >> /etc/php${PHP_VERSION}/php.ini \ -&& echo "xdebug.client_host = host.docker.internal" >> /etc/php${PHP_VERSION}/php.ini \ -&& echo "xdebug.start_with_request = yes" >> /etc/php${PHP_VERSION}/php.ini \ -;fi - - -RUN apk add php${PHP_VERSION}-zip php${PHP_VERSION}-pdo_mysql php${PHP_VERSION}-gd -RUN apk add zip nano -ARG LARAVEL_VERSION -COPY docker-entrypoint.sh /docker-entrypoint.sh -RUN sed -i "s#{LARAVEL_VERSION}#${LARAVEL_VERSION}#g" /docker-entrypoint.sh -RUN chmod +x /docker-entrypoint.sh - -## Linux permission issue -ARG USER_ID -ARG GROUP_ID -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 composer config --global process-timeout 6000 - -RUN sed -i "s#{USER_ID}#${USER_ID}#g" /docker-entrypoint.sh -RUN sed -i "s#{GROUP_ID}#${GROUP_ID}#g" /docker-entrypoint.sh - -## apache2 permission issue -RUN usermod --home /home apache -RUN touch /env -RUN chown -R apache:apache /env -RUN chown -R apache:apache /home -RUN chown -R apache:apache /var/preview/ -RUN chown -R apache:apache /usr/sbin/httpd -RUN chown -R apache:apache /etc/service/apache -RUN chown -R apache:apache /sbin/ -RUN chown -R apache:apache /etc/service/ -RUN chown -R apache:apache /var/run/apache2 -RUN chown -R apache:apache /etc/apache2 -RUN chown -R apache:apache /var/log/apache2 -ARG INSTALL_ADDITIONAL_EXTENSIONS -ENV INSTALL_ADDITIONAL_EXTENSIONS=$INSTALL_ADDITIONAL_EXTENSIONS -RUN if [ -z "$INSTALL_ADDITIONAL_EXTENSIONS" ] ; then \ -echo "No additional PHP extensions added" \ -;else \ -bash /package.sh \ -;fi -USER apache -CMD /docker-entrypoint.sh & /sbin/runit-wrapper diff --git a/laravel/nginx/Dockerfile-8.3 b/laravel/nginx/Dockerfile-8.3 deleted file mode 100644 index 5c48a24..0000000 --- a/laravel/nginx/Dockerfile-8.3 +++ /dev/null @@ -1,91 +0,0 @@ -ARG BACK_END -FROM ghcr.io/deck-app/nginx:v8.3 -LABEL maintainer Naba Das - -ARG LARAVEL_VERSION -RUN mkdir -p /app -RUN mkdir -p /var/preview -COPY default.conf /app/default.conf -COPY default.conf /etc/nginx/conf.d/default.conf -RUN wget -O /var/preview/index.html https://raw.githubusercontent.com/deck-app/stack-preview-screen/main/install/index.html - -ARG SERVER_ROOT -RUN sed -i "s#{SERVER_ROOT}#/var/preview#g" /etc/nginx/conf.d/default.conf -RUN sed -i "s#{SERVER_ROOT}#/var/www/public#g" /app/default.conf - - -# Persistent runtime dependencies -# Example RUN apk add --no-cache php83-openssl php83-sysvmsg php83-curl - -WORKDIR /var/www -ENV PHP_VERSION=83 -ADD package.sh /package.sh - -COPY php.ini /etc/php${PHP_VERSION}/php.ini -ARG DISPLAY_PHPERROR -RUN if [ ${DISPLAY_PHPERROR} = true ]; then \ -sed -i "s#{DISPLAY}#On#g" /etc/php${PHP_VERSION}/php.ini \ -;else \ -sed -i "s#{DISPLAY}#Off#g" /etc/php${PHP_VERSION}/php.ini \ -;fi - -#Xdebug enable or disable -ARG XDEBUG -RUN if [ ${XDEBUG} = true ]; then \ -apk add php${PHP_VERSION}-pecl-xdebug \ -&& echo "[xdebug]" >> /etc/php${PHP_VERSION}/php.ini \ -&& echo "zend_extension = xdebug" >> /etc/php${PHP_VERSION}/php.ini \ -&& echo "xdebug.mode = debug" >> /etc/php${PHP_VERSION}/php.ini \ -&& echo "xdebug.remote_autostart = 0" >> /etc/php${PHP_VERSION}/php.ini \ -&& echo "xdebug.remote_enable = 1" >> /etc/php${PHP_VERSION}/php.ini \ -&& echo "xdebug.log_level = 0" >> /etc/php${PHP_VERSION}/php.ini \ -&& echo "xdebug.discover_client_host = 1" >> /etc/php${PHP_VERSION}/php.ini \ -&& echo "xdebug.client_host = host.docker.internal" >> /etc/php${PHP_VERSION}/php.ini \ -&& echo "xdebug.start_with_request = yes" >> /etc/php${PHP_VERSION}/php.ini \ -;fi - -RUN apk add php${PHP_VERSION}-zip php${PHP_VERSION}-pdo_mysql php${PHP_VERSION}-gd -RUN apk add zip nano -ARG LARAVEL_VERSION -COPY docker-entrypoint.sh /docker-entrypoint.sh -RUN sed -i "s#{LARAVEL_VERSION}#${LARAVEL_VERSION}#g" /docker-entrypoint.sh -RUN chmod +x /docker-entrypoint.sh - -## Linux permission issue -ARG USER_ID -ARG GROUP_ID -RUN apk --no-cache add shadow sudo -RUN usermod -u ${USER_ID} nobody && groupmod -g ${GROUP_ID} nobody - -# sudo command without password -RUN echo "nobody 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 -RUN sed -i "s#{GROUP_ID}#${GROUP_ID}#g" /docker-entrypoint.sh -RUN sed -i "s#{BACK_END}#${BACK_END}#g" /docker-entrypoint.sh - -## nobody permission issue -RUN usermod --home /home nobody -COPY www.conf /etc/php${PHP_VERSION}/php-fpm.d/www.conf -COPY nginx.conf /etc/nginx/nginx.conf -RUN touch /env -RUN chown -R nobody:nobody /env -RUN chown -R nobody:nobody /home -RUN chown -R nobody:nobody /var/preview/ -RUN chown -R nobody:nobody /sbin/ -RUN chown -R nobody:nobody /etc/php${PHP_VERSION}/ -RUN chown -R nobody:nobody /etc/service/ -RUN chown -R nobody:nobody /var/run/ -RUN chown -R nobody:nobody /var/log/ -RUN chown -R nobody:nobody /var/lib/nginx -RUN chown -R nobody:nobody /etc/nginx -ARG INSTALL_ADDITIONAL_EXTENSIONS -ENV INSTALL_ADDITIONAL_EXTENSIONS=$INSTALL_ADDITIONAL_EXTENSIONS -RUN if [ -z "$INSTALL_ADDITIONAL_EXTENSIONS" ] ; then \ -echo "No additional PHP extensions added" \ -;else \ -bash /package.sh \ -;fi -USER nobody -CMD /docker-entrypoint.sh & /sbin/runit-wrapper diff --git a/settings.yml b/settings.yml index 89d68f2..3261957 100644 --- a/settings.yml +++ b/settings.yml @@ -21,11 +21,10 @@ user: type: select values: - - 7.4 - - 8.0 - - 8.1 - - 8.2 - - 8.3 + - "7.4" + - "8.0" + - "8.1" + - "8.2" target: PHP_VERSION From ec5a2295a69007294a6ae720d16a735e71ca68c7 Mon Sep 17 00:00:00 2001 From: James Carlo Luchavez Date: Mon, 3 Jun 2024 02:59:28 +0800 Subject: [PATCH 3/5] Fix on PHP extension not installing - Removed the extra ticks from the package.sh code. --- laravel/nginx/package.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 5327e8d2c6a178afa4fd24e053e84b69678ba1a8 Mon Sep 17 00:00:00 2001 From: James Carlo Luchavez Date: Sun, 9 Jun 2024 19:18:33 +0800 Subject: [PATCH 4/5] Bugfixes and new option to select "latest" Laravel version - Added the "latest" version on settings.yml. - Added logic on docker-entrypoint.sh to accommodate for the "latest" Laravel version. - Added more comments on docker-entrypoint.sh files. - Fixed bugs on Dockerfile-8.3 files since they were still using php82 extensions. --- laravel/apache/Dockerfile-8.3 | 4 +- laravel/apache/docker-entrypoint.sh | 93 ++++++++++++++++------------ laravel/nginx/Dockerfile-8.3 | 2 +- laravel/nginx/docker-entrypoint.sh | 94 +++++++++++++++++------------ settings.yml | 2 + 5 files changed, 114 insertions(+), 81 deletions(-) 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/settings.yml b/settings.yml index 3261957..4e28491 100644 --- a/settings.yml +++ b/settings.yml @@ -25,6 +25,7 @@ user: - "8.0" - "8.1" - "8.2" + - "8.3" target: PHP_VERSION @@ -42,6 +43,7 @@ user: - 9 - 10 - 11 + - "latest" target: LARAVEL_VERSION From f863ca41cd4262b04052c079fa6d7970d4c9631e Mon Sep 17 00:00:00 2001 From: James Carlo Luchavez Date: Mon, 10 Jun 2024 19:38:23 +0800 Subject: [PATCH 5/5] Removed Laravel 7 from the options. --- settings.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/settings.yml b/settings.yml index 4e28491..f0709e5 100644 --- a/settings.yml +++ b/settings.yml @@ -38,7 +38,6 @@ user: type: select values: - - 7 - 8 - 9 - 10