From e436420b96b309e73112f5d41558a6a327b67bd0 Mon Sep 17 00:00:00 2001 From: spawnia Date: Wed, 14 Mar 2018 21:51:38 +0100 Subject: [PATCH] feat: Add docker build This adds a Dockerfile which builds a Docker image with all required dependencies included. It helps to simplify installation and usage of the tool. --- Dockerfile | 26 ++++++++++++++++++ README.md | 74 ++++++++++++++++++++++++++++----------------------- composer.json | 5 ++++ 3 files changed, 71 insertions(+), 34 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cfe769b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +# Utilize multi-stage build to keep image size down +FROM composer as composer +COPY composer.* ./ +RUN composer install --no-dev --optimize-autoloader --no-progress --no-suggest + +# Build the actual image +FROM php + +RUN apt-get update \ + && apt-get install -qqy --no-install-recommends\ + # This is for enabling the program to be run with watch + procps \ + wkhtmltopdf \ + # Required to run PDF generation + xvfb \ + xauth \ + && rm -rf /var/lib/apt/lists/* + +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 cc07e38..0fd232c 100644 --- a/README.md +++ b/README.md @@ -14,38 +14,42 @@ at the [blog post for the project][blog], or look in examples/output to see samp * Single file deployment (no external stylesheets) * You can now version control and branch your resume. -## Install +## Installation + +### Docker + +Run this in the directory where you put your markdown resume: + +`docker run -it -v ${PWD}:/resume there4/markdown-resume bash` + +In the docker console, you can run `md2resume` on your files. +For PDF conversion, run `md2pdf` instead of the usual command. + +### Local + +1. Clone the repo `git clone git@github.com:there4/markdown-resume.git` or [Download ZIP](https://github.com/there4/markdown-resume/archive/master.zip) +2. **PHP 7** and **[composer](https://getcomposer.org/download/)** are installed and on your PATH +3. `composer install` inside of the project directory to install dependencies + +4. For generating PDF files, you need to install `wkhtmltopdf` + * OSX: `brew cask install wkhtmltopdf` via [Homebrew Cask](https://caskroom.github.io/) + * Debian: `sudo apt install php7.0-mbstring wkhtmltopdf` + * Fedora `sudo dnf install php-mbstring wkhtmltopdf` + +## Usage + +The two most important commands are the following two. Run them +inside the cloned directory -#### OSX -1. The simplest installation of the PDF to HTML conversion tool is via [Homebrew Cask](https://caskroom.github.io/) ```bash -brew cask install wkhtmltopdf -``` -2. Download as .zip (cloning has [an issue as of Dec 2017](https://github.com/there4/markdown-resume/issues/65)) and unzip. -3. [Install PHP 7](https://jason.pureconcepts.net/2016/09/upgrade-php-mac-os-x/) and be sure to update your PATH variable. -4. [Install 'composer'](https://getcomposer.org/download/), a per-project package installer to setup the rest of the requirements. You may need to run './composer.phar update' to get the correct versions of dependencies. -5. Now you should be ready to continue down in Quickstart. - -#### Debian -```bash -sudo apt install php7.0-mbstring wkhtmltopdf -``` - -#### Fedora -```bash -sudo dnf install php-mbstring wkhtmltopdf -``` - -## Quickstart - -``` - ./bin/md2resume html examples/source/sample.md examples/output/ - ./bin/md2resume pdf examples/source/sample.md examples/output/ +./bin/md2resume html examples/source/sample.md examples/output/ +./bin/md2resume pdf examples/source/sample.md examples/output/ ``` ## Help + ``` -Markdown Resume Generator version 2.2.1 by Craig Davis +Markdown Resume Generator version 2.3.0 by Craig Davis Usage: [options] command [arguments] @@ -69,25 +73,25 @@ Available commands: version Show current version information ``` + ## Examples Choose a template with the -t option. - - `./bin/md2resume html --template blockish examples/source/sample.md examples/output/` +``` +./bin/md2resume html --template blockish examples/source/sample.md examples/output/` +``` If you want to edit your markdown resume in your editor while watching it update in your browser, run this command: - - `watch ./bin/md2resume html --refresh yes --template modern examples/source/sample.md examples/output/` +``` +watch ./bin/md2resume html --refresh yes --template modern examples/source/sample.md examples/output/ +``` This makes the build script run periodically, and html document will refresh every two seconds via a meta tag. Open the `./examples/ouput/sample.html` file in your browser, and then just save your markdown document when you want to see a fresh preview. -For information about running this inside a Docker container, please read [Issue 46](https://github.com/there4/markdown-resume/issues/46#issuecomment-126520792) -where [Sebastian Klose](https://github.com/sklose) has shared his approach. - ## Authoring Your Resume Markdown is limited to basic html markup. Follow the `examples/source/sample.md` @@ -98,6 +102,7 @@ we have very few ways to nest or identify elements that many of the css rules are based on descendant and adjacent selectors. ## Feature Development + In order to add new commands, you'll need to first install the dependencies: * `composer install` @@ -106,7 +111,7 @@ After that, you can run the `md2resume_dev.php` file from the command line. ## Building a Release -1. Tag the repo with the new build number. +1. Tag the repo with the new build number. 2. Run `composer build`. 3. Push both the tag and the code. @@ -119,6 +124,7 @@ are a more comfortable with html than markdown, you should use it. ## Changelog +* __2.3.0__ : Add docker support to ease the installation process [@spawnia](https://github.com/spawnia) * __2.2.0__ : Dropped phar file distribution, removed Pake and migrated to composer commands * __2.1.0__ : Dropped PHP5 support * __2.0.12__ : Added new `Roboto` template from [@ejwaibel](https://github.com/ejwaibel) diff --git a/composer.json b/composer.json index 258205a..b722222 100644 --- a/composer.json +++ b/composer.json @@ -36,6 +36,11 @@ "name": "Erik Waibel", "email": "ejwaibel@gmail.com", "role": "Contributor" + }, + { + "name": "Benedikt Franke", + "email": "benedikt@franke.tech", + "role": "Contributor" } ], "support": {