diff --git a/stirling-pdf/files/nginx.conf.j2 b/stirling-pdf/files/nginx.conf.j2 new file mode 100644 index 0000000..b06469d --- /dev/null +++ b/stirling-pdf/files/nginx.conf.j2 @@ -0,0 +1,27 @@ +# The `upstream` directives ensure that you have a http/1.1 connection +# This enables the keepalive option and better performance +# +# Define the server IP and ports here. +upstream server { + server localhost:{{ host_port }}; +} + +server { + + listen 80; + server_name {{ http_host }}; + + # Allow large attachments + client_max_body_size 525M; + + location / { + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_pass http://server; + } + +} + diff --git a/stirling-pdf/playbook.yml b/stirling-pdf/playbook.yml new file mode 100755 index 0000000..44c51fc --- /dev/null +++ b/stirling-pdf/playbook.yml @@ -0,0 +1,12 @@ +################################################# +# Bitwarden Playbook +################################################# +--- +- hosts: gondor + become: true + vars_files: + - vars/default.yml + + roles: + - stirling + - nginx diff --git a/stirling-pdf/readme.md b/stirling-pdf/readme.md new file mode 100644 index 0000000..de3d1e4 --- /dev/null +++ b/stirling-pdf/readme.md @@ -0,0 +1,3 @@ +This is a robust, locally hosted web-based PDF manipulation tool using Docker. It enables you to carry out various operations on PDF files, including splitting, merging, converting, reorganizing, adding images, rotating, compressing, and more. This locally hosted web application has evolved to encompass a comprehensive set of features, addressing all your PDF requirements. + +https://github.com/Stirling-Tools/Stirling-PDF \ No newline at end of file diff --git a/stirling-pdf/roles/nginx/handlers/main.yaml b/stirling-pdf/roles/nginx/handlers/main.yaml new file mode 100644 index 0000000..622fd36 --- /dev/null +++ b/stirling-pdf/roles/nginx/handlers/main.yaml @@ -0,0 +1,6 @@ +--- +# Handlers for Nginx role +- name: Reload Nginx + service: + name: nginx + state: reloaded diff --git a/stirling-pdf/roles/nginx/tasks/main.yaml b/stirling-pdf/roles/nginx/tasks/main.yaml new file mode 100644 index 0000000..4441fe7 --- /dev/null +++ b/stirling-pdf/roles/nginx/tasks/main.yaml @@ -0,0 +1,24 @@ +--- +# Tasks for Nginx role +- name: Check if Nginx conf file exists + stat: + path: "/etc/nginx/sites-available/{{ http_conf }}" + register: status + +- name: No need to reload Nginx + debug: + msg: "No need to reload Nginx as sites-available entries have already been created" + +- name: Set Nginx conf file + when: status.stat.exists == false + template: + src: "files/nginx.conf.j2" + dest: "/etc/nginx/sites-available/{{ http_conf }}" + +- name: Enable new site + when: status.stat.exists == false + file: + src: "/etc/nginx/sites-available/{{ http_conf }}" + dest: "/etc/nginx/sites-enabled/{{ http_conf }}" + state: link + notify: Reload Nginx diff --git a/stirling-pdf/roles/stirling/tasks/main.yaml b/stirling-pdf/roles/stirling/tasks/main.yaml new file mode 100644 index 0000000..e892c75 --- /dev/null +++ b/stirling-pdf/roles/stirling/tasks/main.yaml @@ -0,0 +1,49 @@ +--- +# Tasks for Stirling-PDF role +- name: Pull Stirling-PDF image + docker_image: + name: "{{ image }}" + source: pull + force_source: yes + +- name: Ensure Stirling-PDF Directory exists + file: + path: "/var/lib/{{ host_directory }}" + state: directory + mode: 0755 + +- name: Ensure Directory for the tesseract ocr training data exists + file: + path: "/var/lib/{{ host_directory }}/training-data" + state: directory + mode: 0755 + +- name: Check if tesseract ocr training data exists + stat: + path: "/var/lib/{{ host_directory }}/training-data/eng.traineddata" + register: traineddata + +- name: Download eng.traineddata + get_url: + url: "https://github.com/tesseract-ocr/tessdata/raw/main/eng.traineddata" + dest: "/var/lib/{{ host_directory }}/training-data/eng.traineddata" + mode: '0644' + when: not traineddata.stat.exists + +- name: Create Stirling-PDF container + docker_container: + name: "{{ container }}" + image: "{{ image }}" + state: started + restart_policy: "unless-stopped" + env: + DOCKER_ENABLE_SECURITY: "false" + INSTALL_BOOK_AND_ADVANCED_HTML_OPS: "false" + LANGS: en_GB + published_ports: + - "127.0.0.1:{{ host_port }}:8080" + volumes: + - "/var/lib/{{ host_directory }}/training-data:/usr/share/tessdata" + - "/var/lib/{{ host_directory }}/extra-configs:/configs" + - "/var/lib/{{ host_directory }}/logs:/logs" + - "/var/lib/{{ host_directory }}/custom-files:/customFiles" \ No newline at end of file diff --git a/stirling-pdf/vars/default.yml b/stirling-pdf/vars/default.yml new file mode 100644 index 0000000..7abb650 --- /dev/null +++ b/stirling-pdf/vars/default.yml @@ -0,0 +1,9 @@ +--- +http_host: "pdf.tanshu.com" +http_conf: "pdf.tanshu.com.conf" + +container: stirling-pdf +image: frooodle/s-pdf:latest + +host_directory: stirling-pdf +host_port: 8002 \ No newline at end of file