Introduction

In this post, we demonstrate how to deploy Stirling PDF using Docker Compose and Traefik, and access it via a DNS entry like https://pdf.your-domain.org. This configuration enables a straightforward and secure deployment of your PDF processing application.
Introducing Traefik
Traefik is a powerful reverse proxy and load balancer that simplifies the management and deployment of microservices. With Traefik, you can automatically generate certificates for HTTPS and distribute the load across various backend services. For more details and a comprehensive tutorial, visit our Traefik tutorial.
Introducing Stirling PDF
Stirling PDF is a versatile PDF processing tool that allows you to convert, edit, and analyze PDF files. It offers features such as optical character recognition (OCR), merging or splitting PDFs, and converting PDFs to other formats. Stirling PDF is ideal for businesses seeking a powerful and flexible solution for PDF processing.
Introducing Docker and Docker Compose
Docker allows applications to run in isolated containers, significantly simplifying their deployment and scaling. Docker Compose is a tool that enables you to define and start multi-container applications. It helps manage complex application environments with just a few commands.
Docker Compose for Stirling PDF
Stirling PDF
The Stirling PDF service provides PDF processing and is made accessible through Traefik:
services:
stirling-pdf:
image: frooodle/s-pdf:latest
ports:
- '8080:8080'
volumes:
- /location/of/trainingData:/usr/share/tessdata # Required for additional OCR languages
- /location/of/extraConfigs:/configs
environment:
- DOCKER_ENABLE_SECURITY=false
- INSTALL_BOOK_AND_ADVANCED_HTML_OPS=false
- LANGS=en_GB
This section defines the Stirling PDF service, which listens on port 8080 and uses various directories for configuration files and OCR data. The environment variables configure additional security and feature options.
Traefik
The Traefik labels are crucial for correctly configuring the service and routing traffic accordingly:
labels:
- "traefik.enable=true"
- "traefik.http.routers.stirlingpdf.rule=Host(`pdf.your-domain.org`)" # Replace 'your-domain.org' with your actual domain
- "traefik.http.routers.stirlingpdf.entrypoints=websecure"
- "traefik.http.routers.stirlingpdf.tls.certresolver=lets-encrypt"
- "traefik.http.services.stirlingpdf.loadbalancer.server.port=8080"
- "traefik.docker.network=web"
traefik.enable=true: Activates Traefik for this service, allowing Traefik to monitor the service and forward requests.traefik.http.routers.stirlingpdf.rule=Host('pdf.your-domain.org'): Defines the URL mapping condition, specifying that requests topdf.your-domain.orgare forwarded to the Stirling PDF service.traefik.http.routers.stirlingpdf.entrypoints=websecure: Instructs Traefik to serve this service through thewebsecureentry point, used for HTTPS traffic.traefik.http.routers.stirlingpdf.tls.certresolver=lets-encrypt: Indicates that Traefik uses Let's Encrypt to secure HTTPS traffic.traefik.http.services.stirlingpdf.loadbalancer.server.port=8080: Specifies the internal port of the Stirling PDF service to which Traefik forwards traffic.traefik.docker.network=web: Specifies the Docker network used by Traefik to manage connections.
Network
The network settings define the network Traefik uses to connect services:
networks:
web:
external: true # Uses an external network managed by Traefik
This section defines the network used by Traefik to connect various services and manage connections.
Conclusion
With this guide, you can efficiently and securely deploy Stirling PDF with Traefik and Docker. The configuration is flexible and can be easily adapted to individual requirements. For further questions or professional support, check out our Discord channel. We are happy to assist you with the optimal setup and management of your applications.
Complete Docker Compose
Here is the complete docker-compose.yml file for the Stirling PDF installation:
version: '3.3'
services:
stirling-pdf:
image: frooodle/s-pdf:latest
ports:
- '8080:8080'
volumes:
- /location/of/trainingData:/usr/share/tessdata # Required for additional OCR languages
- /location/of/extraConfigs:/configs
environment:
- DOCKER_ENABLE_SECURITY=false
- INSTALL_BOOK_AND_ADVANCED_HTML_OPS=false
- LANGS=en_GB
labels:
- "traefik.enable=true"
- "traefik.http.routers.stirlingpdf.rule=Host(`pdf.your-domain.org`)" # Replace 'your-domain.org' with your actual domain
- "traefik.http.routers.stirlingpdf.entrypoints=websecure"
- "traefik.http.routers.stirlingpdf.tls.certresolver=lets-encrypt"
- "traefik.http.services.stirlingpdf.loadbalancer.server.port=8080"
- "traefik.docker.network=web"
networks:
- web
networks:
web:
external: true # Uses an external network managed by Traefik