From 09f0c4c2e0015b9898f4c1a42069411ca5680361 Mon Sep 17 00:00:00 2001 From: Jonas Kaninda Date: Mon, 5 Dec 2022 13:41:51 +0200 Subject: [PATCH 1/4] Add tag based on folder --- .github/workflows/build.yml | 22 ++++--- build.sh | 12 +++- docker/7.2/Dockerfile | 91 +++++++++++++++++++++++++++++ docker/7.4/Dockerfile | 91 +++++++++++++++++++++++++++++ docker/8.0/Dockerfile | 91 +++++++++++++++++++++++++++++ Dockerfile => docker/8.1/Dockerfile | 0 docker/8.2/Dockerfile | 91 +++++++++++++++++++++++++++++ 7 files changed, 388 insertions(+), 10 deletions(-) create mode 100644 docker/7.2/Dockerfile create mode 100644 docker/7.4/Dockerfile create mode 100644 docker/8.0/Dockerfile rename Dockerfile => docker/8.1/Dockerfile (100%) create mode 100644 docker/8.2/Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eb28434..5406f42 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,9 +1,14 @@ name: Docker image build and Push Image to registry on: - push: - branches: - - '**' + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + inputs: + docker_tag: + description: 'Docker tag' + required: true + default: 'latest' + type: string env: #BRANCH_NAME: ${{ github.head_ref || github.ref_name }} @@ -16,12 +21,11 @@ jobs: name: Set environment for branch run: | set -x - if [[ $GITHUB_REF == 'refs/heads/master' ]]; then - echo "TAG_NAME=latest" >> "$GITHUB_ENV" - echo "runs-on: master branch" + if [[ ${{ inputs.docker_tag }} == 'latest' ]]; then + TAG_NAME=8.1 + echo "Build latest tag'" else - echo "TAG_NAME=${{ github.head_ref || github.ref_name }}" >> "$GITHUB_ENV" - echo "runs-on: ${{ github.head_ref || github.ref_name }} branch" + TAG_NAME=${{ inputs.docker_tag }} fi - name: Set up QEMU @@ -39,5 +43,7 @@ jobs: name: Build and push uses: docker/build-push-action@v3 with: + context: ./ + file: "./docker/${{TAG_NAME}}/Dockerfile" push: true tags: "${{env.BUILDKIT_IMAGE}}:${{env.TAG_NAME}}" \ No newline at end of file diff --git a/build.sh b/build.sh index 7c5e7e9..9beb278 100755 --- a/build.sh +++ b/build.sh @@ -1,9 +1,17 @@ -#!/usr/bin/env bash +#!/bin/bash if [ $# -eq 0 ] then tag='latest' else tag=$1 fi +if [ $tag != 'latest' ] +then + echo 'Build from from tag' + docker build -f docker/${tag}/Dockerfile -t jkaninda/laravel-php-fpm:$tag . +else + echo 'Build latest' + docker build -f docker/8.1/Dockerfile -t jkaninda/laravel-php-fpm:$tag . + +fi -docker build -t jkaninda/laravel-php-fpm:$tag . diff --git a/docker/7.2/Dockerfile b/docker/7.2/Dockerfile new file mode 100644 index 0000000..09b6127 --- /dev/null +++ b/docker/7.2/Dockerfile @@ -0,0 +1,91 @@ +FROM php:7.2-fpm +ARG WORKDIR=/var/www/html +ENV DOCUMENT_ROOT=${WORKDIR} +ENV LARAVEL_PROCS_NUMBER=1 +ENV NODE_VERSION=16.x +# 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 +# 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-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 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/supervisor/supervisord.conf /etc/supervisor/supervisord.conf + +COPY ./entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/entrypoint.sh +RUN ln -s /usr/local/bin/entrypoint.sh / + +ENTRYPOINT ["entrypoint.sh"] + + + +RUN usermod -u 1000 www-data +RUN groupmod -g 1000 www-data + +RUN chmod -R 755 $WORKDIR +RUN chown -R www-data:www-data $WORKDIR +EXPOSE 9000 +CMD [ "entrypoint" ] diff --git a/docker/7.4/Dockerfile b/docker/7.4/Dockerfile new file mode 100644 index 0000000..7715614 --- /dev/null +++ b/docker/7.4/Dockerfile @@ -0,0 +1,91 @@ +FROM php:7.4-fpm +ARG WORKDIR=/var/www/html +ENV DOCUMENT_ROOT=${WORKDIR} +ENV LARAVEL_PROCS_NUMBER=1 +ENV NODE_VERSION=16.x +# 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 +# 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-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 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/supervisor/supervisord.conf /etc/supervisor/supervisord.conf + +COPY ./entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/entrypoint.sh +RUN ln -s /usr/local/bin/entrypoint.sh / + +ENTRYPOINT ["entrypoint.sh"] + + + +RUN usermod -u 1000 www-data +RUN groupmod -g 1000 www-data + +RUN chmod -R 755 $WORKDIR +RUN chown -R www-data:www-data $WORKDIR +EXPOSE 9000 +CMD [ "entrypoint" ] diff --git a/docker/8.0/Dockerfile b/docker/8.0/Dockerfile new file mode 100644 index 0000000..e25af20 --- /dev/null +++ b/docker/8.0/Dockerfile @@ -0,0 +1,91 @@ +FROM php:8.0-fpm +ARG WORKDIR=/var/www/html +ENV DOCUMENT_ROOT=${WORKDIR} +ENV LARAVEL_PROCS_NUMBER=1 +ENV NODE_VERSION=16.x +# 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 +# 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 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/supervisor/supervisord.conf /etc/supervisor/supervisord.conf + +COPY ./entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/entrypoint.sh +RUN ln -s /usr/local/bin/entrypoint.sh / + +ENTRYPOINT ["entrypoint.sh"] + + + +RUN usermod -u 1000 www-data +RUN groupmod -g 1000 www-data + +RUN chmod -R 755 $WORKDIR +RUN chown -R www-data:www-data $WORKDIR +EXPOSE 9000 +CMD [ "entrypoint" ] diff --git a/Dockerfile b/docker/8.1/Dockerfile similarity index 100% rename from Dockerfile rename to docker/8.1/Dockerfile diff --git a/docker/8.2/Dockerfile b/docker/8.2/Dockerfile new file mode 100644 index 0000000..bb08b74 --- /dev/null +++ b/docker/8.2/Dockerfile @@ -0,0 +1,91 @@ +FROM php:8.2.0RC5-fpm +ARG WORKDIR=/var/www/html +ENV DOCUMENT_ROOT=${WORKDIR} +ENV LARAVEL_PROCS_NUMBER=1 +ENV NODE_VERSION=17.x +# 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 +# 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 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/supervisor/supervisord.conf /etc/supervisor/supervisord.conf + +COPY ./entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/entrypoint.sh +RUN ln -s /usr/local/bin/entrypoint.sh / + +ENTRYPOINT ["entrypoint.sh"] + + + +RUN usermod -u 1000 www-data +RUN groupmod -g 1000 www-data + +RUN chmod -R 755 $WORKDIR +RUN chown -R www-data:www-data $WORKDIR +EXPOSE 9000 +CMD [ "entrypoint" ] From df9eaa22aecb1631ee50b5917e571ccaffa820f3 Mon Sep 17 00:00:00 2001 From: Jonas Kaninda Date: Mon, 5 Dec 2022 13:45:19 +0200 Subject: [PATCH 2/4] Add tag based on folder --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5406f42..7acce16 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Docker image build and Push Image to registry +name: Docker build on: # Allows you to run this workflow manually from the Actions tab From b41dc0d28f31229cb0e4bfe2e73abd98c5fd136f Mon Sep 17 00:00:00 2001 From: Jonas Kaninda Date: Wed, 4 Jan 2023 17:30:37 +0200 Subject: [PATCH 3/4] Refactoring --- .github/workflows/build.yml | 55 ++++++++++++++++++++----------------- build.sh | 2 +- docker/7.4/Dockerfile | 6 ++-- docker/8.0/Dockerfile | 6 ++-- docker/8.1/Dockerfile | 9 +++--- docker/8.2/Dockerfile | 12 ++++---- 6 files changed, 51 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7acce16..997b45e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,32 +1,15 @@ -name: Docker build - +name: Build on: - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - inputs: - docker_tag: - description: 'Docker tag' - required: true - default: 'latest' - type: string + push: + branches: + - main env: - #BRANCH_NAME: ${{ github.head_ref || github.ref_name }} BUILDKIT_IMAGE: jkaninda/laravel-php-fpm jobs: docker: runs-on: ubuntu-latest steps: - - - name: Set environment for branch - run: | - set -x - if [[ ${{ inputs.docker_tag }} == 'latest' ]]; then - TAG_NAME=8.1 - echo "Build latest tag'" - else - TAG_NAME=${{ inputs.docker_tag }} - fi - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -40,10 +23,32 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push + name: Build and push 7.4 uses: docker/build-push-action@v3 with: - context: ./ - file: "./docker/${{TAG_NAME}}/Dockerfile" + file: "./docker/7.4/Dockerfile" push: true - tags: "${{env.BUILDKIT_IMAGE}}:${{env.TAG_NAME}}" \ No newline at end of file + tags: "${{env.BUILDKIT_IMAGE}}:7.4" + - + name: Build and push 8.0 + uses: docker/build-push-action@v3 + with: + file: "./docker/8.0/Dockerfile" + push: true + tags: "${{env.BUILDKIT_IMAGE}}:8.0" + - + name: Build and push 8.1 + uses: docker/build-push-action@v3 + with: + file: "./docker/8.1/Dockerfile" + push: true + tags: "${{env.BUILDKIT_IMAGE}}:8.1" + - + name: Build and push 8.2 + uses: docker/build-push-action@v3 + with: + file: "./docker/8.2/Dockerfile" + push: true + tags: | + "${{env.BUILDKIT_IMAGE}}:8.2" + "${{env.BUILDKIT_IMAGE}}:latest" \ No newline at end of file diff --git a/build.sh b/build.sh index 9beb278..2181309 100755 --- a/build.sh +++ b/build.sh @@ -11,7 +11,7 @@ then docker build -f docker/${tag}/Dockerfile -t jkaninda/laravel-php-fpm:$tag . else echo 'Build latest' - docker build -f docker/8.1/Dockerfile -t jkaninda/laravel-php-fpm:$tag . + docker build -f docker/8.2/Dockerfile -t jkaninda/laravel-php-fpm:$tag . fi diff --git a/docker/7.4/Dockerfile b/docker/7.4/Dockerfile index 7715614..06ea974 100644 --- a/docker/7.4/Dockerfile +++ b/docker/7.4/Dockerfile @@ -3,6 +3,8 @@ ARG WORKDIR=/var/www/html ENV DOCUMENT_ROOT=${WORKDIR} ENV LARAVEL_PROCS_NUMBER=1 ENV NODE_VERSION=16.x +ARG HOST_UID=1000 +ENV USER=www-data # Install system dependencies RUN apt-get update && apt-get install -y \ git \ @@ -82,8 +84,8 @@ ENTRYPOINT ["entrypoint.sh"] -RUN usermod -u 1000 www-data -RUN groupmod -g 1000 www-data +RUN usermod -u ${HOST_UID} www-data +RUN groupmod -g ${HOST_UID} www-data RUN chmod -R 755 $WORKDIR RUN chown -R www-data:www-data $WORKDIR diff --git a/docker/8.0/Dockerfile b/docker/8.0/Dockerfile index e25af20..862b394 100644 --- a/docker/8.0/Dockerfile +++ b/docker/8.0/Dockerfile @@ -3,6 +3,8 @@ ARG WORKDIR=/var/www/html ENV DOCUMENT_ROOT=${WORKDIR} ENV LARAVEL_PROCS_NUMBER=1 ENV NODE_VERSION=16.x +ARG HOST_UID=1000 +ENV USER=www-data # Install system dependencies RUN apt-get update && apt-get install -y \ git \ @@ -82,8 +84,8 @@ ENTRYPOINT ["entrypoint.sh"] -RUN usermod -u 1000 www-data -RUN groupmod -g 1000 www-data +RUN usermod -u ${HOST_UID} www-data +RUN groupmod -g ${HOST_UID} www-data RUN chmod -R 755 $WORKDIR RUN chown -R www-data:www-data $WORKDIR diff --git a/docker/8.1/Dockerfile b/docker/8.1/Dockerfile index 4e91e11..a1f8223 100644 --- a/docker/8.1/Dockerfile +++ b/docker/8.1/Dockerfile @@ -1,8 +1,10 @@ -FROM php:8.1.11-fpm +FROM php:8.1.13-fpm ARG WORKDIR=/var/www/html ENV DOCUMENT_ROOT=${WORKDIR} ENV LARAVEL_PROCS_NUMBER=1 ENV NODE_VERSION=17.x +ARG HOST_UID=1000 +ENV USER=www-data # Install system dependencies RUN apt-get update && apt-get install -y \ git \ @@ -81,9 +83,8 @@ RUN ln -s /usr/local/bin/entrypoint.sh / ENTRYPOINT ["entrypoint.sh"] - -RUN usermod -u 1000 www-data -RUN groupmod -g 1000 www-data +RUN usermod -u ${HOST_UID} www-data +RUN groupmod -g ${HOST_UID} www-data RUN chmod -R 755 $WORKDIR RUN chown -R www-data:www-data $WORKDIR diff --git a/docker/8.2/Dockerfile b/docker/8.2/Dockerfile index bb08b74..f6463b9 100644 --- a/docker/8.2/Dockerfile +++ b/docker/8.2/Dockerfile @@ -1,8 +1,10 @@ -FROM php:8.2.0RC5-fpm +FROM php:8.2.0-fpm ARG WORKDIR=/var/www/html ENV DOCUMENT_ROOT=${WORKDIR} ENV LARAVEL_PROCS_NUMBER=1 ENV NODE_VERSION=17.x +ARG HOST_UID=1000 +ENV USER=www-data # Install system dependencies RUN apt-get update && apt-get install -y \ git \ @@ -24,9 +26,9 @@ RUN apt-get update && apt-get install -y \ nano \ cron -#RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - +RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - # Install Node -#RUN apt-get install -y nodejs +RUN apt-get install -y nodejs # Clear cache RUN apt-get clean && rm -rf /var/lib/apt/lists/* # Install Kafka @@ -82,8 +84,8 @@ ENTRYPOINT ["entrypoint.sh"] -RUN usermod -u 1000 www-data -RUN groupmod -g 1000 www-data +RUN usermod -u ${HOST_UID} www-data +RUN groupmod -g ${HOST_UID} www-data RUN chmod -R 755 $WORKDIR RUN chown -R www-data:www-data $WORKDIR From b4db0d71c93120dda9106d1fa7580b103a673e99 Mon Sep 17 00:00:00 2001 From: Jonas Kaninda Date: Wed, 4 Jan 2023 17:31:43 +0200 Subject: [PATCH 4/4] Update action --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 997b45e..ad1c6e6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: Build on: push: branches: - - main + - master env: BUILDKIT_IMAGE: jkaninda/laravel-php-fpm