From 703fd709207f7ff3db27aea0753cf0e974fc46a5 Mon Sep 17 00:00:00 2001 From: Manuel Vogel <8409778+mavogel@users.noreply.github.com> Date: Wed, 26 Feb 2025 08:50:41 +0100 Subject: [PATCH 1/2] feat: add docker setup Signed-off-by: Manuel Vogel <8409778+mavogel@users.noreply.github.com> --- .dockerignore | 2 ++ Dockerfile | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..cfd32ab --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.github +README.md \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..241b0f1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM ubuntu:latest + +USER root +RUN apt-get update && apt -y install \ + ghostscript \ + librsvg2-bin \ + texlive-latex-recommended \ + texlive-latex-extra \ + pandoc + +USER nobody +COPY --chown=nobody:nobody shrinkpdf.sh /usr/local/bin/shrinkpdf.sh \ No newline at end of file From 267bf9109075c3d088caa1bf14ea20393c3ea616 Mon Sep 17 00:00:00 2001 From: Manuel Vogel <8409778+mavogel@users.noreply.github.com> Date: Wed, 26 Feb 2025 08:50:57 +0100 Subject: [PATCH 2/2] chore(docs): update docker usage Signed-off-by: Manuel Vogel <8409778+mavogel@users.noreply.github.com> --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index d7742ea..473f79b 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,18 @@ Download the script and make it executable: chmod +x shrinkpdf.sh ``` +or you run it within a Docker container +```sh +# check out the repo +git clone git@github.com:aklomp/shrinkpdf.git && cd shrinkpdf +# build it first +docker build -t shrinkpdf:local . +# run it by mounting the current directory +docker run -it -v $(pwd):/build -w /build shrinkpdf:local bash +# as the script is stored in /usr/local/bin +shrinkpdf.sh in.pdf > out.pdf +``` + If you run it with no arguments, it prints a usage summary. If you run it with a single argument -- the name of the pdf to shrink -- it writes the result to `stdout`: