diff --git a/.gitignore b/.gitignore index 07d3b82..ae6db6f 100644 --- a/.gitignore +++ b/.gitignore @@ -114,4 +114,3 @@ dj_local_conf_old.json **/*~ **/#*# **/.#* -docker-compose.y*ml diff --git a/docs/docker-compose.yaml b/docs/docker-compose.yaml new file mode 100644 index 0000000..a8d84bf --- /dev/null +++ b/docs/docker-compose.yaml @@ -0,0 +1,51 @@ +# MODE="LIVE|QA|PUSH" PACKAGE=element_interface UPSTREAM_REPO=https://github.com/datajoint/element-interface.git HOST_UID=$(id -u) docker compose -f docs/docker-compose.yaml up --build +# +# navigate to http://localhost/ +version: "2.4" +services: + docs: + build: + dockerfile: docs/.docker/Dockerfile + context: ../ + args: + - PACKAGE + image: ${PACKAGE}-docs + environment: + - PACKAGE + - UPSTREAM_REPO + - MODE + - GOOGLE_ANALYTICS_KEY + - PATCH_VERSION + volumes: + - ../docs:/main/docs + - ../${PACKAGE}:/main/${PACKAGE} + user: ${HOST_UID}:anaconda + ports: + - 80:80 + command: + - sh + - -c + - | + git config --global --add safe.directory /main + set -e + export PATCH_VERSION=$$(cat /main/$${PACKAGE}/version.py | grep -oE '\d+\.\d+\.[a-z0-9]+') + if echo "$${MODE}" | grep -i live &>/dev/null; then + mkdocs serve --config-file ./docs/mkdocs.yaml -a 0.0.0.0:80 + elif echo "$${MODE}" | grep -iE "qa|push" &>/dev/null; then + echo "INFO::Delete gh-pages branch" + git branch -D gh-pages || true + echo "INFO::Fetch upstream gh-pages" + git fetch $${UPSTREAM_REPO} gh-pages:gh-pages && git switch gh-pages || git switch --orphan gh-pages && git commit --allow-empty -m "init commit" + echo "INFO::mike" + mike deploy --config-file ./docs/mkdocs.yaml -u $$(grep -oE '\d+\.\d+' /main/$${PACKAGE}/version.py) latest + mike set-default --config-file ./docs/mkdocs.yaml latest + if echo "$${MODE}" | grep -i qa &>/dev/null; then + mike serve --config-file ./docs/mkdocs.yaml -a 0.0.0.0:80 + elif echo "$${MODE}" | grep -i push &>/dev/null; then + echo "INFO::Push gh-pages to upstream" + git push $${UPSTREAM_REPO} gh-pages + fi + else + echo "Unexpected mode..." + exit 1 + fi \ No newline at end of file