From 8dd29e5afd8fad8421abc218fd419768e89b3f06 Mon Sep 17 00:00:00 2001 From: spawnia Date: Sat, 14 Apr 2018 11:17:40 +0200 Subject: [PATCH] Enable pdf conversion as a oneshot command in docker --- Dockerfile | 15 +++++++++++---- README.md | 17 +++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index cfe769b..cbbcb31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,9 @@ RUN composer install --no-dev --optimize-autoloader --no-progress --no-suggest # Build the actual image FROM php +WORKDIR /resume +CMD ["/bin/bash"] + RUN apt-get update \ && apt-get install -qqy --no-install-recommends\ # This is for enabling the program to be run with watch @@ -16,11 +19,15 @@ RUN apt-get update \ xauth \ && rm -rf /var/lib/apt/lists/* +# Wrap pdf creation in a xvfb-run to enable headless pdf creation in the container +RUN printf '#!/bin/bash\nexec xvfb-run md2resume pdf "$@"' >> /usr/bin/md2pdf \ + && chmod +x /usr/bin/md2pdf + +# Enables continously calling a command and piping the output to STDOUT, viewable via docker logs +RUN printf '#!/bin/bash\nwhile sleep 1; do\n "$@"\ndone' >> /usr/bin/watch-docker \ + && chmod +x /usr/bin/watch-docker + COPY --from=composer /app/vendor /app/vendor COPY . /app RUN ln -s /app/bin/md2resume /usr/bin/md2resume - -RUN echo "alias md2pdf=\"xvfb-run md2resume pdf\"" >> ~/.bashrc - -WORKDIR /resume diff --git a/README.md b/README.md index b34836e..7bf46e2 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,21 @@ at the [blog post for the project][blog], or look in examples/output to see samp ### Docker -Run this in the directory where you put your markdown resume: +Run those commands in the directory where you put your markdown resume. -`docker run -it -v ${PWD}:/resume there4/markdown-resume bash` +The command for PDF creation works differently in a container, use `md2pdf` instead of the usual command. -In the docker console, you can run `md2resume` on your files. -For PDF conversion, run `md2pdf` instead of the usual command. +#### Oneshot command + +This is best suited for use in scripts or in CI environments: + +`docker run -v ${PWD}:/resume there4/markdown-resume md2resume [options] command [arguments]` + +#### Interactive console + +This allows you to enter an interactive console where you can easily experiment and run different commands: + +`docker run -it -v ${PWD}:/resume there4/markdown-resume` ### Local