Check out my latest project PullPreview - Deployment previews for your pull requests, on servers you control

The return of the Makefile

Makefiles are underrated. I find myself putting more of them in projects I touch, to encapsulate useful commands such as docker builds, pushes, deploys, or development-related tasks.

This is how this whole blog is generated from markdown files, in about half a second:

INFILES = $(shell find . -name "*.md")

all: $(OUTFILES)

%.html: css/style.css
        m4 -PEIinc > $@
        bin/mark -i $< >> $@
        cat >> $@
        sed -i ':begin;$!N;s/\(<code.*>\)\n/\1/;tbegin;P;D' $@
        sed -i 's|<body>|<body class="$(shell dirname $@)">|' $@

        rm -f $(OUTFILES)

preview: all
        docker build -t ouestcode .
        docker run -it -p 5678:80 -v $(shell pwd):/usr/share/nginx/html codelicacy

        optipng img/**/*.png

PHONY: all clean