Enable pdf conversion as a oneshot command in docker

This commit is contained in:
spawnia 2018-04-14 11:17:40 +02:00
parent 61524c1702
commit 8dd29e5afd
2 changed files with 24 additions and 8 deletions

View File

@ -6,6 +6,9 @@ RUN composer install --no-dev --optimize-autoloader --no-progress --no-suggest
# Build the actual image # Build the actual image
FROM php FROM php
WORKDIR /resume
CMD ["/bin/bash"]
RUN apt-get update \ RUN apt-get update \
&& apt-get install -qqy --no-install-recommends\ && apt-get install -qqy --no-install-recommends\
# This is for enabling the program to be run with watch # This is for enabling the program to be run with watch
@ -16,11 +19,15 @@ RUN apt-get update \
xauth \ xauth \
&& rm -rf /var/lib/apt/lists/* && 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 --from=composer /app/vendor /app/vendor
COPY . /app COPY . /app
RUN ln -s /app/bin/md2resume /usr/bin/md2resume RUN ln -s /app/bin/md2resume /usr/bin/md2resume
RUN echo "alias md2pdf=\"xvfb-run md2resume pdf\"" >> ~/.bashrc
WORKDIR /resume

View File

@ -19,12 +19,21 @@ at the [blog post for the project][blog], or look in examples/output to see samp
### Docker ### 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. #### Oneshot command
For PDF conversion, run `md2pdf` instead of the usual 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 ### Local