diff --git a/Dockerfile b/Dockerfile index 2e9746e..f6e4a9d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,13 @@ RUN apk add --no-cache \ git \ mkdocs \ py3-pip \ + mkdocs-material \ py3-pathspec py3-markupsafe py3-platformdirs ## The last line is only needed because nginx:alpine uses an older version, which doesn't have this dependency ## See https://pkgs.alpinelinux.org/package/edge/community/x86_64/mkdocs vs https://pkgs.alpinelinux.org/package/v3.19/community/x86_64/mkdocs ENV MKDOCKER_REPOSITORY_URL github.com/g2forge/mkdocker +ENV MKDOCKER_REPOSITORY_LOGIN '' ENV MKDOCKER_REPOSITORY_BRANCH main ENV MKDOCKER_REPOSITORY_DIRECTORY example ENV MKDOCKER_LOCAL_DIRECTORY /mkdocker/docs diff --git a/README.md b/README.md index a93c9f2..05c86f4 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,18 @@ docker run -d --mount type=bind,source=${pwd},target=/mkdocker/docs --publish 12 ## Environment Variables * `MKDOCKER_REPOSITORY_URL` - The git repository to clone, without the protocol (default: `github.com/g2forge/mkdocker`) +* `MKDOCKER_REPOSITORY_LOGIN` - A login (`username:password` or `github_PAT`) for the repository (default: none) * `MKDOCKER_REPOSITORY_BRANCH` - The branch in the git repository to build (default: `main`) * `MKDOCKER_REPOSITORY_DIRECTORY` - The subdirectory in the git repository to run the build in (default: `example`) * `MKDOCKER_LOCAL_DIRECTORY` - The directory inside the docker container to clone the repository in to, or to just use if already mounted (default: `/mkdocker/docs`) * `MKDOCKER_VENV_DIRECTORY` - The directory inside the docker container to use for the python virtual environment (default: `/mkdocker/venv`). This is only necessary if a `requirements.txt` is present, and can optionally be mounted to a docker volume for persistence. * `MKDOCKER_SERVE` - A boolean flag to enable `mkdocs serve` if set to `1` (default: `0`) +## Requirements + +While the standard mkdocs and mkdocs-material packages are already installed, you can require other python packages by creating a `requirements.txt` in the repository directory. +If this file exists, a virtual environment will be created, and any packages will be installed in it. + ## Scripts mkdocker can run scripts both before and after the mkdocs build. diff --git a/mkdocker/scripts/mkdocker.sh b/mkdocker/scripts/mkdocker.sh index be6dd16..cba549c 100755 --- a/mkdocker/scripts/mkdocker.sh +++ b/mkdocker/scripts/mkdocker.sh @@ -8,7 +8,13 @@ if [ ! -d "${MKDOCKER_LOCAL_DIRECTORY}" ]; then if [ -d .git ]; then git pull else - git clone "https://${MKDOCKER_REPOSITORY_URL}" . + if [ $MKDOCKER_REPOSITORY_LOGIN ]; then + echo "Login specified" + git clone "https://${MKDOCKER_REPOSITORY_LOGIN}@${MKDOCKER_REPOSITORY_URL}" . + else + echo "Login not specified" + git clone "https://${MKDOCKER_REPOSITORY_URL}" . + fi; git checkout "${MKDOCKER_REPOSITORY_BRANCH}" fi else