From 1f0022b6e179f2cda0ab860a9e95d05056e4b5c2 Mon Sep 17 00:00:00 2001 From: xgaia Date: Fri, 28 Jan 2022 17:23:51 +0100 Subject: [PATCH 1/4] ci: dockerize and push with gh-actions --- .github/workflows/docker.yaml | 54 +++++++++++++++++++++++++++++++++++ Dockerfile | 18 ++++++++++++ apache.conf | 22 ++++++++++++++ php.ini | 3 ++ 4 files changed, 97 insertions(+) create mode 100644 .github/workflows/docker.yaml create mode 100644 Dockerfile create mode 100644 apache.conf create mode 100644 php.ini diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..01dfee8 --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,54 @@ +name: Docker publish + +on: + push: + branches: + - 'master' + tags: + - '*.*.*' + +jobs: + docker: + environment: docker-registry + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + # list of Docker images to use as base name for tags + images: registry.hub.docker.com/${{ secrets.DOCKER_REGISTRY_USERNAME }}/signaturepdf + # generate Docker tags based on the following events/attributes + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to registry + uses: docker/login-action@v1 + with: + registry: registry.hub.docker.com + username: xgaia + password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + secrets: | + GIT_AUTH_TOKEN=${{ secrets.DOCKER_REGISTRY_TOKEN }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0435aee --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM php:7.4-apache + +ENV SERVERNAME=localhost + +RUN apt update && apt install -y gettext-base librsvg2-bin pdftk imagemagick potrace + +COPY . /usr/local/signaturepdf + +RUN chown -R www-data:www-data /usr/local/signaturepdf && chmod 750 -R /usr/local/signaturepdf && \ + cp /usr/local/signaturepdf/php.ini /usr/local/etc/php/conf.d/uploads.ini && \ + cat /usr/local/signaturepdf/apache.conf | envsubst > /etc/apache2/sites-available/signaturepdf.conf && \ + a2enmod rewrite && a2ensite signaturepdf + +WORKDIR /usr/local/signaturepdf + +CMD envsubst < /usr/local/signaturepdf/apache.conf > /etc/apache2/sites-available/signaturepdf.conf && \ + chown -R www-data:www-data /usr/local/signaturepdf && chmod 750 -R /usr/local/signaturepdf && \ + apache2-foreground diff --git a/apache.conf b/apache.conf new file mode 100644 index 0000000..3a077d0 --- /dev/null +++ b/apache.conf @@ -0,0 +1,22 @@ + + ServerName ${SERVERNAME} + DocumentRoot /usr/local/signaturepdf/public + DirectoryIndex index.php + + AddDefaultCharset UTF-8 + + + AllowOverride All + = 2.3> + Require all granted + + + Order Deny,Allow + Allow from all + + + + LogLevel warn + ErrorLog /var/log/apache2/ssp_error.log + CustomLog /var/log/apache2/ssp_access.log combined + diff --git a/php.ini b/php.ini new file mode 100644 index 0000000..a0dfce0 --- /dev/null +++ b/php.ini @@ -0,0 +1,3 @@ +upload_max_filesize = 24M +post_max_size = 24M +max_file_uploads = 201 From 2d76302d8bd91dd8418c22237790e4f24d7e7213 Mon Sep 17 00:00:00 2001 From: xgaia Date: Fri, 28 Jan 2022 18:23:43 +0100 Subject: [PATCH 2/4] chore: config php.ini with env --- Dockerfile | 8 ++++++-- php.ini | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0435aee..7573bb4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,22 @@ FROM php:7.4-apache ENV SERVERNAME=localhost +ENV UPLOAD_MAX_FILESIZE=24M +ENV POST_MAX_SIZE=24M +ENV MAX_FILE_UPLOADS=201 RUN apt update && apt install -y gettext-base librsvg2-bin pdftk imagemagick potrace COPY . /usr/local/signaturepdf RUN chown -R www-data:www-data /usr/local/signaturepdf && chmod 750 -R /usr/local/signaturepdf && \ - cp /usr/local/signaturepdf/php.ini /usr/local/etc/php/conf.d/uploads.ini && \ - cat /usr/local/signaturepdf/apache.conf | envsubst > /etc/apache2/sites-available/signaturepdf.conf && \ + envsubst < /usr/local/signaturepdf/php.ini > /usr/local/etc/php/conf.d/uploads.ini && \ + envsubst < /usr/local/signaturepdf/apache.conf > /etc/apache2/sites-available/signaturepdf.conf && \ a2enmod rewrite && a2ensite signaturepdf WORKDIR /usr/local/signaturepdf CMD envsubst < /usr/local/signaturepdf/apache.conf > /etc/apache2/sites-available/signaturepdf.conf && \ + envsubst < /usr/local/signaturepdf/php.ini > /usr/local/etc/php/conf.d/uploads.ini && \ chown -R www-data:www-data /usr/local/signaturepdf && chmod 750 -R /usr/local/signaturepdf && \ apache2-foreground diff --git a/php.ini b/php.ini index a0dfce0..a2f71ab 100644 --- a/php.ini +++ b/php.ini @@ -1,3 +1,3 @@ -upload_max_filesize = 24M -post_max_size = 24M -max_file_uploads = 201 +upload_max_filesize = $UPLOAD_MAX_FILESIZE +post_max_size = $POST_MAX_SIZE +max_file_uploads = $MAX_FILE_UPLOADS From 3ec94a0ae3f820a12f31f713527e228244d145db Mon Sep 17 00:00:00 2001 From: xgaia Date: Fri, 28 Jan 2022 18:24:01 +0100 Subject: [PATCH 3/4] docs: update README --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index fcb0b03..36a997d 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Logiciel web libre permettant de signer un PDF. Liste des instances permettant d'utiliser ce logiciel : - [pdf.24eme.fr](https://pdf.24eme.fr) +- [pdf.libreon.fr](https://pdf.libreon.fr) ## License @@ -62,6 +63,37 @@ DocumentRoot /path/to/signaturepdf/public ``` +### Déployer avec docker + +#### Construction de l'image + +```bash +docker build -t signaturepdf . +```` + +#### Lancement d'un conteneur + +```bash +docker run -d --name=signaturepdf -p 8080:80 signaturepdf +```` + +[localhost:8080](localhost:8080) + +#### Configuration + +Les variables suivantes permettent de configurer le déployement : + +|Variable|description|exemple|defaut| +|-----|-----|-----|-----| +|`SERVERNAME`|url de déploiement|`pdf.24eme.fr`|localhost| +|`UPLOAD_MAX_FILESIZE`|Taille maximum du fichier PDF à signer|48|24M| +|`POST_MAX_SIZE`|Taille maximum du fichier PDF à signer|48|24M| +|`MAX_FILE_UPLOADS`|Nombre de pages maximum du PDF, ici 200 pages + le PDF d'origine|401|201| + +```bash +docker run -d --name=signaturepdf -p 8080:80 -e SERVERNAME=pdf.example.org -e UPLOAD_MAX_FILESIZE=48M -e POST_MAX_SIZE=48M -e MAX_FILE_UPLOADS=401 signaturepdf +```` + ## Tests Pour exécuter les tests fonctionnels : From 6af056f847907b6e779fd15185254134aa1fb2c9 Mon Sep 17 00:00:00 2001 From: xgaia Date: Sun, 30 Jan 2022 20:49:44 +0100 Subject: [PATCH 4/4] docs: fix README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 36a997d..1c87e26 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ docker build -t signaturepdf . docker run -d --name=signaturepdf -p 8080:80 signaturepdf ```` -[localhost:8080](localhost:8080) +[localhost:8080](http://localhost:8080) #### Configuration @@ -86,8 +86,8 @@ Les variables suivantes permettent de configurer le déployement : |Variable|description|exemple|defaut| |-----|-----|-----|-----| |`SERVERNAME`|url de déploiement|`pdf.24eme.fr`|localhost| -|`UPLOAD_MAX_FILESIZE`|Taille maximum du fichier PDF à signer|48|24M| -|`POST_MAX_SIZE`|Taille maximum du fichier PDF à signer|48|24M| +|`UPLOAD_MAX_FILESIZE`|Taille maximum du fichier PDF à signer|48M|24M| +|`POST_MAX_SIZE`|Taille maximum du fichier PDF à signer|48M|24M| |`MAX_FILE_UPLOADS`|Nombre de pages maximum du PDF, ici 200 pages + le PDF d'origine|401|201| ```bash