Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM php:8.4-cli

# zip: ZipArchive in JSignPdfRuntimeService | sockets: donatj/mock-webserver in the tests
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod uga+x /usr/local/bin/install-php-extensions && sync \
&& install-php-extensions \
sockets \
zip \
@composer \
&& rm /usr/local/bin/install-php-extensions

# PharData exceeds the default 128M just to open the JRE tarball
RUN echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/app.ini

WORKDIR /app
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,31 @@ Change parameters of JSignPDF:
$param->setJSignParameters("-a -kst PKCS12 -ts https://freetsa.org/tsr");
```

## Docker Environment

The repository ships a minimal Docker setup (`Dockerfile` and `compose.yml`) with the extensions
the test suite needs.

```bash
docker compose build
docker compose run --rm php composer install
```

Checks, the same ones the CI runs:

```bash
docker compose run --rm php composer run test:unit
docker compose run --rm php composer run cs:check # cs:fix to apply the formatting
docker compose run --rm php composer run psalm
```

### Usage example

To sign a PDF end to end. It downloads the JRE and the JSignPdf jar into `tmp/` on the first run:
Comment thread
YvesCesar marked this conversation as resolved.

```bash
docker compose run --rm php php example/index.php
```

## Credits
- [Jeidison Farias](https://github.com/jeidison)
9 changes: 9 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
php:
build: .
# export HOST_UID/HOST_GID if yours are not 1000, so the files it writes are yours (see: id -u; id -g)
user: "${HOST_UID:-1000}:${HOST_GID:-1000}"
environment:
COMPOSER_HOME: ${COMPOSER_HOME:-/tmp/composer}
volumes:
- .:/app
1 change: 1 addition & 0 deletions tests/Runtime/JavaRuntimeServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public function testGetPathWithDownloadUrlWithInvalidVersion(): void
$baseUrl = $server->getServerRoot();
$url = $baseUrl . '/OpenJDK21U-jre_x64_linux_hotspot_21.0.8_9.tar.gz';
$jsignParam->setJavaDownloadUrl($url);
$jsignParam->setJavaPath($this->testTmpDir . '/bin/java');

$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/cannot be extracted/');
Expand Down
Loading