Skip to content

Commit

Permalink
feat: Support Alpine
Browse files Browse the repository at this point in the history
  • Loading branch information
tienvx committed May 14, 2024
1 parent d14890e commit 2944deb
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,28 @@ jobs:
uses: coverallsapp/github-action@v2
with:
parallel-finished: true

test-alpine:
runs-on: ubuntu-latest
needs:
- php-cs
strategy:
fail-fast: false
matrix:
arch: [ amd64, arm64 ]

steps:
- uses: actions/checkout@v4
name: Checkout repository
- name: Set up QEMU
if: matrix.arch == 'arm64'
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: matrix.arch == 'arm64'
uses: docker/setup-buildx-action@v3
- name: run musl # If shared-mime-info not installed - Expected binary contents to have content type 'image/jpeg' but detected contents was 'application/octet-stream'
if: matrix.arch == 'amd64'
run: docker run --platform=linux/${{ matrix.arch }} --rm -v $PWD:/home you54f/pact-php:alpine-base-${{ matrix.arch }} /bin/sh -c 'apk add --no-cache shared-mime-info && cd /home && composer install && composer gen-lib && composer test'
- name: run musl # If shared-mime-info installed - Expected binary contents to have content type 'image/jpeg' but detected contents was 'application/octet-stream'
if: matrix.arch == 'arm64'
run: docker run --platform=linux/${{ matrix.arch }} --rm -v $PWD:/home you54f/pact-php:alpine-base-${{ matrix.arch }} /bin/sh -c 'cd /home && composer install && composer gen-lib && composer test'
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM php:8.3-alpine
RUN apk add --no-cache linux-headers libffi-dev protoc protobuf-dev musl-dev autoconf gcc g++ make
COPY --from=composer/composer:2-bin /composer /usr/local/bin/composer
RUN docker-php-ext-install sockets
RUN docker-php-ext-install ffi
RUN pecl install grpc
RUN echo 'extension=grpc.so' >> /usr/local/etc/php/conf.d/grpc.ini
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ _\*_ v3 support is limited to the subset of functionality required to enable lan
| Linux | arm64 || 9.x + |
| Windows | x86_64 || All |
| Windows | x86 || 9.x - |
| Alpine | x86_64 || 10.x + |
| Alpine | arm64 || 10.x + |

</details>

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"composer/semver": "^1.4.0|^3.2.0",
"symfony/process": "^5.4|^6.0|^7.0",
"guzzlehttp/psr7": "^2.4.5",
"pact-foundation/composer-downloads-plugin": "^2.0"
"pact-foundation/composer-downloads-plugin": "^2.1"
},
"require-dev": {
"ext-sockets": "*",
Expand Down Expand Up @@ -123,9 +123,10 @@
"{$prefix}": "PHP_OS_FAMILY === 'Windows' ? 'pact_ffi' : 'libpact_ffi'",
"{$os}": "PHP_OS === 'Darwin' ? 'osx' : strtolower(PHP_OS_FAMILY)",
"{$architecture}": "in_array(php_uname('m'), ['arm64', 'aarch64']) ? (PHP_OS === 'Darwin' ? 'aarch64-apple-darwin' : 'aarch64') : 'x86_64'",
"{$musl}": "PHP_OS === 'Linux' && musl() === true ? '-musl' : ''",
"{$extension}": "PHP_OS_FAMILY === 'Windows' ? 'dll' : (PHP_OS === 'Darwin' ? 'dylib' : 'so')"
},
"url": "https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v{$version}/{$prefix}-{$os}-{$architecture}.{$extension}.gz",
"url": "https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v{$version}/{$prefix}-{$os}-{$architecture}{$musl}.{$extension}.gz",
"path": "bin/pact-ffi-lib/pact.{$extension}"
},
"pact-stub-server": {
Expand Down
7 changes: 4 additions & 3 deletions example/protobuf-sync-message/provider/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"require": {
"grpc/grpc": "^1.57",
"spiral/roadrunner-grpc": "^3.2",
"pact-foundation/composer-downloads-plugin": "^2.0"
"pact-foundation/composer-downloads-plugin": "^2.1"
},
"require-dev": {
"ext-grpc": "*"
Expand All @@ -16,11 +16,12 @@
"rr": {
"version": "2023.3.10",
"variables": {
"{$os}": "strtolower(PHP_OS_FAMILY)",
"{$os}": "PHP_OS === 'Linux' && musl() === true ? 'unknown' : strtolower(PHP_OS_FAMILY)",
"{$musl}": "PHP_OS === 'Linux' && musl() === true ? '-musl' : ''",
"{$architecture}": "in_array(php_uname('m'), ['x86_64', 'AMD64']) ? 'amd64' : 'arm64'",
"{$extension}": "(PHP_OS_FAMILY === 'Windows' || (PHP_OS_FAMILY === 'Darwin' && php_uname('m') === 'x86_64')) ? 'zip' : 'tar.gz'"
},
"url": "https://github.com/roadrunner-server/roadrunner/releases/download/v{$version}/roadrunner-{$version}-{$os}-{$architecture}.{$extension}",
"url": "https://github.com/roadrunner-server/roadrunner/releases/download/v{$version}/roadrunner-{$version}-{$os}{$musl}-{$architecture}.{$extension}",
"path": "bin/roadrunner"
}
}
Expand Down

0 comments on commit 2944deb

Please sign in to comment.