From b1bc4ca919b4d734d12c16a3e398059fe7f20549 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Thu, 25 Jan 2024 17:00:44 +0100 Subject: [PATCH 01/14] 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 c6a3b84..0ff6362 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); From aaf9a8d672a9fcb141e714314814b752f7cdea4f Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Mon, 29 Jan 2024 14:54:43 +0100 Subject: [PATCH 02/14] remove expose 8000 --- fpm/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/fpm/Dockerfile b/fpm/Dockerfile index f662b34..44ef063 100644 --- a/fpm/Dockerfile +++ b/fpm/Dockerfile @@ -56,7 +56,6 @@ USER www-data COPY --link rootfs / -EXPOSE 8000 WORKDIR /var/www/html ENTRYPOINT [ "/usr/local/sbin/php-fpm" ] From 682a77f0bae47cedac3d1eccb4070910538bb9af Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Thu, 25 Jan 2024 17:00:44 +0100 Subject: [PATCH 03/14] Generate image name in matrix.php --- .github/workflows/build.yml | 31 +++++++++++++++---------------- matrix.php | 4 ++++ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dda3753..f0a2527 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,10 +47,10 @@ jobs: - uses: docker/build-push-action@v5 with: - tags: ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-fpm-amd64 + tags: ${{ matrix.fpm-image }}-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 + cache-from: type=registry,ref=${{ matrix.fpm-image-cache }}-amd64 + cache-to: type=registry,ref=${{ matrix.fpm-image-cache }}-amd64,mode=max platforms: linux/amd64 build-args: | PHP_PATCH_VERSION=${{ matrix.phpPatch }} @@ -75,10 +75,10 @@ jobs: - uses: docker/build-push-action@v5 with: - tags: ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-fpm-arm64 + tags: ${{ matrix.fpm-image }}-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 + cache-from: type=registry,ref=${{ matrix.fpm-image-cache }}-arm64 + cache-to: type=registry,ref=${{ matrix.fpm-image-cache }}-arm64,mode=max platforms: linux/arm64 build-args: | PHP_PATCH_VERSION=${{ matrix.phpPatch }} @@ -106,21 +106,19 @@ 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:${{ matrix.php }}-fpm --amend ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-fpm-amd64 --amend ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-fpm-arm64 + - run: docker manifest create ${{ matrix.fpm-image }} --amend ${{ matrix.fpm-image }}-amd64 --amend ${{ matrix.fpm-image }}-arm64 - - 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: docker tag ${{ matrix.fpm-image }} ${{ matrix.fpm-patch-image }} - - run: docker manifest push ghcr.io/shopware/docker-base:${{ matrix.php }}-fpm + - run: docker manifest push ${{ matrix.fpm-image }} - - run: docker manifest push ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-fpm + - run: cosign sign --yes ${{ matrix.fpm-image }} - - run: cosign sign --yes ghcr.io/shopware/docker-base:${{ matrix.php }}-fpm + - if: github.ref == 'refs/heads/main' + run: ./regctl-linux-amd64 image copy ${{ matrix.fpm-image }} ${{ matrix.fpm-hub-image }} - - run: cosign sign --yes ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-fpm - - - run: ./regctl-linux-amd64 image copy ghcr.io/shopware/docker-base:${{ matrix.php }}-fpm shopware/docker-base:${{ matrix.php }}-fpm - - - run: ./regctl-linux-amd64 image copy ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-fpm shopware/docker-base:${{ matrix.phpPatch }}-fpm + - if: github.ref == 'refs/heads/main' + run: ./regctl-linux-amd64 image copy ${{ matrix.fpm-patch-image }} ${{ matrix.fpm-patch-hub-image }} caddy: name: Build Caddy ${{ matrix.php }} @@ -138,6 +136,7 @@ jobs: uses: docker/setup-buildx-action@v3 - uses: docker/build-push-action@v5 + if: github.ref == 'refs/heads/main' with: tags: | ghcr.io/shopware/docker-base:${{ matrix.php }}-caddy diff --git a/matrix.php b/matrix.php index 3260c38..5aaac8b 100644 --- a/matrix.php +++ b/matrix.php @@ -44,6 +44,10 @@ 'phpPatch' => $patchVersion['version'], 'phpPatchDigest' => $phpDigest, 'supervisordDigest' => $supervisord, + 'fpm-image' => 'ghcr.io/shopware/docker-base:' . $supportedVersion . '-fpm', + 'fpm-patch-image' => 'ghcr.io/shopware/docker-base:' . $patchVersion['version'] . '-fpm', + 'fpm-hub-image' => 'shopware/docker-base:' . $supportedVersion . '-fpm', + 'fpm-patch-hub-image' => 'shopware/docker-base:' . $patchVersion['version'] . '-fpm', ]; } From 8cb9329b272d80c2982579fac557fc29493b0fbe Mon Sep 17 00:00:00 2001 From: Patrick Weyck Date: Mon, 29 Jan 2024 15:22:54 +0100 Subject: [PATCH 04/14] Use job id for mr build images --- .github/workflows/build.yml | 10 ++++++---- matrix.php | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f0a2527..b0a1377 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,6 +18,8 @@ jobs: runs-on: ubuntu-latest outputs: matrix: ${{ steps.generate-matrix.outputs.matrix }} + environment: + GH_JOB_ID: ${{ github.job }} steps: - name: Checkout uses: actions/checkout@v4 @@ -49,8 +51,8 @@ jobs: with: tags: ${{ matrix.fpm-image }}-amd64 context: fpm - cache-from: type=registry,ref=${{ matrix.fpm-image-cache }}-amd64 - cache-to: type=registry,ref=${{ matrix.fpm-image-cache }}-amd64,mode=max + cache-from: type=gha + cache-to: type=gha,mode=max platforms: linux/amd64 build-args: | PHP_PATCH_VERSION=${{ matrix.phpPatch }} @@ -77,8 +79,8 @@ jobs: with: tags: ${{ matrix.fpm-image }}-arm64 context: fpm - cache-from: type=registry,ref=${{ matrix.fpm-image-cache }}-arm64 - cache-to: type=registry,ref=${{ matrix.fpm-image-cache }}-arm64,mode=max + cache-from: type=gha + cache-to: type=gha,mode=max platforms: linux/arm64 build-args: | PHP_PATCH_VERSION=${{ matrix.phpPatch }} diff --git a/matrix.php b/matrix.php index 5aaac8b..8d10c44 100644 --- a/matrix.php +++ b/matrix.php @@ -39,15 +39,17 @@ $phpDigest = get_digest_of_image('library/php', $patchVersion['version'] . '-fpm-alpine'); + $imagePrefix = $_ENV['GH_JOB_ID'] ? ($_ENV['GH_JOB_ID'] . '_') : ''; + $data[] = [ 'php' => $supportedVersion, 'phpPatch' => $patchVersion['version'], 'phpPatchDigest' => $phpDigest, 'supervisordDigest' => $supervisord, - 'fpm-image' => 'ghcr.io/shopware/docker-base:' . $supportedVersion . '-fpm', - 'fpm-patch-image' => 'ghcr.io/shopware/docker-base:' . $patchVersion['version'] . '-fpm', - 'fpm-hub-image' => 'shopware/docker-base:' . $supportedVersion . '-fpm', - 'fpm-patch-hub-image' => 'shopware/docker-base:' . $patchVersion['version'] . '-fpm', + 'fpm-image' => 'ghcr.io/shopware/docker-base:' . $imagePrefix . $supportedVersion . '-fpm', + 'fpm-patch-image' => 'ghcr.io/shopware/docker-base:' . $imagePrefix . $patchVersion['version'] . '-fpm', + 'fpm-hub-image' => 'shopware/docker-base:' . $imagePrefix . $supportedVersion . '-fpm', + 'fpm-patch-hub-image' => 'shopware/docker-base:' . $imagePrefix . $patchVersion['version'] . '-fpm', ]; } From 6bea0e44daf82e740d79cc9fee4e01d0a8a55d8a Mon Sep 17 00:00:00 2001 From: Patrick Weyck Date: Mon, 29 Jan 2024 15:34:14 +0100 Subject: [PATCH 05/14] Pass env correctly --- .github/workflows/build.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b0a1377..8cda51b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,6 +8,7 @@ env: DOCKER_BUILDKIT: 1 COSIGN_EXPERIMENTAL: 1 + permissions: contents: write id-token: write @@ -18,8 +19,6 @@ jobs: runs-on: ubuntu-latest outputs: matrix: ${{ steps.generate-matrix.outputs.matrix }} - environment: - GH_JOB_ID: ${{ github.job }} steps: - name: Checkout uses: actions/checkout@v4 @@ -27,7 +26,7 @@ jobs: - name: Generate Matrix id: generate-matrix run: | - MATRIX=$(php matrix.php) + MATRIX=$(GH_JOB_ID=${{ github.job }} php matrix.php) echo "matrix<> $GITHUB_OUTPUT echo "$MATRIX" >> $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT From d9c2557e7bcfbd6d1b0ecba3d9b18d94c0717e4c Mon Sep 17 00:00:00 2001 From: Patrick Weyck Date: Mon, 29 Jan 2024 15:40:53 +0100 Subject: [PATCH 06/14] Use GITHUB_RUN_ID --- .github/workflows/build.yml | 2 +- matrix.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8cda51b..4bbb703 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,7 @@ jobs: - name: Generate Matrix id: generate-matrix run: | - MATRIX=$(GH_JOB_ID=${{ github.job }} php matrix.php) + MATRIX=$(php matrix.php) echo "matrix<> $GITHUB_OUTPUT echo "$MATRIX" >> $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT diff --git a/matrix.php b/matrix.php index 8d10c44..6802f1e 100644 --- a/matrix.php +++ b/matrix.php @@ -39,7 +39,7 @@ $phpDigest = get_digest_of_image('library/php', $patchVersion['version'] . '-fpm-alpine'); - $imagePrefix = $_ENV['GH_JOB_ID'] ? ($_ENV['GH_JOB_ID'] . '_') : ''; + $imagePrefix = $_SERVER['GITHUB_RUN_ID'] ? ($_SERVER['GITHUB_RUN_ID'] . '-') : ''; $data[] = [ 'php' => $supportedVersion, From 47f744ed823d13ae04b3d569a37d80e136d737f4 Mon Sep 17 00:00:00 2001 From: Patrick Weyck Date: Mon, 29 Jan 2024 15:55:06 +0100 Subject: [PATCH 07/14] Fix manifest creation --- .github/workflows/build.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4bbb703..700fe34 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -109,12 +109,16 @@ jobs: - run: docker manifest create ${{ matrix.fpm-image }} --amend ${{ matrix.fpm-image }}-amd64 --amend ${{ matrix.fpm-image }}-arm64 - - run: docker tag ${{ matrix.fpm-image }} ${{ matrix.fpm-patch-image }} - - run: docker manifest push ${{ matrix.fpm-image }} - run: cosign sign --yes ${{ matrix.fpm-image }} + - run: docker manifest create ${{ matrix.fpm-patch-image }} --amend ${{ matrix.fpm-image }}-amd64 --amend ${{ matrix.fpm-image }}-arm64 + + - run: docker manifest push ${{ matrix.fpm-patch-image }} + + - run: cosign sign --yes ${{ matrix.fpm-patch-image }} + - if: github.ref == 'refs/heads/main' run: ./regctl-linux-amd64 image copy ${{ matrix.fpm-image }} ${{ matrix.fpm-hub-image }} From e65e040d00da2dbe41572e4e7bf9837cee7e49c9 Mon Sep 17 00:00:00 2001 From: Patrick Weyck Date: Mon, 29 Jan 2024 16:12:53 +0100 Subject: [PATCH 08/14] Fix cache --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 700fe34..6f55664 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,8 +50,8 @@ jobs: with: tags: ${{ matrix.fpm-image }}-amd64 context: fpm - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=gha,scope=fpm-${{ matrix.php }}-amd64 + cache-to: type=gha,mode=max,scope=fpm-${{ matrix.php }}-amd64 platforms: linux/amd64 build-args: | PHP_PATCH_VERSION=${{ matrix.phpPatch }} @@ -78,8 +78,8 @@ jobs: with: tags: ${{ matrix.fpm-image }}-arm64 context: fpm - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=gha,scope=fpm-${{ matrix.php }}-arm64 + cache-to: type=gha,mode=max,scope=fpm-${{ matrix.php }}-arm64 platforms: linux/arm64 build-args: | PHP_PATCH_VERSION=${{ matrix.phpPatch }} From 81dd1b2cfe3775c34c095a6be322638d38a5c18c Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Mon, 29 Jan 2024 16:54:43 +0100 Subject: [PATCH 09/14] fix shellcheck --- fpm/rootfs/setup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fpm/rootfs/setup b/fpm/rootfs/setup index 343a60e..325827f 100755 --- a/fpm/rootfs/setup +++ b/fpm/rootfs/setup @@ -7,9 +7,9 @@ shopware_version=$(jq '.packages[] | select (.name == "shopware/core") | .versio # if shopware version starts with 6.6 echo 6.6 # shellcheck disable=SC2081,SC3010 if [[ $shopware_version == v6.6.* ]]; then - # shellcheck source-path=./rootfs source=./usr/local/shopware/setup_6.6.x + # shellcheck source-path=./fpm/rootfs source=./usr/local/shopware/setup_6.6.x . /usr/local/shopware/setup_6.6.x else - # shellcheck source-path=./rootfs source=./usr/local/shopware/setup_6.5.x + # shellcheck source-path=./fpm/rootfs source=./usr/local/shopware/setup_6.5.x . /usr/local/shopware/setup_6.5.x fi From 92d218c5ea3e6f3be86ad65d29ae902b8192d1e1 Mon Sep 17 00:00:00 2001 From: Patrick Weyck Date: Mon, 29 Jan 2024 16:44:07 +0100 Subject: [PATCH 10/14] Only run push on main branch --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6f55664..35d4b81 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,6 +2,8 @@ name: Build on: workflow_dispatch: push: + branches: + - main pull_request: env: From 78de7a75790beb6a34c99d3cbd3749dedd37223f Mon Sep 17 00:00:00 2001 From: Patrick Weyck Date: Tue, 30 Jan 2024 08:46:09 +0100 Subject: [PATCH 11/14] Run check after building images --- .github/workflows/build.yml | 53 +++++++++++++++++++++++++++++++------ .github/workflows/pr.yml | 49 ---------------------------------- matrix.php | 18 +++++++++++++ 3 files changed, 63 insertions(+), 57 deletions(-) delete mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 35d4b81..6c64966 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -146,14 +146,7 @@ jobs: if: github.ref == 'refs/heads/main' 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 }} + ${{ matrix.caddy-tags }} 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 @@ -165,3 +158,47 @@ jobs: push: false provenance: false + check: + name: Test Image + runs-on: ubuntu-latest + needs: [caddy] + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Checkout + uses: actions/checkout@v4 + + - name: Checkout example repo + uses: actions/checkout@v4 + with: + path: example-repo + repository: shopwareLabs/example-docker-repository + + - name: Build + id: build + uses: docker/build-push-action@v5 + with: + push: false + load: true + build-args: | + BASE_IMAGE=ghcr.io/shopware/docker-base:${{ github.run_id }}-8.3-caddy + context: . + file: Dockerfile + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Run image + env: + DOCKER_BUILDKIT: 0 + working-directory: example-repo + run: docker compose up -d --wait + + - name: Check if shopware is running + run: curl --fail localhost:8000/admin + + # output logs if failed + - name: Output logs + working-directory: example-repo + run: docker compose logs + if: ${{ failure() }} \ No newline at end of file diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml deleted file mode 100644 index 2d59b69..0000000 --- a/.github/workflows/pr.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Smoke test Image -on: - pull_request: - -jobs: - check: - name: Test Image - runs-on: ubuntu-latest - steps: - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Checkout - uses: actions/checkout@v4 - - - name: Checkout example repo - uses: actions/checkout@v4 - with: - path: example-repo - repository: shopwareLabs/example-docker-repository - - - name: Build - id: build - uses: docker/build-push-action@v5 - with: - push: false - load: true - tags: | - shopware/docker-base:8.3 - docker.io/shopware/docker-base:8.3 - context: . - file: 8.3/Dockerfile - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Run image - env: - DOCKER_BUILDKIT: 0 - working-directory: example-repo - run: docker compose up -d --wait - - - name: Check if shopware is running - run: curl --fail localhost:8000/admin - - # output logs if failed - - name: Output logs - working-directory: example-repo - run: docker compose logs - if: ${{ failure() }} diff --git a/matrix.php b/matrix.php index 6802f1e..9d13067 100644 --- a/matrix.php +++ b/matrix.php @@ -41,15 +41,33 @@ $imagePrefix = $_SERVER['GITHUB_RUN_ID'] ? ($_SERVER['GITHUB_RUN_ID'] . '-') : ''; + $caddyImages = [ + 'ghcr.io/shopware/docker-base:' . $imagePrefix . $supportedVersion, + 'ghcr.io/shopware/docker-base:' . $imagePrefix . $supportedVersion . '-caddy', + 'ghcr.io/shopware/docker-base:' . $imagePrefix . $patchVersion['version'], + 'ghcr.io/shopware/docker-base:' . $imagePrefix . $$patchVersion['version'] . '-caddy', + ]; + + if (!$imagePrefix) { + $caddyImages = array_merge($caddyImages, [ + 'shopware/docker-base:' . $imagePrefix . $supportedVersion, + 'shopware/docker-base:' . $imagePrefix . $supportedVersion . '-caddy', + 'shopware/docker-base:' . $imagePrefix . $patchVersion['version'], + 'shopware/docker-base:' . $imagePrefix . $patchVersion['version'] . '-caddy', + ]); + } + $data[] = [ 'php' => $supportedVersion, 'phpPatch' => $patchVersion['version'], 'phpPatchDigest' => $phpDigest, 'supervisordDigest' => $supervisord, + 'base-image' => 'ghcr.io/shopware/docker-base:' . $imagePrefix . $supportedVersion, 'fpm-image' => 'ghcr.io/shopware/docker-base:' . $imagePrefix . $supportedVersion . '-fpm', 'fpm-patch-image' => 'ghcr.io/shopware/docker-base:' . $imagePrefix . $patchVersion['version'] . '-fpm', 'fpm-hub-image' => 'shopware/docker-base:' . $imagePrefix . $supportedVersion . '-fpm', 'fpm-patch-hub-image' => 'shopware/docker-base:' . $imagePrefix . $patchVersion['version'] . '-fpm', + 'caddy-tags' => implode("\n", $caddyImages), ]; } From 8c051b4118e4b9ea07269f563cb652c96c635647 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Tue, 30 Jan 2024 09:52:55 +0100 Subject: [PATCH 12/14] fix test pipeline --- .github/workflows/build.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6c64966..952cf98 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -166,13 +166,9 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Checkout - uses: actions/checkout@v4 - - name: Checkout example repo uses: actions/checkout@v4 with: - path: example-repo repository: shopwareLabs/example-docker-repository - name: Build @@ -191,7 +187,6 @@ jobs: - name: Run image env: DOCKER_BUILDKIT: 0 - working-directory: example-repo run: docker compose up -d --wait - name: Check if shopware is running From eeb8e552f4e40674ff523f004757f5aef550be01 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Tue, 30 Jan 2024 09:55:40 +0100 Subject: [PATCH 13/14] push caddy image --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 952cf98..070d363 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -143,7 +143,6 @@ jobs: uses: docker/setup-buildx-action@v3 - uses: docker/build-push-action@v5 - if: github.ref == 'refs/heads/main' with: tags: | ${{ matrix.caddy-tags }} From 13196847b48bbfa4cb66002ad9378c976753d221 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Tue, 30 Jan 2024 09:58:46 +0100 Subject: [PATCH 14/14] push caddy image --- .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 070d363..df1bd61 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -154,7 +154,7 @@ jobs: PHP_PATCH_VERSION=${{ matrix.phpPatch }} PHP_DIGEST=${{ matrix.phpPatchDigest }} SUPERVISORD_DIGEST=${{ matrix.supervisordDigest }} - push: false + push: true provenance: false check: