From ae1fc8259eba0a75ab886be00fe8792dc2157283 Mon Sep 17 00:00:00 2001 From: Jonas Kaninda Date: Wed, 18 Sep 2024 20:50:15 +0200 Subject: [PATCH 1/2] chore: upgrade Node version from 17 to 20 --- .github/workflows/integration-tests.yml | 2 +- README.md | 39 ++++++-- src/docker/8.2/Dockerfile | 2 +- src/docker/8.3/Dockerfile | 2 +- src/docker/8.4/Dockerfile | 127 ++++++++++++++++++++++++ 5 files changed, 159 insertions(+), 13 deletions(-) create mode 100644 src/docker/8.4/Dockerfile diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index f356328..48fa314 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -1,4 +1,4 @@ -name: Integration Test +name: Test on: push: jobs: diff --git a/README.md b/README.md index d79a5d8..b7a2ea4 100644 --- a/README.md +++ b/README.md @@ -41,28 +41,47 @@ ## Simple docker-compose usage: ```yml -version: '3' services: app: image: jkaninda/nginx-php-fpm:8.3 - container_name: my-app + container_name: app restart: unless-stopped user: www-data # Optional - for production usage volumes: #Project root - - ./:/var/www/html + - ./src:/var/www/html ports: - "80:80" networks: - default #if you're using networks between containers ``` -## Laravel `artisan` command usage: -### CLI +## Docker: +### Run ```sh -docker-compose exec app bash - + docker compose up -d +``` +### Create Laravel project +```sh +docker compose exec app composer create-project --prefer-dist laravel/laravel . +``` +### Artisan generate key +```sh +docker compose exec app php artisan key:generate +``` +### Storage link +```sh +docker compose exec app php artisan storage:link +``` +### Fix permissions +```sh +docker compose exec app chmod -R 777 storage bootstrap/cache +``` +### Laravel migration +```sh + docker compose exec app php artisan migrate ``` +### ```sh docker exec -it app bash @@ -75,7 +94,7 @@ version: '3' services: app: image: jkaninda/nginx-php-fpm - container_name: nginx-fpm + container_name: app restart: unless-stopped ports: - "80:80" @@ -100,7 +119,7 @@ Default web root: ## Docker run ```sh - docker-compose up -d + docker compose up -d ``` ## Build from base @@ -153,7 +172,7 @@ stdout_logfile=/var/www/html/storage/logs/kafka.log ### Storage permision issue ```sh - docker-compose exec php-fpm /bin/bash + docker compose exec php-fpm /bin/bash ``` ```sh chown -R www-data:www-data /var/www/html/ diff --git a/src/docker/8.2/Dockerfile b/src/docker/8.2/Dockerfile index 6ade464..3f5d63c 100644 --- a/src/docker/8.2/Dockerfile +++ b/src/docker/8.2/Dockerfile @@ -4,7 +4,7 @@ ENV DOCUMENT_ROOT=${WORKDIR} ENV LARAVEL_PROCS_NUMBER=1 ENV DOMAIN=_ ENV CLIENT_MAX_BODY_SIZE=15M -ENV NODE_VERSION=17.x +ENV NODE_VERSION=20.x ARG GROUP_ID=1000 ARG USER_ID=1000 ENV USER_NAME=www-data diff --git a/src/docker/8.3/Dockerfile b/src/docker/8.3/Dockerfile index 8c7a51c..5c52d16 100644 --- a/src/docker/8.3/Dockerfile +++ b/src/docker/8.3/Dockerfile @@ -4,7 +4,7 @@ ENV DOCUMENT_ROOT=${WORKDIR} ENV LARAVEL_PROCS_NUMBER=1 ENV DOMAIN=_ ENV CLIENT_MAX_BODY_SIZE=15M -ENV NODE_VERSION=17.x +ENV NODE_VERSION=20.x ARG GROUP_ID=1000 ARG USER_ID=1000 ENV USER_NAME=www-data diff --git a/src/docker/8.4/Dockerfile b/src/docker/8.4/Dockerfile new file mode 100644 index 0000000..56478c3 --- /dev/null +++ b/src/docker/8.4/Dockerfile @@ -0,0 +1,127 @@ +FROM php:8.4-rc-fpm +ARG WORKDIR=/var/www/html +ENV DOCUMENT_ROOT=${WORKDIR} +ENV LARAVEL_PROCS_NUMBER=1 +ENV DOMAIN=_ +ENV CLIENT_MAX_BODY_SIZE=15M +ENV NODE_VERSION=20.x +ARG GROUP_ID=1000 +ARG USER_ID=1000 +ENV USER_NAME=www-data +ARG GROUP_NAME=www-data +# Install system dependencies +RUN apt-get update && apt-get install -y \ + git \ + curl \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libmemcached-dev \ + libzip-dev \ + libpng-dev \ + libonig-dev \ + libxml2-dev \ + librdkafka-dev \ + libpq-dev \ + openssh-server \ + zip \ + unzip \ + supervisor \ + sqlite3 \ + nano \ + cron + +RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - + # Install Node +RUN apt-get install -y nodejs +# Install nginx +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-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl + +# Install Redis and enable it +RUN pecl install redis && docker-php-ext-enable redis + + + +# Install the php memcached extension +RUN pecl install memcached && docker-php-ext-enable memcached + +# Install the PHP pdo_mysql extention +RUN docker-php-ext-install pdo_mysql + +# Install the PHP pdo_pgsql extention +RUN docker-php-ext-install pdo_pgsql + +# Install PHP Opcache extention +RUN docker-php-ext-install opcache + +# Install Composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# Set working directory +WORKDIR $WORKDIR + +RUN rm -Rf /var/www/* && \ +mkdir -p /var/www/html + +ADD src/index.php $WORKDIR/index.php +ADD src/php.ini $PHP_INI_DIR/conf.d/ +ADD src/opcache.ini $PHP_INI_DIR/conf.d/ +ADD src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf + +COPY src/entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/entrypoint.sh +RUN ln -s /usr/local/bin/entrypoint.sh / + + +RUN rm -rf /etc/nginx/conf.d/default.conf +RUN rm -rf /etc/nginx/sites-enabled/default +RUN rm -rf /etc/nginx/sites-available/default + +RUN rm -rf /etc/nginx/nginx.conf + +COPY src/nginx.conf /etc/nginx/nginx.conf +COPY src/default.conf /etc/nginx/conf.d/ + +RUN usermod -u ${USER_ID} ${USER_NAME} +RUN groupmod -g ${USER_ID} ${GROUP_NAME} + +RUN mkdir -p /var/log/supervisor +RUN mkdir -p /var/log/nginx +RUN mkdir -p /var/cache/nginx + +RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \ + chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \ + chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \ + chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \ + touch /var/run/nginx.pid && \ + chown -R $USER_NAME:$USER_NAME /var/cache/nginx && \ + chown -R $USER_NAME:$USER_NAME /var/lib/nginx/ && \ + chown -R $USER_NAME:$USER_NAME /var/run/nginx.pid && \ + chown -R $USER_NAME:$USER_NAME /var/log/supervisor && \ + chown -R $USER_NAME:$USER_NAME /etc/nginx/nginx.conf && \ + chown -R $USER_NAME:$USER_NAME /etc/nginx/conf.d/ && \ + chown -R ${USER_NAME}:${GROUP_NAME} /tmp + + +#USER ${USER_NAME} +EXPOSE 80 +ENTRYPOINT ["entrypoint.sh"] + From 18658c770208571bfd5079d9787d43d6217ba286 Mon Sep 17 00:00:00 2001 From: Jonas Kaninda Date: Wed, 18 Sep 2024 20:52:28 +0200 Subject: [PATCH 2/2] Fix test --- .github/workflows/integration-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 48fa314..4d0ee41 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -14,7 +14,7 @@ jobs: - name: Run docker-compose run: cp ./tests/compose.yaml compose.yaml && - docker-compose -f "compose.yaml" up -d + docker compose -f "compose.yaml" up -d - name: Create script.js for K6 test run: | touch script.js && cat > script.js <