diff --git a/Dockerfile b/Dockerfile index bdfffcf..2e9746e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,7 @@ ENV MKDOCKER_REPOSITORY_BRANCH main ENV MKDOCKER_REPOSITORY_DIRECTORY example ENV MKDOCKER_LOCAL_DIRECTORY /mkdocker/docs ENV MKDOCKER_VENV_DIRECTORY /mkdocker/venv +ENV MKDOCKER_SERVE 0 EXPOSE 80 diff --git a/README.md b/README.md index 2ab3d96..a93c9f2 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ docker run -d --mount type=bind,source=${pwd},target=/mkdocker/docs --publish 12 * `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`) ## Scripts diff --git a/mkdocker/scripts/mkdocker.sh b/mkdocker/scripts/mkdocker.sh index 090a7c2..be6dd16 100755 --- a/mkdocker/scripts/mkdocker.sh +++ b/mkdocker/scripts/mkdocker.sh @@ -36,15 +36,19 @@ if [ -x scripts/pre ]; then echo Running pre script ./scripts/pre fi -mkdocs build -d /usr/share/nginx/html -if [ -x scripts/post ]; then - echo Running post script - ./scripts/post -fi - -if [ -d "${MKDOCKER_VENV_DIRECTORY}" ]; then - echo "Deactivating virtual environment" - deactivate +if [ "${MKDOCKER_SERVE}" = 0 ]; then + mkdocs build -d /usr/share/nginx/html + if [ -x scripts/post ]; then + echo Running post script + ./scripts/post + fi + + if [ -d "${MKDOCKER_VENV_DIRECTORY}" ]; then + echo "Deactivating virtual environment" + deactivate + fi + + nginx -g "daemon off;" +else + mkdocs serve -a "0.0.0.0:80" fi - -nginx -g "daemon off;"