|
| 1 | +name: Build PHP 8 Security Images |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: read |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: php8-security-release |
| 11 | + cancel-in-progress: false |
| 12 | + |
| 13 | +env: |
| 14 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" |
| 15 | + |
| 16 | +jobs: |
| 17 | + docker: |
| 18 | + runs-on: ubuntu-24.04 |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + max-parallel: 1 |
| 22 | + matrix: |
| 23 | + phpVersion: ["8.2.35", "8.3.36", "8.4.27", "8.5.12"] |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v6 |
| 27 | + |
| 28 | + - name: Prepare source build with 1Panel configuration |
| 29 | + shell: bash |
| 30 | + env: |
| 31 | + PHP_VERSION: ${{ matrix.phpVersion }} |
| 32 | + run: | |
| 33 | + set -euo pipefail |
| 34 | + python3 - <<'PY' |
| 35 | + import os |
| 36 | + import shutil |
| 37 | + from pathlib import Path |
| 38 | +
|
| 39 | + version = os.environ["PHP_VERSION"] |
| 40 | + source = Path("php/8") |
| 41 | + context = Path(os.environ["RUNNER_TEMP"]) / "php-security" |
| 42 | + context.mkdir() |
| 43 | + shutil.copytree(source / "data", context / "data") |
| 44 | + for helper in (source / "upstream").glob("docker-php-*"): |
| 45 | + shutil.copy2(helper, context / helper.name) |
| 46 | + (context / helper.name).chmod(0o755) |
| 47 | +
|
| 48 | + upstream = (source / "upstream" / version / "Dockerfile").read_text() |
| 49 | + assert upstream.count("FROM debian:trixie-slim\n") == 1 |
| 50 | + assert f"ENV PHP_VERSION {version}\n" in upstream |
| 51 | + assert upstream.count('make -j "$(nproc)"') == 1 |
| 52 | + upstream = upstream.replace("FROM debian:trixie-slim\n", "FROM debian:trixie-slim AS php-upstream\n", 1) |
| 53 | + upstream = upstream.replace('make -j "$(nproc)"', 'make -j 2', 1) |
| 54 | +
|
| 55 | + runtime = (source / "Dockerfile").read_text() |
| 56 | + base = "ARG PHP_VERSION\nFROM php:${PHP_VERSION}-fpm\n" |
| 57 | + assert runtime.startswith(base) |
| 58 | + runtime = "FROM php-upstream\n" + runtime[len(base):] |
| 59 | + smoke = f"\nRUN php -r 'exit(PHP_VERSION === \"{version}\" ? 0 : 1);' && php-fpm -t && supervisord --version && composer --version\n" |
| 60 | + (context / "Dockerfile").write_text(upstream + "\n" + runtime + smoke) |
| 61 | + PY |
| 62 | +
|
| 63 | + - name: Set up QEMU |
| 64 | + uses: docker/setup-qemu-action@v3 |
| 65 | + |
| 66 | + - name: Set up Docker Buildx |
| 67 | + uses: docker/setup-buildx-action@v4 |
| 68 | + with: |
| 69 | + buildkitd-config-inline: | |
| 70 | + [worker.oci] |
| 71 | + max-parallelism = 1 |
| 72 | +
|
| 73 | + - name: Login to Docker Hub |
| 74 | + uses: docker/login-action@v4 |
| 75 | + with: |
| 76 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 77 | + password: ${{ secrets.DOCKERHUB_PASSWORD }} |
| 78 | + |
| 79 | + - name: Build PHP-FPM security image and push |
| 80 | + uses: docker/build-push-action@v7 |
| 81 | + with: |
| 82 | + context: ${{ runner.temp }}/php-security |
| 83 | + file: ${{ runner.temp }}/php-security/Dockerfile |
| 84 | + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8 |
| 85 | + pull: true |
| 86 | + push: true |
| 87 | + tags: 1panel/php:${{ matrix.phpVersion }}-fpm |
| 88 | + cache-from: type=gha,scope=php-security-${{ matrix.phpVersion }} |
| 89 | + cache-to: type=gha,mode=max,scope=php-security-${{ matrix.phpVersion }} |
0 commit comments