facteurpat
facteurpat

Reputation: 61

How to install plugins in mkdocs-material docker image

Hello Stackoverflow community,

I use mkdocs with continous integration (drone-ci) to build and deploy documentation.

I use the docker image mkdocs-material from squidfunk, but I need some plugins on top of it.

I tried to build my custom image with this maybe naive Dockerfile:

FROM squidfunk/mkdocs-material

RUN pip install --no-cache-dir \
  mkdocs-awesome-pages-plugin \
  mkdocs-minify-plugin \
  mkdocs-git-revision-date-localized-plugin \
  mkdocs-bibtex \
  mkdocs-img2fig-plugin \
  mkdocs-mermaid2-plugin

ENTRYPOINT ["mkdocs"]

However during the build process in continous integration I get the error:

ERROR   -  Config value: 'plugins'. Error: The "bibtex" plugin is not installed 

Aborted with 1 Configuration Errors!

which seems to indicate mkdocs in docker cannot find the mkdocs-bibtex package.

Does anyone know how to properly install additional mkdocs plugins on top of squidfunk's docker image?

PS: I get no error when I build mkdocs doc manually outside docker.

Upvotes: 4

Views: 4121

Answers (2)

JRC
JRC

Reputation: 61

I solved it this way as getting a CI build of a custom image into a repo is a bit of a pain at my workplace. I did this to install the mkdocs-drawio plugin.

In your documentation directory (same as your mkdocs.yml), create a new file with executable permissions called entrypoint.sh (or anything you like)

#!/bin/sh
/usr/local/bin/pip install mkdocs-drawio
/sbin/tini -s /usr/local/bin/python -- /usr/local/bin/mkdocs serve --dev-addr=0.0.0.0:8000

Then, when you start your docker containe, mount the volume like you normally would and override the default entrypoint with the script you created, like so

docker run  ...
...
-v $(pwd):/docs \
--entrypoint "/docs/entrypoint.sh" \
squidfunk/mkdocs-material:latest

Upvotes: 0

facteurpat
facteurpat

Reputation: 61

My dockerfile is correct. The problem was due to the fact I was pulling a wrong docker image in my continous integration pipeline.

Upvotes: 2

Related Questions