Skip to content

Commit

Permalink
G2-1621 Support private repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
gdgib committed Aug 13, 2024
1 parent 5290683 commit a5a1e87
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 13 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_REPOSITORY_LOGIN ''

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_REPOSITORY_BRANCH main

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_REPOSITORY_DIRECTORY example

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_LOCAL_DIRECTORY /mkdocker/docs

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/
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 7 additions & 1 deletion mkdocker/scripts/mkdocker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a5a1e87

Please sign in to comment.