-
Notifications
You must be signed in to change notification settings - Fork 79
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
Export documentation site as a set of static pages. #53
Comments
Hey, let me add a +1 to this one. I'm trying to host the docs website with some sort of authentication, but I seem to run into problems with this whenever I enable it. Could be that I'm missing something here since this is well outside my comfort zone, but it feels related! |
Is there a recommended solution to this? I'm running into the same thing. The docs state you can host from s3 but I'm also getting
|
Since posting above I found a solution for GCP users that work quite well: Host the docs website with AppEngine and wrap it in Google Auth with Identity-Aware Proxy (IAP). This is relatively (but not quite) straightforward and does exactly what I wanted. |
@justinwagg sounds like you might just need to upload the |
Interesting @larsbkrogvig I will have look into it, thank you for the tip! @drewbanin my bucket looks like this
but I'm getting
when accessing |
huh! a 400?? That status code would be served up by S3 I think.... I'm super with you that this points to a permissions or configuration issue. The bucket I'm unsure if this is the right answer for your org, but more docs on s3 permissions can be found here: https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteAccessPermissionsReqd.html |
Yes, I agree and think this has more to do with GCS permissioning/setup than dbt. Once/if I figure it out I can follow up with step by step for future users who want to host privately for their org via gcs bucket. Thanks for the follow ups! |
To host the docs website with GCS without any authetication should work in the sense that I've been able to get it to work before. What I said above about AppEngine is for when you don't want the docs to be publicly available |
But this should work locally right? Because I get the same error, |
For local development you could use the python native server: |
And I just realized there is also a |
@justinwagg any chance you were able to find a solution? I am facing the same issue trying to host on an azure WebApp |
@larsbkrogvig do you mind sharing some insights on how you set it up? |
This is my service: default
runtime: python37
handlers:
- url: /
static_files: public/index.html
upload: public/index.html
- url: /
static_dir: public
- url: /.*
secure: always
redirect_http_response_code: 301
script: auto This is my deploy script: #!/bin/sh
dbt docs generate --project-dir my-dbt --target prod
cp my-dbt/target/catalog.json my-docs/public/
cp my-dbt/target/manifest.json my-docs/public/
cp my-dbt/target/run_results.json my-docs/public/
cp my-dbt/target/index.html my-docs/public/
gcloud app deploy my-docs --project my-project --quiet |
@larsbkrogvig Thanks a lot! runs perfectly. |
We were never able to get the static files working locally. I suspect this is a security feature of modern browsers (i.e. https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSRequestNotHttp) For local development, we instruct developers to use |
I did get it to deploy on github like here https://github.com/RMHogervorst/dbt_postgresql |
After exploring a bit, the issue with GCS has to do with the fact that when you load a page containing an authenticated link to a GCS bucket file, i.e. something like https://storage.cloud.google.com/REGION-BUCKET/PATH?authuser=0 you get redirected to a completely different URL. Again, no expert, but discussing this with google they told me that it is entirely impossible to make this work. Either you use a domain, or you go through App Engine or the solution they push the most now, Cloud Run. I know this doesn't help, but I never stopped hoping and now I can. |
I went down a bit of a rabbit hole researching this issue so am snapshotting some thoughts I had here. They're not very well structured, so apologies in advance if it's a bit of a brain dump. Main ideaThe contents of One way to accomplish this could be to add a static string placeholder to diff --git a/src/index.html b/src/index.html
index 23681ca..ec11238 100644
--- a/src/index.html
+++ b/src/index.html
@@ -26,3 +26,5 @@
<div ui-view></div>
+
+ <!-- PLACEHOLDER__DBT_DOCS_GENERATE_INLINED_RESOURCES -->
</body>
</html> and then if <script type="application/json" id="inlined-manifest"> ... (insert html-escaped contents of manifest.json here) </script>
<script type="application/json" id="inlined-catalog"> ... (insert html-escaped contents of catalog.json here) </script> Using an actual HTML parser for the injection would probably be more elegant, but also would be heavier and likely add otherwise-unnecessary dependencies. As long as the placeholder comment is sufficiently unique and care is taken to HTML-escape the contents of the artifacts, I don't see what else would go wrong. The only other change would be to this project's One challenge I foresee with this approach though is that it could be easy for an inlined One possible solution to that challenge could be adding a small header or footer to the docs site itself that includes the dbt version used to generate the site and the date and time when the site was generated, both of which would be sourced from manifest.json's E.g. |
What is the reason that the content of the file If you do this, you don't need a web server to see the documentation. There are significant benefits:
Python script to build a single page documentationTo solve this problem and host my documentation on Google Cloud Storage (GCS), I write this python script: import json
search_str = 'o=[i("manifest","manifest.json"+t),i("catalog","catalog.json"+t)]'
with open('target/index.html', 'r') as f:
content_index = f.read()
with open('target/manifest.json', 'r') as f:
json_manifest = json.loads(f.read())
with open('target/catalog.json', 'r') as f:
json_catalog = json.loads(f.read())
with open('target/index2.html', 'w') as f:
new_str = "o=[{label: 'manifest', data: "+json.dumps(json_manifest)+"},{label: 'catalog', data: "+json.dumps(json_catalog)+"}]"
new_content = content_index.replace(search_str, new_str)
f.write(new_content) Source: https://data-banana.github.io/dbt-generate-doc-in-one-static-html-file.html Now you can use |
@4sushi your solution is far from perfect but it saved my life ! |
@4sushi Thank you for your snippet, worked for me |
@4sushi thanks very much for your script, worked for me! |
@drewbanin any update on this? It looks like @4sushi's implementation works well - see comment above on 2022-01-12 What is needed to get this added to the product? That solution uses Python, so not entirely sure where it would fit in the actual docs generation process, but would love for this to get prioritized since it would make working with the docs MUCH easier! |
Well..... dbt is written in Python, so I guess the odds are fairly low. |
Any update on this one? |
This would simplify things for many use cases if we can. I'd like to propose a solution (and I'll likely put forward a PR) to do the following:
Why?
Any feedback on this proposal is appreciated. I will likely translate it into a PR in either case. |
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days. |
Still relevant and would still be helpful IMO. (Commenting to chase off Stalebot.) |
I think this is done and should be closed. @vergenzt - what is missing? |
Oooh I hadn't seen that feature! 😄 Never mind then! Yay! Resolved by dbt-labs/dbt-core#8615 it looks like 🙂 |
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days. |
Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers. |
@philippe-lavoie commented on Tue Nov 12 2019
Describe the feature
Shipping a zip of static HTML pages makes it easy to ship internal documentation to others. I'd use something like Gatsby to create the static pages. But to stick to a Python pipeline, something like Pelican could be used. I have never tried it though.
Describe alternatives you've considered
An alternative would be to generate a PDF file corresponding to the documentation, but would have to include the node graph and in practice, this might be a true alternative in the sense that it improves portability.
Additional context
I wanted to ship what I had to a client but I can't expose an internal site nor can easily create a locked-down public site for them. Shipping a site.zip would make this trivial.
Who will this benefit?
Anyone that wants to more easily share what's going on inside all those DBT models. Also, with a static site, you can add the documentation has a sub-folder of a larger site which makes exposing documentation even easier.
@philippe-lavoie commented on Tue Nov 12 2019
The documentation states that the site is static. However, when loading directly from the index.html page, I get
Perhaps, just the fix the fetch to use the above, but when it fails defaults to manifest.json instead ?
@drewbanin commented on Tue Nov 12 2019
hey @philippe-lavoie - the site is "static" in that you don't need to run a database or an application webserver to use it. The site does however load a few .json files that contain information about your project code and the state of the database.
You're seeing this problem because your web browser is disallowing the docs site to request other local files (eg.
file://Users/drew/my_project/target/manifest.json
). This is a security feature intended to prevent sites from reading arbitrary files on a user's hard drive.I think that if we were to do something here, it would be to embed the json data directly into the
index.html
file. That way, you wouldn't need to send along a .zip file with a bunch of html files inside of it - you'd just have a single index.html file that showed all of the docs.I'm going to transfer this issue over to the docs repo for further discussion. Let me know if you have any questions or thoughts!
The text was updated successfully, but these errors were encountered: