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 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`: