Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

G2-1621 Support private repositories #8

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
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/
ENV MKDOCKER_VENV_DIRECTORY /mkdocker/venv

Check warning on line 18 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 19 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 All @@ -22,4 +24,4 @@
COPY mkdocker /mkdocker/
RUN dos2unix /mkdocker/scripts/mkdocker.sh && chmod +x /mkdocker/scripts/mkdocker.sh

CMD /mkdocker/scripts/mkdocker.sh

Check warning on line 27 in Dockerfile

View workflow job for this annotation

GitHub Actions / build

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
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