Giter Site home page Giter Site logo

Comments (11)

aforsythe avatar aforsythe commented on May 20, 2024 1

Thanks so much for the help. I did find a work around. I moved the Dockerfile and mkdocs.yml up to the root of the git repo. Then I attached the docker volume to the git repo root also, but changed the mkdocs.yml to reflect the new docs_dir structure and the location of the theme with custom_dir. Hoping there's no unintended side effects but all seems to be working now.

from mkdocs-git-revision-date-localized-plugin.

timvink avatar timvink commented on May 20, 2024

Going to need a bit more info.

You cloned a repo, cd-ed into it, and running mkdocs serve gives you this error?

What OS are you on? Which version of python? Running the latest mkdocs package and of this package?

from mkdocs-git-revision-date-localized-plugin.

timvink avatar timvink commented on May 20, 2024

Also, is there a larger traceback you can paste ?

from mkdocs-git-revision-date-localized-plugin.

aforsythe avatar aforsythe commented on May 20, 2024

Thanks ...

Here's the full traceback

Traceback (most recent call last):
  File "/usr/local/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/__main__.py", line 177, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 54, in serve
    config = builder()
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 49, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/build.py", line 257, in build
    config = config['plugins'].run_event('config', config)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/plugins.py", line 102, in run_event
    result = method(item, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs_git_revision_date_localized_plugin/plugin.py", line 65, in on_config
    self.last_site_revision_timestamp = self.util.get_git_commit_timestamp(
  File "/usr/local/lib/python3.9/site-packages/mkdocs_git_revision_date_localized_plugin/util.py", line 135, in get_git_commit_timestamp
    raise err
  File "/usr/local/lib/python3.9/site-packages/mkdocs_git_revision_date_localized_plugin/util.py", line 106, in get_git_commit_timestamp
    git = self._get_repo(realpath)
  File "/usr/local/lib/python3.9/site-packages/mkdocs_git_revision_date_localized_plugin/util.py", line 40, in _get_repo
    self.repo_cache[path] = Repo(path, search_parent_directories=True).git
  File "/usr/local/lib/python3.9/site-packages/git/repo/base.py", line 224, in __init__
    self.working_dir: Optional[PathLike] = self._working_tree_dir or self.common_dir
  File "/usr/local/lib/python3.9/site-packages/git/repo/base.py", line 307, in common_dir
    raise InvalidGitRepositoryError()
git.exc.InvalidGitRepositoryError

Running mkdocs-material using the squidfunk/mkdocs-material docker image.
Using plugins so running with the following Dockerfile

FROM squidfunk/mkdocs-material

WORKDIR /tmp
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
WORKDIR /docs

requirements.txt is

mkdocs-material
mkdocs-enumerate-headings-plugin
mkdocs-git-revision-date-localized-plugin
mkdocs-mermaid2-plugin
mkdocs-techdocs-core

I think I might know what's going on here but don't know how to address ... The directory in which I'm currently docker run --rm -it -p 8000:8000 -v ${PWD}:/docs myImage isn't the root of the git repository, so it looks like inside the container there's no knowledge of the .git hidden folder which exists one level up.

from mkdocs-git-revision-date-localized-plugin.

oliversalzburg avatar oliversalzburg commented on May 20, 2024

@aforsythe If the .git directory is not mounted into the container, that's likely a problem. Why not mount the parent folder (likely your entire repo) into /docs instead? That is what we do anyway.

from mkdocs-git-revision-date-localized-plugin.

timvink avatar timvink commented on May 20, 2024

Indeed that seems to be the problem. The official mkdocs-material docker image states:

Mount the folder where your mkdocs.yml resides as a volume into /docs:
Start development server on http://localhost:8000
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material

Is mkdocs.yml in the root of your repository, same as where your .git folder is? Alternatively, is there a .dockerignore file in your project that ignores the .git folder?

from mkdocs-git-revision-date-localized-plugin.

aforsythe avatar aforsythe commented on May 20, 2024

No .dockerignore ...

The Dockerfile and the mkdocs.yml are in the subdirectory of the repo. That's what is getting mounted as a docker volume, so the container isn't seeing the .git directory that's one level up. I tried moving the Dockerfile up, mounting the top level directory, but then mkdocs doesn't build with the squidfunk/mkdocs-material docker image because it assumes the mkdocs.yml is in the directory that gets mounted to /docs in the container.

Sorry this obviously isn't an issue with your plugin, but if you've got thoughts on how to manage the issue in an elegant fashion, I'd love your input. I can brute force it by copying the contents of the mkdocs-material Dockerfile into my Dockerfile and modifying the working directory, but I'm hoping there's a more elegant solution.

from mkdocs-git-revision-date-localized-plugin.

oliversalzburg avatar oliversalzburg commented on May 20, 2024

@aforsythe Not sure if this can help, but I came across https://github.com/backstage/mkdocs-monorepo-plugin while looking through https://github.com/mkdocs/mkdocs/wiki/MkDocs-Plugins. Maybe this, or another similar plugin, can support your use case as well.

from mkdocs-git-revision-date-localized-plugin.

timvink avatar timvink commented on May 20, 2024

@squidfunk any possibility we can improve the mkdocs-material docker image for better compatibility / easier setup with plugins that use git ? Reading the thread above it seems we might be able to make things easier :)

from mkdocs-git-revision-date-localized-plugin.

aforsythe avatar aforsythe commented on May 20, 2024

Certainly any way to make it a little clearer how to deal with this sort of situation, would be appreciated. I'm coming to mkdocs and mkdocs-material pretty green, so there's some stuff that was pretty obvious that I just messed up along the way. This felt like it required a bit of digging to get right.

from mkdocs-git-revision-date-localized-plugin.

squidfunk avatar squidfunk commented on May 20, 2024

@timvink the getting started guide assumes that mkdocs.yml and the .git folder are on the same level, yes. If you deviate from that path, i.e. mount a subfolder, YMMV. I don't want to make the getting started guide any more complicated, but we can certainly add a note to the setup page of your plugin. If you feel that this is a good idea, a PR is appreciated.

from mkdocs-git-revision-date-localized-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.