Skip to content

Commit

Permalink
Merge pull request #7 from gdgib/G2-1620-Serve
Browse files Browse the repository at this point in the history
G2-1620 mkdocs serve mode
  • Loading branch information
gdgib authored Aug 13, 2024
2 parents f6168da + 915b88e commit 5290683
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ENV MKDOCKER_REPOSITORY_BRANCH main
ENV MKDOCKER_REPOSITORY_DIRECTORY example

Check warning on line 14 in Dockerfile

View workflow job for this annotation

GitHub Actions / build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV MKDOCKER_LOCAL_DIRECTORY /mkdocker/docs

Check warning on line 15 in Dockerfile

View workflow job for this annotation

GitHub Actions / build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV MKDOCKER_VENV_DIRECTORY /mkdocker/venv

Check warning on line 16 in Dockerfile

View workflow job for this annotation

GitHub Actions / build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV MKDOCKER_SERVE 0

Check warning on line 17 in Dockerfile

View workflow job for this annotation

GitHub Actions / build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

EXPOSE 80

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 15 additions & 11 deletions mkdocker/scripts/mkdocker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;"

0 comments on commit 5290683

Please sign in to comment.