Skip to content

Instantly share code, notes, and snippets.

@ManotLuijiu
Last active June 29, 2024 16:04
Show Gist options
  • Save ManotLuijiu/ea33a9ceb411d7cc758fd55e6ae96e3c to your computer and use it in GitHub Desktop.
Save ManotLuijiu/ea33a9ceb411d7cc758fd55e6ae96e3c to your computer and use it in GitHub Desktop.
How to install Stirling PDF on Docker using docker-compose
version: '3.3'
services:
stirling-pdf:
image: frooodle/s-pdf:latest
ports:
- '8080:8080'
volumes:
- ./trainingData:/usr/share/tessdata #Required for extra OCR languages
- ./extraConfigs:/configs
- ./customFiles:/customFiles/
- ./logs:/logs/
environment:
- DOCKER_ENABLE_SECURITY=true
- SECURITY_ENABLELOGIN=true
- SECURITY_INITIALLOGIN_USERNAME=admin
- SECURITY_INITIALLOGIN_PASSWORD=yourpassword
- INSTALL_BOOK_AND_ADVANCED_HTML_OPS=false
- LANGS=th_TH
- UI_APP_NAME=Put any name here
- UI_HOME_DESCRIPTION=Your locally hosted one-stop-shop for all your PDF needs.
- UI_APP_NAVBAR_NAME=Stirling PDF
restart: always
server {
# replace example.com with your domain name
# Don't forget to add domain name
# and your server's IP in DNS Server like AWS/Route53
server_name example.com;
listen 80;
listen [::]:80;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location = /live/websocket {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
}
@ManotLuijiu
Copy link
Author

ManotLuijiu commented Jun 29, 2024

How to install Stirling PDF on Docker using docker-compose

Install Docker engine and docker-compose

Docker engine and docker compose plugin

Step 1

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

Step 2

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Step 3

sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker

Step 4

sudo systemctl enable docker.service
sudo systemctl enable containerd.service

docker-compose standalone

curl -SL https://github.com/docker/compose/releases/download/v2.28.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

Install Nginx and Certbot

sudo apt-get install -y nginx
sudo apt-get install -y certbot python3-certbot-nginx

Install Thai OCR packages

sudo apt-get install -y 'tesseract-ocr-tha'

Create Folder for docker-compose.yml file

mkdir stirling-pdf && cd $_

Create File docker-compose.yml

# stirling-pdf/docker-compose.yml
sudo nano docker-compose.yml

copy code that shown in docker-compose.yml and paste

run application

docker-compose up -d

@ManotLuijiu
Copy link
Author

ManotLuijiu commented Jun 29, 2024

How to enable SSL (HTTPS) for Stirling PDF

Go to /etc/nginx/sites-available/ or using this command

sudo nano /etc/nginx/sites-available/stirlingpdf

Copy code from stirlingpdf as shown above and paste to it.

Sync sites-available/stirlingpdf to sites-enabled/stirlingpdf using this command

sudo ln -s /etc/nginx/sites-available/stirlingpdf /etc/nginx/sites-enabled/

Run Certbot

sudo certbot --nginx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment