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

dev container is unable to build docs in bind mounted directory #4164

Closed
gsnider2195 opened this issue Jul 25, 2023 · 4 comments
Closed

dev container is unable to build docs in bind mounted directory #4164

gsnider2195 opened this issue Jul 25, 2023 · 4 comments
Assignees
Labels
type: housekeeping Changes to the application which do not directly impact the end user

Comments

@gsnider2195
Copy link
Contributor

Environment

  • Nautobot version (Docker tag too if applicable): 2.0.0b2
  • Python version: 3.10.12 (3.8.17 in container)
  • Database platform, version: N/A
  • Middleware(s):

Steps to Reproduce

  1. Build docker container with latest version of next (after Fix nodejs dev container for real #4130)
  2. Try to run inv build-and-check-docs

Expected Behavior

Docs are built

Observed Behavior

Permission denied. mkdocs tries to build the docs in $PWD/project-static/docs which is owned by the user on the host system (uid 1000 for me) but is running as uid 999 in the container

My quick workaround was to run build_nautobot_docs and build_example_plugin_docs as the current user:

diff --git a/tasks.py b/tasks.py
index 9dc59ee2d..e60fb0eaa 100644
--- a/tasks.py
+++ b/tasks.py
@@ -536,7 +536,11 @@ def build_and_check_docs(context):
 def build_nautobot_docs(context):
     "Build Nautobot docs."
     command = "mkdocs build --no-directory-urls --strict"
-    run_command(context, command)
+    if is_truthy(context.nautobot.local):
+        run_command(context, command)
+    else:
+        docker_command = f"run --user {os.getuid()}:{os.getgid()} --entrypoint '{command}' nautobot"
+        docker_compose(context, docker_command, pty=True)
 
 
 def build_example_plugin_docs(context):
@@ -547,7 +551,7 @@ def build_example_plugin_docs(context):
         print_command(local_command)
         context.run(local_command, pty=True)
     else:
-        docker_command = f"run --workdir='/source/examples/example_plugin' --entrypoint '{command}' nautobot"
+        docker_command = f"run --user {os.getuid()}:{os.getgid()} --workdir='/source/examples/example_plugin' --entrypoint '{command}' nautobot"
         docker_compose(context, docker_command, pty=True)

I'm still getting permission denied when unittest tries to create .coverage so we may need to run unittest as the local user also.

@bryanculver bryanculver added the type: housekeeping Changes to the application which do not directly impact the end user label Jul 31, 2023
@gsnider2195
Copy link
Contributor Author

My preferred alternate option is to continue to run as root in the dev stage. Thoughts @glennmatthews?

@glennmatthews
Copy link
Contributor

I'm not necessarily opposed to that option. I was kinda worried that we might hit issues like this with #4130 given the difference in how Docker Desktop works on Mac versus other platforms. Whatever the cleanest/quickest way to fix this turns out to be is fine with me.

@gsnider2195
Copy link
Contributor Author

I'd like to propose that we stick with root in the dev stage for now. Even with the workaround proposed above, after switching to the develop branch, the docs get created by root so when switching back to next I have to rm -rf examples/example_plugin/example_plugin/static/example_plugin/docs and rm -rf nautobot/project-static/docs to get back to a working state.

@gsnider2195
Copy link
Contributor Author

Resolved by #4213

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: housekeeping Changes to the application which do not directly impact the end user
Projects
No open projects
Archived in project
Development

No branches or pull requests

3 participants