Skip to content

Commit b038d83

Browse files
committed
Prepare CI job for building Docker binary-only images
1 parent c6f0f4b commit b038d83

3 files changed

Lines changed: 63 additions & 0 deletions

File tree

.github/workflows/build-phar.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,8 @@ jobs:
6161
with:
6262
name: pie-${{ github.sha }}.phar
6363
path: pie.phar
64+
- name: Store PHAR as artifact
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: phar-binary
68+
path: pie.phar

.github/workflows/release.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77

88
permissions:
99
contents: read
10+
packages: write
1011

1112
jobs:
1213
build-phar:
@@ -38,3 +39,56 @@ jobs:
3839
if: ${{startsWith(github.ref, 'refs/tags/') }}
3940
with:
4041
files: pie.phar
42+
43+
docker-binary-only-image:
44+
needs: build-phar
45+
name: Docker binary-only image
46+
runs-on: ubuntu-latest
47+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
48+
49+
steps:
50+
- name: Checkout repository
51+
uses: actions/checkout@v4
52+
53+
- name: Restore built PHAR
54+
uses: actions/download-artifact@v4
55+
with:
56+
name: phar-binary
57+
58+
- name: Set up QEMU
59+
uses: docker/setup-qemu-action@v3
60+
61+
- name: Set up Docker Buildx
62+
uses: docker/setup-buildx-action@v3
63+
64+
- name: Log in to the Container registry
65+
uses: docker/login-action@v3
66+
with:
67+
registry: ghcr.io
68+
username: ${{ github.actor }}
69+
password: ${{ secrets.GITHUB_TOKEN }}
70+
71+
- name: Extract metadata (tags, labels) for Docker
72+
id: meta
73+
uses: docker/metadata-action@v5
74+
with:
75+
flavor: |
76+
latest=false
77+
suffix=-bin
78+
images: ghcr.io/${{ github.repository }}
79+
tags: |
80+
type=raw,value=latest-bin
81+
type=semver,pattern={{version}}
82+
type=semver,pattern={{major}}.{{minor}}
83+
type=semver,pattern={{major}}
84+
85+
- name: Build and push Docker image
86+
uses: docker/build-push-action@v5
87+
with:
88+
context: .
89+
platforms: linux/amd64,linux/arm64
90+
file: Dockerfile
91+
target: standalone-binary
92+
push: true
93+
tags: ${{ steps.meta.outputs.tags }}
94+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM scratch AS standalone-binary
2+
3+
# @TODO change to --chmod=+x when https://github.com/moby/buildkit/pull/5380 is released
4+
COPY --chmod=0755 pie.phar /pie

0 commit comments

Comments
 (0)