From 43fe96b0cb444a43f2a74fde8d4d39250a8b686e Mon Sep 17 00:00:00 2001 From: Jonas Kaninda Date: Sun, 14 Aug 2022 14:43:00 +0200 Subject: [PATCH 1/5] Refactoring --- Dockerfile | 13 +++++---- README.md | 22 ++++++-------- entrypoint.sh | 51 ++++++--------------------------- src/conf/nginx/default.conf | 2 +- src/supervisor/supervisord.conf | 27 +++++++++++++++++ 5 files changed, 52 insertions(+), 63 deletions(-) create mode 100644 src/supervisor/supervisord.conf diff --git a/Dockerfile b/Dockerfile index 36fe1dd..b866d03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,7 @@ -FROM php:8.1-fpm -ENV WORKDIR=/var/www/html -ENV STORAGE_DIR=${WORKDIR}/storage +FROM php:8.1.7-fpm +ARG WORKDIR=/var/www/html ENV DOCUMENT_ROOT=${WORKDIR} -ENV LARAVEL_PROCS_NUMBER=2 +ENV LARAVEL_PROCS_NUMBER=1 ENV DOMAIN=_ ENV CLIENT_MAX_BODY_SIZE=15M # Install system dependencies @@ -71,13 +70,13 @@ RUN composer global require "laravel/envoy=~1.0" # Set working directory WORKDIR $WORKDIR -# nginx site conf RUN rm -Rf /var/www/* && \ -mkdir /var/www/html/ +mkdir -p /var/www/html ADD src/index.php $WORKDIR/index.php ADD src/conf/nginx/default.conf /etc/nginx/sites-available/default ADD src/php.ini $PHP_INI_DIR/conf.d/ +ADD src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf COPY ./entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/entrypoint.sh @@ -93,4 +92,6 @@ RUN groupmod -g 1000 www-data RUN chmod -R 755 $WORKDIR RUN chown -R www-data:www-data $WORKDIR EXPOSE 9000 +EXPOSE 80 CMD [ "entrypoint" ] + diff --git a/README.md b/README.md index 012e4f9..e77829b 100644 --- a/README.md +++ b/README.md @@ -50,13 +50,11 @@ services: ## Laravel `artisan` command usage: ### CLI ```sh -docker-compose exec app bash +docker-compose exec app bash ``` - -### Laravel migration ```sh -php atisan migrate +docker exec -it app bash ``` @@ -67,8 +65,7 @@ version: '3' services: app: image: jkaninda/nginx-php-fpm - container_name: my-app - working_dir: /var/www/html #Optional, If you want to use a custom directory + container_name: nginx-fpm restart: unless-stopped ports: - "80:80" @@ -76,15 +73,14 @@ services: #Project root - ./:/var/www/html - ~/.ssh:/root/.ssh # If you use private CVS - - #./php.ini:/usr/local/etc/php/conf.d/php.ini # Optional, your custom php init file - - storage-data:/var/www/html/storage/app #Optional, your custom storage data + #./php.ini:/usr/local/etc/php/conf.d/php.ini # Optional, your custom php init file environment: - APP_ENV=development # Optional, or production - - LARAVEL_PROCS_NUMBER=3 # Optional, Laravel queue:work process number - - CLIENT_MAX_BODY_SIZE=20M # Optional - - DOMAIN=example.com # Optional -volumes: - storage-data: + - LARAVEL_PROCS_NUMBER=2 # Optional, Laravel queue:work process number + #- CLIENT_MAX_BODY_SIZE=20M # Optional + #- DOMAIN=example.com # Optional + #- DOCUMENT_ROOT=/var/www/html Optional + ``` ## Docker run diff --git a/entrypoint.sh b/entrypoint.sh index d11339b..bb29dfc 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -8,25 +8,11 @@ echo "***********************************************************" set -e -## Create PHP-FPM worker process -TASK=/etc/supervisor/conf.d/php-fpm.conf -touch $TASK -cat > "$TASK" < "$TASK" < Date: Sun, 14 Aug 2022 14:45:33 +0200 Subject: [PATCH 2/5] Refactoring --- Dockerfile | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index b866d03..f82277c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,21 +29,9 @@ RUN apt-get update && apt-get install -y nginx # Clear cache RUN apt-get clean && rm -rf /var/lib/apt/lists/* -# Install Kafka -RUN git clone https://github.com/arnaud-lb/php-rdkafka.git\ - && cd php-rdkafka \ - && phpize \ - && ./configure \ - && make all -j 5 \ - && make install - -# Install Rdkafka and enable it -RUN docker-php-ext-enable rdkafka \ - && cd .. \ - && rm -rf /php-rdkafka # Install PHP extensions zip, mbstring, exif, bcmath, intl -RUN docker-php-ext-configure gd --with-freetype --with-jpeg +RUN docker-php-ext-configure gd RUN docker-php-ext-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl # Install Redis and enable it From 0dc34c1f70d6fc1bbc93250b38f59595a4c2988f Mon Sep 17 00:00:00 2001 From: Jonas Kaninda Date: Sun, 14 Aug 2022 14:45:58 +0200 Subject: [PATCH 3/5] Refactoring --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f82277c..ca8f344 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.1.7-fpm +FROM php:7.2-fpm ARG WORKDIR=/var/www/html ENV DOCUMENT_ROOT=${WORKDIR} ENV LARAVEL_PROCS_NUMBER=1 From 2c548ec73c3841dd2eda0a244ccf362571ecd9fa Mon Sep 17 00:00:00 2001 From: Jonas Kaninda Date: Sun, 14 Aug 2022 14:46:51 +0200 Subject: [PATCH 4/5] Update php version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ca8f344..006965c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.2-fpm +FROM php:7.4-fpm ARG WORKDIR=/var/www/html ENV DOCUMENT_ROOT=${WORKDIR} ENV LARAVEL_PROCS_NUMBER=1 From 0f6881c1c700fbfb5a4ad80c1cdc8435ad5853cd Mon Sep 17 00:00:00 2001 From: Jonas Kaninda Date: Sun, 14 Aug 2022 14:58:09 +0200 Subject: [PATCH 5/5] Update php version --- Dockerfile | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 006965c..a94dddd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.4-fpm +FROM php:8.0-fpm ARG WORKDIR=/var/www/html ENV DOCUMENT_ROOT=${WORKDIR} ENV LARAVEL_PROCS_NUMBER=1 @@ -29,9 +29,21 @@ RUN apt-get update && apt-get install -y nginx # Clear cache RUN apt-get clean && rm -rf /var/lib/apt/lists/* +# Install Kafka +RUN git clone https://github.com/arnaud-lb/php-rdkafka.git\ + && cd php-rdkafka \ + && phpize \ + && ./configure \ + && make all -j 5 \ + && make install + +# Install Rdkafka and enable it +RUN docker-php-ext-enable rdkafka \ + && cd .. \ + && rm -rf /php-rdkafka # Install PHP extensions zip, mbstring, exif, bcmath, intl -RUN docker-php-ext-configure gd +RUN docker-php-ext-configure gd --with-freetype --with-jpeg RUN docker-php-ext-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl # Install Redis and enable it