From ba1810a07140d68361a122088b018bce80024209 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Thu, 25 Jan 2024 17:00:44 +0100 Subject: [PATCH] create fpm only image, and add automatic matrix --- .github/workflows/build.yml | 284 ++++++------------ .github/workflows/lint.yml | 19 +- 8.1/Dockerfile | 61 ---- 8.2/Dockerfile | 61 ---- 8.3/Dockerfile | 61 ---- caddy/Dockerfile | 23 ++ {rootfs => caddy/rootfs}/etc/caddy/Caddyfile | 0 {rootfs => caddy/rootfs}/etc/supervisord.conf | 0 Dockerfile.template => fpm/Dockerfile | 13 +- {rootfs => fpm/rootfs}/setup | 0 .../usr/local/etc/php-fpm.d/docker.conf | 2 +- .../usr/local/etc/php/conf.d/docker.ini | 0 .../rootfs}/usr/local/shopware/functions.sh | 8 +- .../rootfs}/usr/local/shopware/setup_6.5.x | 0 .../rootfs}/usr/local/shopware/setup_6.6.x | 4 +- matrix.php | 50 +++ 16 files changed, 188 insertions(+), 398 deletions(-) delete mode 100644 8.1/Dockerfile delete mode 100644 8.2/Dockerfile delete mode 100644 8.3/Dockerfile create mode 100644 caddy/Dockerfile rename {rootfs => caddy/rootfs}/etc/caddy/Caddyfile (100%) rename {rootfs => caddy/rootfs}/etc/supervisord.conf (100%) rename Dockerfile.template => fpm/Dockerfile (83%) rename {rootfs => fpm/rootfs}/setup (100%) rename {rootfs => fpm/rootfs}/usr/local/etc/php-fpm.d/docker.conf (94%) rename {rootfs => fpm/rootfs}/usr/local/etc/php/conf.d/docker.ini (100%) rename {rootfs => fpm/rootfs}/usr/local/shopware/functions.sh (92%) rename {rootfs => fpm/rootfs}/usr/local/shopware/setup_6.5.x (100%) rename {rootfs => fpm/rootfs}/usr/local/shopware/setup_6.6.x (91%) create mode 100644 matrix.php diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f988070..dda3753 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,12 +2,7 @@ name: Build on: workflow_dispatch: push: - branches: - - main - paths: - - "Dockerfile.template" - - ".github/workflows/build.yml" - - "rootfs/**" + pull_request: env: DOCKER_BUILDKIT: 1 @@ -19,183 +14,83 @@ permissions: packages: write jobs: - php81-arm64: - name: 8.1 on ARM64 - runs-on: hcloud-arm64-small + generate-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.generate-matrix.outputs.matrix }} steps: - - uses: actions/checkout@v3 - - - name: Install Cosign - uses: sigstore/cosign-installer@v3 - - - name: Login into Docker Hub - run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin - - - name: Login into Github Docker Registery - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - uses: docker/build-push-action@v4 - with: - tags: ghcr.io/shopware/docker-base:8.1.26-arm64 - context: . - file: 8.1/Dockerfile - cache-from: type=registry,ref=ghcr.io/shopware/docker-cache:8.1-arm64 - cache-to: type=registry,ref=ghcr.io/shopware/docker-cache:8.1-arm64,mode=max - platforms: linux/arm64 - push: true - provenance: false + - name: Checkout + uses: actions/checkout@v4 - php81-amd64: - name: 8.1 on AMD64 - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 + - name: Generate Matrix + id: generate-matrix + run: | + MATRIX=$(php matrix.php) + echo "matrix<> $GITHUB_OUTPUT + echo "$MATRIX" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT - - name: Install Cosign - uses: sigstore/cosign-installer@v3 - - - name: Login into Github Docker Registery - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - uses: docker/build-push-action@v4 - with: - tags: ghcr.io/shopware/docker-base:8.1.26-amd64 - context: . - file: 8.1/Dockerfile - cache-from: type=registry,ref=ghcr.io/shopware/docker-cache:8.1-amd64 - cache-to: type=registry,ref=ghcr.io/shopware/docker-cache:8.1-amd64,mode=max - platforms: linux/amd64 - push: true - provenance: false - - php82-arm64: - name: 8.2 on ARM64 - runs-on: hcloud-arm64-small + build-fpm-amd64: + name: PHP FPM ${{ matrix.php }} on amd64 + runs-on: ubuntu-latest + needs: [generate-matrix] + strategy: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} steps: - - uses: actions/checkout@v3 - - - name: Install Cosign - uses: sigstore/cosign-installer@v3 + - name: Checkout + uses: actions/checkout@v4 - - name: Login into Docker Hub - run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin - - name: Login into Github Docker Registery run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - - uses: docker/build-push-action@v4 + - uses: docker/build-push-action@v5 with: - tags: ghcr.io/shopware/docker-base:8.2.14-arm64 - context: . - file: 8.2/Dockerfile - cache-from: type=registry,ref=ghcr.io/shopware/docker-cache:8.2-arm64 - cache-to: type=registry,ref=ghcr.io/shopware/docker-cache:8.2-arm64,mode=max - platforms: linux/arm64 + tags: ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-fpm-amd64 + context: fpm + cache-from: type=registry,ref=ghcr.io/shopware/docker-cache:${{ matrix.phpPatch }}-fpm-amd64 + cache-to: type=registry,ref=ghcr.io/shopware/docker-cache:${{ matrix.phpPatch }}-fpm-amd64,mode=max + platforms: linux/amd64 + build-args: | + PHP_PATCH_VERSION=${{ matrix.phpPatch }} + PHP_DIGEST=${{ matrix.phpPatchDigest }} push: true provenance: false - php82-amd64: - name: 8.2 on AMD64 - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - - name: Install Cosign - uses: sigstore/cosign-installer@v3 - - - name: Login into Github Docker Registery - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - uses: docker/build-push-action@v4 - with: - tags: ghcr.io/shopware/docker-base:8.2.14-amd64 - context: . - file: 8.2/Dockerfile - cache-from: type=registry,ref=ghcr.io/shopware/docker-cache:8.2-amd64 - cache-to: type=registry,ref=ghcr.io/shopware/docker-cache:8.2-amd64,mode=max - platforms: linux/amd64 - push: true - provenance: false - - php83-arm64: - name: 8.3 on ARM64 + build-fpm-arm64: + name: PHP FPM ${{ matrix.php }} on arm64 runs-on: hcloud-arm64-small + needs: [generate-matrix] + strategy: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v4 - - name: Install Cosign - uses: sigstore/cosign-installer@v3 - - - name: Login into Docker Hub - run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin - - name: Login into Github Docker Registery run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - - uses: docker/build-push-action@v4 + - uses: docker/build-push-action@v5 with: - tags: ghcr.io/shopware/docker-base:8.3.1-arm64 - context: . - file: 8.3/Dockerfile - cache-from: type=registry,ref=ghcr.io/shopware/docker-cache:8.3-arm64 - cache-to: type=registry,ref=ghcr.io/shopware/docker-cache:8.3-arm64,mode=max + tags: ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-fpm-arm64 + context: fpm + cache-from: type=registry,ref=ghcr.io/shopware/docker-cache:${{ matrix.phpPatch }}-fpm-arm64 + cache-to: type=registry,ref=ghcr.io/shopware/docker-cache:${{ matrix.phpPatch }}-fpm-arm64,mode=max platforms: linux/arm64 + build-args: | + PHP_PATCH_VERSION=${{ matrix.phpPatch }} + PHP_DIGEST=${{ matrix.phpPatchDigest }} push: true provenance: false - php83-amd64: - name: 8.3 on AMD64 - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - - name: Install Cosign - uses: sigstore/cosign-installer@v3 - - - name: Login into Github Docker Registery - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - uses: docker/build-push-action@v4 - with: - tags: ghcr.io/shopware/docker-base:8.3.1-amd64 - context: . - file: 8.3/Dockerfile - cache-from: type=registry,ref=ghcr.io/shopware/docker-cache:8.3-amd64 - cache-to: type=registry,ref=ghcr.io/shopware/docker-cache:8.3-amd64,mode=max - platforms: linux/amd64 - push: true - provenance: false - - - merge-manifest: - name: Merge Manifest + fpm-merge: + name: Generate Docker Manifest for PHP ${{ matrix.php }} runs-on: ubuntu-latest - needs: - - php81-arm64 - - php81-amd64 - - php82-arm64 - - php82-amd64 - - php83-arm64 - - php83-amd64 - + needs: [generate-matrix, build-fpm-amd64, build-fpm-arm64] + strategy: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} steps: - name: Login into Docker Hub run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin @@ -211,51 +106,56 @@ jobs: wget https://github.com/regclient/regclient/releases/latest/download/regctl-linux-amd64 chmod +x regctl-linux-amd64 - - run: docker manifest create ghcr.io/shopware/docker-base:8.1 --amend ghcr.io/shopware/docker-base:8.1.26-amd64 --amend ghcr.io/shopware/docker-base:8.1.26-arm64 - - - run: docker manifest create ghcr.io/shopware/docker-base:8.1.26 --amend ghcr.io/shopware/docker-base:8.1.26-amd64 --amend ghcr.io/shopware/docker-base:8.1.26-arm64 - - - run: docker manifest push ghcr.io/shopware/docker-base:8.1 - - - run: docker manifest push ghcr.io/shopware/docker-base:8.1.26 - - - run: cosign sign --yes ghcr.io/shopware/docker-base:8.1 + - run: docker manifest create ghcr.io/shopware/docker-base:${{ matrix.php }}-fpm --amend ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-fpm-amd64 --amend ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-fpm-arm64 - - run: cosign sign --yes ghcr.io/shopware/docker-base:8.1.26 + - run: docker manifest create ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-fpm --amend ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-fpm-amd64 --amend ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-fpm-arm64 - - run: ./regctl-linux-amd64 image copy ghcr.io/shopware/docker-base:8.1 shopware/docker-base:8.1 + - run: docker manifest push ghcr.io/shopware/docker-base:${{ matrix.php }}-fpm - - run: ./regctl-linux-amd64 image copy ghcr.io/shopware/docker-base:8.1.26 shopware/docker-base:8.1.26 + - run: docker manifest push ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-fpm - - run: docker manifest create ghcr.io/shopware/docker-base:8.2 --amend ghcr.io/shopware/docker-base:8.2.14-amd64 --amend ghcr.io/shopware/docker-base:8.2.14-arm64 + - run: cosign sign --yes ghcr.io/shopware/docker-base:${{ matrix.php }}-fpm - - run: docker manifest create ghcr.io/shopware/docker-base:8.2.14 --amend ghcr.io/shopware/docker-base:8.2.14-amd64 --amend ghcr.io/shopware/docker-base:8.2.14-arm64 + - run: cosign sign --yes ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-fpm - - run: docker manifest push ghcr.io/shopware/docker-base:8.2 + - run: ./regctl-linux-amd64 image copy ghcr.io/shopware/docker-base:${{ matrix.php }}-fpm shopware/docker-base:${{ matrix.php }}-fpm - - run: docker manifest push ghcr.io/shopware/docker-base:8.2.14 - - - run: cosign sign --yes ghcr.io/shopware/docker-base:8.2 - - - run: cosign sign --yes ghcr.io/shopware/docker-base:8.2.14 - - - run: ./regctl-linux-amd64 image copy ghcr.io/shopware/docker-base:8.2 shopware/docker-base:8.2 - - - run: ./regctl-linux-amd64 image copy ghcr.io/shopware/docker-base:8.2.14 shopware/docker-base:8.2.14 - - - run: docker manifest create ghcr.io/shopware/docker-base:8.3 --amend ghcr.io/shopware/docker-base:8.3.1-amd64 --amend ghcr.io/shopware/docker-base:8.3.1-arm64 - - - run: docker manifest create ghcr.io/shopware/docker-base:8.3.1 --amend ghcr.io/shopware/docker-base:8.3.1-amd64 --amend ghcr.io/shopware/docker-base:8.3.1-arm64 - - - run: docker manifest push ghcr.io/shopware/docker-base:8.3 - - - run: docker manifest push ghcr.io/shopware/docker-base:8.3.1 - - - run: cosign sign --yes ghcr.io/shopware/docker-base:8.3 + - run: ./regctl-linux-amd64 image copy ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-fpm shopware/docker-base:${{ matrix.phpPatch }}-fpm + + caddy: + name: Build Caddy ${{ matrix.php }} + runs-on: ubuntu-latest + needs: [generate-matrix, fpm-merge] + strategy: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} + steps: + - name: Checkout + uses: actions/checkout@v4 - - run: cosign sign --yes ghcr.io/shopware/docker-base:8.3.1 + - name: Login into Github Docker Registery + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - run: ./regctl-linux-amd64 image copy ghcr.io/shopware/docker-base:8.3 shopware/docker-base:8.3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - - run: ./regctl-linux-amd64 image copy ghcr.io/shopware/docker-base:8.3.1 shopware/docker-base:8.3.1 + - uses: docker/build-push-action@v5 + with: + tags: | + ghcr.io/shopware/docker-base:${{ matrix.php }}-caddy + ghcr.io/shopware/docker-base:${{ matrix.php }} + ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-caddy + ghcr.io/shopware/docker-base:${{ matrix.phpPatch }} + shopware/docker-base:${{ matrix.php }}-caddy + shopware/docker-base:${{ matrix.php }} + shopware/docker-base:${{ matrix.phpPatch }}-caddy + shopware/docker-base:${{ matrix.phpPatch }} + context: caddy + cache-from: type=registry,ref=ghcr.io/shopware/docker-cache:${{ matrix.php }}-caddy + cache-to: type=registry,ref=ghcr.io/shopware/docker-cache:${{ matrix.php }}-caddy,mode=max + platforms: linux/amd64,linux/arm64 + build-args: | + PHP_PATCH_VERSION=${{ matrix.phpPatch }} + PHP_DIGEST=${{ matrix.phpPatchDigest }} + SUPERVISORD_DIGEST=${{ matrix.supervisordDigest }} + push: false + provenance: false diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cd902fa..aa452d6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,21 +10,20 @@ on: jobs: lint: - name: 'Lint Dockerfile (PHP: ${{ matrix.php-version }})' + name: Lint Dockerfiles runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - php-version: - - '8.1' - - '8.2' steps: - name: Checkout uses: actions/checkout@v4 - - name: Lint Dockerfile - id: hadolint + - name: Lint FPM uses: hadolint/hadolint-action@master with: - dockerfile: ./${{ matrix.php-version }}/Dockerfile + dockerfile: ./fpm/Dockerfile + ignore: DL3018 + + - name: Lint Caddy + uses: hadolint/hadolint-action@master + with: + dockerfile: ./caddy/Dockerfile ignore: DL3018 diff --git a/8.1/Dockerfile b/8.1/Dockerfile deleted file mode 100644 index 0d9594e..0000000 --- a/8.1/Dockerfile +++ /dev/null @@ -1,61 +0,0 @@ -#syntax=docker/dockerfile:1.4 - -FROM docker.io/library/php:8.1.26-fpm-alpine@sha256:b480cfc032ee8fc1e0fcc0925301830ce798d55b4ed8c241f9727ee5e0389b9e - -ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ - -RUN apk add --no-cache icu-data-full curl jq trurl caddy && \ - apk upgrade --no-cache && \ - chmod +x /usr/local/bin/install-php-extensions && \ - install-php-extensions bcmath gd intl mysqli pdo_mysql pcntl sockets bz2 gmp soap zip ffi redis opcache apcu amqp && \ - mkdir -p /var/www/html && \ - mv "${PHP_INI_DIR}/php.ini-production" "${PHP_INI_DIR}/php.ini" && \ - rm -f /usr/local/etc/php-fpm.d/zz-docker.conf && \ - rm -f /usr/local/etc/php-fpm.d/www.conf && \ - rm -f /usr/local/etc/php-fpm.d/www.conf.default && \ - ln -s /usr/sbin/caddy /usr/bin/caddy - -COPY --from=shyim/supervisord:latest@sha256:8671c375d4890f6592dcab242758427f47303b47b96fe31d86c949a496a9cda2 --link /usr/local/bin/supervisord /usr/bin/supervisord - -ENV APP_ENV=prod \ - APP_URL_CHECK_DISABLED=1 \ - SHOPWARE_SKIP_WEBINSTALLER=1 \ - LOCK_DSN=flock \ - MAILER_DSN=null://localhost \ - DATABASE_PORT=3306 \ - OPENSEARCH_URL= \ - SHOPWARE_ES_ENABLED=0 \ - SHOPWARE_ES_INDEXING_ENABLED=0 \ - SHOPWARE_ES_INDEX_PREFIX= \ - COMPOSER_HOME=/tmp/composer \ - SHOPWARE_HTTP_CACHE_ENABLED=1 \ - SHOPWARE_HTTP_DEFAULT_TTL=7200 \ - SHOPWARE_CACHE_ID=docker \ - BLUE_GREEN_DEPLOYMENT=0 \ - SHOPWARE_SKIP_WEBINSTALLER=1 \ - COMPOSER_PLUGIN_LOADER=1 \ - INSTALL_LOCALE=en-GB \ - INSTALL_CURRENCY=EUR \ - INSTALL_ADMIN_USERNAME=admin \ - INSTALL_ADMIN_PASSWORD=shopware \ - FPM_PM=dynamic \ - FPM_PM_MAX_CHILDREN=5 \ - FPM_PM_START_SERVERS=2 \ - FPM_PM_MIN_SPARE_SERVERS=1 \ - FPM_PM_MAX_SPARE_SERVERS=3 \ - PHP_SESSION_HANDLER=files \ - PHP_SESSION_SAVE_PATH= \ - PHP_MAX_UPLOAD_SIZE=128m \ - PHP_MAX_EXECUTION_TIME=300 \ - PHP_MEMORY_LIMIT=512m \ - PHP_ERROR_REPORTING=E_ALL \ - MYSQL_WAIT_SECONDS=20 - -USER www-data - -COPY --link rootfs / - -EXPOSE 8000 -WORKDIR /var/www/html - -ENTRYPOINT [ "/usr/bin/supervisord", "-c", "/etc/supervisord.conf" ] diff --git a/8.2/Dockerfile b/8.2/Dockerfile deleted file mode 100644 index caf0660..0000000 --- a/8.2/Dockerfile +++ /dev/null @@ -1,61 +0,0 @@ -#syntax=docker/dockerfile:1.4 - -FROM docker.io/library/php:8.2.14-fpm-alpine@sha256:27d888ffb761d4ceb967067bb23859347a0b644e1bad589c73a2a8a5b184a73d - -ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ - -RUN apk add --no-cache icu-data-full curl jq trurl caddy && \ - apk upgrade --no-cache && \ - chmod +x /usr/local/bin/install-php-extensions && \ - install-php-extensions bcmath gd intl mysqli pdo_mysql pcntl sockets bz2 gmp soap zip ffi redis opcache apcu amqp && \ - mkdir -p /var/www/html && \ - mv "${PHP_INI_DIR}/php.ini-production" "${PHP_INI_DIR}/php.ini" && \ - rm -f /usr/local/etc/php-fpm.d/zz-docker.conf && \ - rm -f /usr/local/etc/php-fpm.d/www.conf && \ - rm -f /usr/local/etc/php-fpm.d/www.conf.default && \ - ln -s /usr/sbin/caddy /usr/bin/caddy - -COPY --from=shyim/supervisord:latest@sha256:8671c375d4890f6592dcab242758427f47303b47b96fe31d86c949a496a9cda2 --link /usr/local/bin/supervisord /usr/bin/supervisord - -ENV APP_ENV=prod \ - APP_URL_CHECK_DISABLED=1 \ - SHOPWARE_SKIP_WEBINSTALLER=1 \ - LOCK_DSN=flock \ - MAILER_DSN=null://localhost \ - DATABASE_PORT=3306 \ - OPENSEARCH_URL= \ - SHOPWARE_ES_ENABLED=0 \ - SHOPWARE_ES_INDEXING_ENABLED=0 \ - SHOPWARE_ES_INDEX_PREFIX= \ - COMPOSER_HOME=/tmp/composer \ - SHOPWARE_HTTP_CACHE_ENABLED=1 \ - SHOPWARE_HTTP_DEFAULT_TTL=7200 \ - SHOPWARE_CACHE_ID=docker \ - BLUE_GREEN_DEPLOYMENT=0 \ - SHOPWARE_SKIP_WEBINSTALLER=1 \ - COMPOSER_PLUGIN_LOADER=1 \ - INSTALL_LOCALE=en-GB \ - INSTALL_CURRENCY=EUR \ - INSTALL_ADMIN_USERNAME=admin \ - INSTALL_ADMIN_PASSWORD=shopware \ - FPM_PM=dynamic \ - FPM_PM_MAX_CHILDREN=5 \ - FPM_PM_START_SERVERS=2 \ - FPM_PM_MIN_SPARE_SERVERS=1 \ - FPM_PM_MAX_SPARE_SERVERS=3 \ - PHP_SESSION_HANDLER=files \ - PHP_SESSION_SAVE_PATH= \ - PHP_MAX_UPLOAD_SIZE=128m \ - PHP_MAX_EXECUTION_TIME=300 \ - PHP_MEMORY_LIMIT=512m \ - PHP_ERROR_REPORTING=E_ALL \ - MYSQL_WAIT_SECONDS=20 - -USER www-data - -COPY --link rootfs / - -EXPOSE 8000 -WORKDIR /var/www/html - -ENTRYPOINT [ "/usr/bin/supervisord", "-c", "/etc/supervisord.conf" ] diff --git a/8.3/Dockerfile b/8.3/Dockerfile deleted file mode 100644 index 78dc4fc..0000000 --- a/8.3/Dockerfile +++ /dev/null @@ -1,61 +0,0 @@ -#syntax=docker/dockerfile:1.4 - -FROM docker.io/library/php:8.3.1-fpm-alpine@sha256:3b8c170dfa6e6c06a074656837af4ca9b5e8dc748f5ced0785a46f018f2b1dc8 - -ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ - -RUN apk add --no-cache icu-data-full curl jq trurl caddy && \ - apk upgrade --no-cache && \ - chmod +x /usr/local/bin/install-php-extensions && \ - install-php-extensions bcmath gd intl mysqli pdo_mysql pcntl sockets bz2 gmp soap zip ffi redis opcache apcu amqp && \ - mkdir -p /var/www/html && \ - mv "${PHP_INI_DIR}/php.ini-production" "${PHP_INI_DIR}/php.ini" && \ - rm -f /usr/local/etc/php-fpm.d/zz-docker.conf && \ - rm -f /usr/local/etc/php-fpm.d/www.conf && \ - rm -f /usr/local/etc/php-fpm.d/www.conf.default && \ - ln -s /usr/sbin/caddy /usr/bin/caddy - -COPY --from=shyim/supervisord:latest@sha256:8671c375d4890f6592dcab242758427f47303b47b96fe31d86c949a496a9cda2 --link /usr/local/bin/supervisord /usr/bin/supervisord - -ENV APP_ENV=prod \ - APP_URL_CHECK_DISABLED=1 \ - SHOPWARE_SKIP_WEBINSTALLER=1 \ - LOCK_DSN=flock \ - MAILER_DSN=null://localhost \ - DATABASE_PORT=3306 \ - OPENSEARCH_URL= \ - SHOPWARE_ES_ENABLED=0 \ - SHOPWARE_ES_INDEXING_ENABLED=0 \ - SHOPWARE_ES_INDEX_PREFIX= \ - COMPOSER_HOME=/tmp/composer \ - SHOPWARE_HTTP_CACHE_ENABLED=1 \ - SHOPWARE_HTTP_DEFAULT_TTL=7200 \ - SHOPWARE_CACHE_ID=docker \ - BLUE_GREEN_DEPLOYMENT=0 \ - SHOPWARE_SKIP_WEBINSTALLER=1 \ - COMPOSER_PLUGIN_LOADER=1 \ - INSTALL_LOCALE=en-GB \ - INSTALL_CURRENCY=EUR \ - INSTALL_ADMIN_USERNAME=admin \ - INSTALL_ADMIN_PASSWORD=shopware \ - FPM_PM=dynamic \ - FPM_PM_MAX_CHILDREN=5 \ - FPM_PM_START_SERVERS=2 \ - FPM_PM_MIN_SPARE_SERVERS=1 \ - FPM_PM_MAX_SPARE_SERVERS=3 \ - PHP_SESSION_HANDLER=files \ - PHP_SESSION_SAVE_PATH= \ - PHP_MAX_UPLOAD_SIZE=128m \ - PHP_MAX_EXECUTION_TIME=300 \ - PHP_MEMORY_LIMIT=512m \ - PHP_ERROR_REPORTING=E_ALL \ - MYSQL_WAIT_SECONDS=20 - -USER www-data - -COPY --link rootfs / - -EXPOSE 8000 -WORKDIR /var/www/html - -ENTRYPOINT [ "/usr/bin/supervisord", "-c", "/etc/supervisord.conf" ] diff --git a/caddy/Dockerfile b/caddy/Dockerfile new file mode 100644 index 0000000..d50c31a --- /dev/null +++ b/caddy/Dockerfile @@ -0,0 +1,23 @@ +#syntax=docker/dockerfile:1.4 + +ARG PHP_PATCH_VERSION + +FROM ghcr.io/shopware/docker-base:${PHP_PATCH_VERSION}-fpm + +USER root + +RUN apk add --no-cache caddy && \ + ln -s /usr/sbin/caddy /usr/bin/caddy + +COPY --from=shyim/supervisord:latest --link /usr/local/bin/supervisord /usr/bin/supervisord + +USER www-data + +COPY --link rootfs / + +EXPOSE 8000 +WORKDIR /var/www/html + +ENV FPM_LISTEN=/tmp/php-fpm.sock + +ENTRYPOINT [ "/usr/bin/supervisord", "-c", "/etc/supervisord.conf" ] diff --git a/rootfs/etc/caddy/Caddyfile b/caddy/rootfs/etc/caddy/Caddyfile similarity index 100% rename from rootfs/etc/caddy/Caddyfile rename to caddy/rootfs/etc/caddy/Caddyfile diff --git a/rootfs/etc/supervisord.conf b/caddy/rootfs/etc/supervisord.conf similarity index 100% rename from rootfs/etc/supervisord.conf rename to caddy/rootfs/etc/supervisord.conf diff --git a/Dockerfile.template b/fpm/Dockerfile similarity index 83% rename from Dockerfile.template rename to fpm/Dockerfile index a559d0e..f662b34 100644 --- a/Dockerfile.template +++ b/fpm/Dockerfile @@ -1,10 +1,13 @@ #syntax=docker/dockerfile:1.4 +ARG PHP_PATCH_VERSION +ARG PHP_DIGEST + FROM docker.io/library/php:${PHP_PATCH_VERSION}-fpm-alpine@${PHP_DIGEST} ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ -RUN apk add --no-cache icu-data-full curl jq trurl caddy && \ +RUN apk add --no-cache icu-data-full curl jq trurl && \ apk upgrade --no-cache && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions bcmath gd intl mysqli pdo_mysql pcntl sockets bz2 gmp soap zip ffi redis opcache apcu amqp && \ @@ -12,10 +15,7 @@ RUN apk add --no-cache icu-data-full curl jq trurl caddy && \ mv "${PHP_INI_DIR}/php.ini-production" "${PHP_INI_DIR}/php.ini" && \ rm -f /usr/local/etc/php-fpm.d/zz-docker.conf && \ rm -f /usr/local/etc/php-fpm.d/www.conf && \ - rm -f /usr/local/etc/php-fpm.d/www.conf.default && \ - ln -s /usr/sbin/caddy /usr/bin/caddy - -COPY --from=shyim/supervisord:latest@${SUPERVISORD_DIGEST} --link /usr/local/bin/supervisord /usr/bin/supervisord + rm -f /usr/local/etc/php-fpm.d/www.conf.default ENV APP_ENV=prod \ APP_URL_CHECK_DISABLED=1 \ @@ -49,6 +49,7 @@ ENV APP_ENV=prod \ PHP_MAX_EXECUTION_TIME=300 \ PHP_MEMORY_LIMIT=512m \ PHP_ERROR_REPORTING=E_ALL \ + FPM_LISTEN=9000 \ MYSQL_WAIT_SECONDS=20 USER www-data @@ -58,4 +59,4 @@ COPY --link rootfs / EXPOSE 8000 WORKDIR /var/www/html -ENTRYPOINT [ "/usr/bin/supervisord", "-c", "/etc/supervisord.conf" ] +ENTRYPOINT [ "/usr/local/sbin/php-fpm" ] diff --git a/rootfs/setup b/fpm/rootfs/setup similarity index 100% rename from rootfs/setup rename to fpm/rootfs/setup diff --git a/rootfs/usr/local/etc/php-fpm.d/docker.conf b/fpm/rootfs/usr/local/etc/php-fpm.d/docker.conf similarity index 94% rename from rootfs/usr/local/etc/php-fpm.d/docker.conf rename to fpm/rootfs/usr/local/etc/php-fpm.d/docker.conf index 0477ef7..46e348c 100644 --- a/rootfs/usr/local/etc/php-fpm.d/docker.conf +++ b/fpm/rootfs/usr/local/etc/php-fpm.d/docker.conf @@ -6,7 +6,7 @@ error_log = /proc/self/fd/2 log_limit = 8192 [www] -listen = /tmp/php-fpm.sock +listen = ${FPM_LISTEN} clear_env = no pm = ${FPM_PM} pm.max_children = ${FPM_PM_MAX_CHILDREN} diff --git a/rootfs/usr/local/etc/php/conf.d/docker.ini b/fpm/rootfs/usr/local/etc/php/conf.d/docker.ini similarity index 100% rename from rootfs/usr/local/etc/php/conf.d/docker.ini rename to fpm/rootfs/usr/local/etc/php/conf.d/docker.ini diff --git a/rootfs/usr/local/shopware/functions.sh b/fpm/rootfs/usr/local/shopware/functions.sh similarity index 92% rename from rootfs/usr/local/shopware/functions.sh rename to fpm/rootfs/usr/local/shopware/functions.sh index 7eb1b00..7a04d4e 100644 --- a/rootfs/usr/local/shopware/functions.sh +++ b/fpm/rootfs/usr/local/shopware/functions.sh @@ -48,9 +48,9 @@ run_hooks() { hook=$1 if [ -d "/usr/local/shopware/$hook.d" ]; then for file in "/usr/local/shopware/$hook.d"/*.sh; do - echo "Running $file for $hook" - # shellcheck source=/dev/null - . "$file" - done + echo "Running $file for $hook" + # shellcheck source=../../../../../../../../../dev/null + . "$file" +done fi } diff --git a/rootfs/usr/local/shopware/setup_6.5.x b/fpm/rootfs/usr/local/shopware/setup_6.5.x similarity index 100% rename from rootfs/usr/local/shopware/setup_6.5.x rename to fpm/rootfs/usr/local/shopware/setup_6.5.x diff --git a/rootfs/usr/local/shopware/setup_6.6.x b/fpm/rootfs/usr/local/shopware/setup_6.6.x similarity index 91% rename from rootfs/usr/local/shopware/setup_6.6.x rename to fpm/rootfs/usr/local/shopware/setup_6.6.x index edf6d32..52e5828 100755 --- a/rootfs/usr/local/shopware/setup_6.6.x +++ b/fpm/rootfs/usr/local/shopware/setup_6.6.x @@ -12,9 +12,9 @@ if console system:is-installed; then run_hooks pre_update if [ "${SHOPWARE_SKIP_ASSET_COPY-""}" ]; then - console system:update:finish --skip-asset-build + console system:update:finish --skip-asset-build else - console system:update:finish + console system:update:finish fi if [ "${SHOPWARE_SKIP_ASSET_COPY-""}" ]; then diff --git a/matrix.php b/matrix.php new file mode 100644 index 0000000..3260c38 --- /dev/null +++ b/matrix.php @@ -0,0 +1,50 @@ +\d\.\d\.\d{1,}(RC\d)?)/m'; + +$supervisord = get_digest_of_image('shyim/supervisord', 'latest'); + +foreach ($supportedVersions as $supportedVersion) +{ + $apiResponse = json_decode(file_get_contents('https://hub.docker.com/v2/repositories/library/php/tags/?page_size=50&page=1&name=' . $supportedVersion. '.'), true); + + if (!is_array($apiResponse)) { + throw new \RuntimeException("invalid api response"); + } + + $curVersion = null; + $patchVersion = null; + $rcVersion = null; + + foreach ($apiResponse['results'] as $entry) { + preg_match($versionRegex, $entry['name'], $rcVersion); + + if (strpos($entry['name'], 'RC') !== false && !in_array($rcVersion['version'], $rcVersions)) { + continue; + } + + preg_match($versionRegex, $entry['name'], $patchVersion); + } + + if ($patchVersion === null) { + throw new \RuntimeException('There is no version found for PHP ' . $supportedVersion); + } + + $phpDigest = get_digest_of_image('library/php', $patchVersion['version'] . '-fpm-alpine'); + + $data[] = [ + 'php' => $supportedVersion, + 'phpPatch' => $patchVersion['version'], + 'phpPatchDigest' => $phpDigest, + 'supervisordDigest' => $supervisord, + ]; +} + +echo json_encode(['matrix' => ['include' => $data]], JSON_THROW_ON_ERROR);