Skip to content

Commit

Permalink
Merge pull request #23 from chatons-libreon/master
Browse files Browse the repository at this point in the history
Dockerize signaturepdf
  • Loading branch information
wincelau authored Feb 2, 2022
2 parents 2f834f6 + 6af056f commit 97e994a
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +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 && \
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
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -62,6 +63,37 @@ DocumentRoot /path/to/signaturepdf/public
</Directory>
```

### 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](http://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|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
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 :
Expand Down
22 changes: 22 additions & 0 deletions apache.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<VirtualHost *:80>
ServerName ${SERVERNAME}
DocumentRoot /usr/local/signaturepdf/public
DirectoryIndex index.php

AddDefaultCharset UTF-8

<Directory /usr/local/signaturepdf/public>
AllowOverride All
<IfVersion >= 2.3>
Require all granted
</IfVersion>
<IfVersion < 2.3>
Order Deny,Allow
Allow from all
</IfVersion>
</Directory>

LogLevel warn
ErrorLog /var/log/apache2/ssp_error.log
CustomLog /var/log/apache2/ssp_access.log combined
</VirtualHost>
3 changes: 3 additions & 0 deletions php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
upload_max_filesize = $UPLOAD_MAX_FILESIZE
post_max_size = $POST_MAX_SIZE
max_file_uploads = $MAX_FILE_UPLOADS

0 comments on commit 97e994a

Please sign in to comment.