From a2ff1f5647b82bb1fcf2be70b083566d35f7bf99 Mon Sep 17 00:00:00 2001 From: Rune Juhl Jacobsen Date: Wed, 18 Nov 2020 04:17:51 +0100 Subject: [PATCH] Add Dockerfile and Makefile for easily building docs (#614) This is useful to have - thank you for contributing. @amarts perhaps we can make more folks aware that this is now available. If any changes/fixes are required we can track against this initial contribution. --- .gitignore | 1 + Dockerfile | 9 +++++++++ Makefile | 5 +++++ README.md | 17 ++++++++++++++++- 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 1dc6e3b..7a116d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ site/ env/ .env +/.buildlog diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..301e76e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM centos:7 + +# RUN yum install -y epel-release +RUN yum install -y python3 python3-setuptools +RUN pip3 install mkdocs mkdocs-material + +ENV LC_ALL=en_US.utf-8 LANG=en_US.utf-8 + +ENTRYPOINT ["mkdocs", "build"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f350152 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +build: docker/build + @docker run --rm -ti --user $(shell id -u):$(shell id -g) -v $(PWD):/docs:ro -v $(PWD)/site:/docs/site:rw -w /docs $(shell grep "Successfully built" .buildlog | cut -d ' ' -f 3) + +docker/build: + @docker build . | tee .buildlog diff --git a/README.md b/README.md index cdc7aff..e90ced4 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ If you are on EPEL 7 or Fedora, the first thing you will need is to install mkdocs, with the following command : # sudo yum install mkdocs - + For Fedora 30+ (run the following in root) # dnf install python-pip @@ -37,3 +37,18 @@ Then you need to run mkdocs The result will be in the `site/` subdirectory, in HTML. +# Building the docs in Docker + +Included is a Makefile and a Dockerfile, which enables you to easily build the +docs inside Docker without installing any dependencies on your system. + +Simply run the following command to compile the docs: + +```sh +make +``` + +This Makefile recipe builds a Docker image containing the dependencies required +and runs `mkdocs` inside the built image, taking care to run the container as +the current `uid` and `gid` so that your user has ownership of the results in +the `./site` directory.