Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 71
feat: CI job for building Docker binary-only images#122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
a141d41f69e736e0c258d672be39383dd4599e25f88585fd27a6097961ba6a8File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -38,3 +38,77 @@ jobs: | ||
| if: ${{startsWith(github.ref, 'refs/tags/') }} | ||
| with: | ||
| files: pie.phar | ||
| docker-binary-only-image: | ||
| needs: build-phar | ||
| name: Docker binary-only image | ||
| runs-on: ubuntu-latest | ||
| if: ${{ startsWith(github.ref, 'refs/tags/') }} | ||
| permissions: | ||
| # attestations:write is required for build provenance attestation. | ||
| attestations: write | ||
| # id-token:write is required for build provenance attestation. | ||
| id-token: write | ||
| # packages:write is required to publish Docker images to GitHub's registry. | ||
| packages: write | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Fetch built PHAR from artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: pie-${{ github.sha }}.phar | ||
| - name: Verify the PHAR | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: gh attestation verify pie.phar --repo ${{ github.repository }} | ||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@v3 | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| - name: Log in to the Container registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Extract metadata (tags, labels) for Docker | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| flavor: | | ||
| latest=false | ||
| images: ghcr.io/${{ github.repository }} | ||
| # @TODO v1.0 Consider introducing more granular tags (major and major.minor) | ||
| # @see https://github.com/php/pie/pull/122#pullrequestreview-2477496308 | ||
| # @see https://github.com/php/pie/pull/122#discussion_r1867331273 | ||
| tags: | | ||
| type=raw,value=bin | ||
| type=semver,pattern={{version}}-bin | ||
| - name: Build and push Docker image | ||
| id: build-and-push | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| platforms: linux/amd64,linux/arm64 | ||
asgrim marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| file: Dockerfile | ||
| target: standalone-binary | ||
| push: true | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| - name: Generate artifact attestation | ||
| uses: actions/attest-build-provenance@v1 | ||
| with: | ||
| subject-name: ghcr.io/${{ github.repository }} | ||
| subject-digest: ${{ steps.build-and-push.outputs.digest }} | ||
| push-to-registry: true | ||
asgrim marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| FROM scratch AS standalone-binary | ||
| # @TODO change to --chmod=+x when https://github.com/moby/buildkit/pull/5380 is released | ||
asgrim marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| COPY --chmod=0755 pie.phar /pie | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -27,6 +27,19 @@ system: | ||
| sudo curl -L --output /usr/local/bin/pie https://github.com/php/pie/releases/latest/download/pie.phar && sudo chmod +x /usr/local/bin/pie | ||
| ``` | ||
| ### Docker installation | ||
| PIE is published as binary-only Docker image, so you can install it easily during your Docker build: | ||
Wirone marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ```Dockerfile | ||
| COPY --from=ghcr.io/php/pie:bin /pie /usr/bin/pie | ||
| ``` | ||
| Instead of `bin` tag (which represents latest binary-only image) you can also use explicit version (in `x.y.z-bin` format). Use [GitHub registry](https://ghcr.io/php/pie) to find available tags. | ||
| > [!IMPORTANT] | ||
| > Binary-only images don't include PHP runtime so you can't use them for _running_ PIE. This is just an alternative way of distributing PHAR file, you still need to satisfy PIE's runtime requirements on your own. | ||
| ## Prerequisites for PIE | ||
| Running PIE requires PHP 8.1 or newer. However, you may still use PIE to install | ||
Uh oh!
There was an error while loading. Please reload this page.