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

Improvements to documentation around getting Developer Docs running locally #4875

Merged
merged 2 commits into from
Feb 5, 2025

Conversation

ChrisBAshton
Copy link
Contributor

@ChrisBAshton ChrisBAshton commented Nov 7, 2024

We were having trouble getting this working locally, which wasn't helped by sporadic docs and swallowed errors. See commits.

@ChrisBAshton ChrisBAshton force-pushed the local-dev-doc-improvements branch from 1e85524 to 33956a0 Compare February 3, 2025 09:24
@ChrisBAshton ChrisBAshton marked this pull request as ready for review February 3, 2025 09:24
We can give a hint to the user as to how to fix the following
issue:

```
== Request: /document-types/landing_page.html
       error  build/document-types/landing_page.html
undefined method `include?' for nil
/govuk/govuk-developer-docs/app/document_types.rb:83:in `block in shift_low_value_schemas'
/govuk/govuk-developer-docs/app/document_types.rb:82:in `each'
/govuk/govuk-developer-docs/app/document_types.rb:82:in `shift_low_value_schemas'
/govuk/govuk-developer-docs/app/document_types.rb:74:in `schemas'
/govuk/govuk-developer-docs/source/templates/document_type_template.html.md.erb:28:in `__tilt_29200'
/root/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/tilt-2.0.11/lib/tilt/template.rb:181:in `call'
/root/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/tilt-2.0.11/lib/tilt/template.rb:181:in `evaluate'
/root/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/tilt-2.0.11/lib/tilt/template.rb:109:in `render'
```
@ChrisBAshton ChrisBAshton force-pushed the local-dev-doc-improvements branch from 33956a0 to 05dd126 Compare February 3, 2025 09:27
Copy link
Contributor

@minhngocd minhngocd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried out the instructions:

  • local run without docker works without the Github token being in place by using SKIP_PROXY_PAGES as suggested
  • docker run still failed with rate limiting when i set the env var in docker-compose.yml to SKIP_PROXY_PAGES true. Does the docker version only work if the Github token is set?

Copy link
Contributor

@minhngocd minhngocd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it out a little bit more.
Unfortunately never got docker to work...
Small typo and docker-compose file suggestion, otherwise the rest might be a problem with my machine.

README.md Outdated Show resolved Hide resolved
1. Install the dependencies (`govuk-docker-run bundle install`)
1. Run the application (`govuk-docker-up`)
1. Wait until all the GitHub API calls have completed (you'll see `Inspect your site configuration at` in the output). This can take a few minutes.
1. Visit <http://govuk-developer-docs.dev.gov.uk/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SKIP_PROXY_PAGES option for docker seems to be throwing an error, curious if it worked for you? I wasn't able to look into it, but might worth noting that it doesn't support that at the moment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, after getting past the rate limiting, I'm also hitting the same error as if i just passed through SKIP PROXY PAGES which is :

govuk-developer-docs-app-1  | bundler: failed to load command: middleman (/root/.rbenv/versions/3.3.1/bin/middleman)
govuk-developer-docs-app-1  | /root/.rbenv/versions/3.3.1/lib/ruby/3.3.0/prettyprint.rb:184:in `text': can't convert Middleman::CoreExtensions::Collections::LazyCollectorStep to String (Middleman::CoreExtensions::Collections::LazyCollectorStep#to_str gives Middleman::CoreExtensions::Collections::LazyCollectorStep) (TypeError)
govuk-developer-docs-app-1  | 
govuk-developer-docs-app-1  |       @output << obj
govuk-developer-docs-app-1  |                  ^^^
govuk-developer-docs-app-1  |   from /root/.rbenv/versions/3.3.1/lib/ruby/3.3.0/pp.rb:328:in `pretty_print'
govuk-developer-docs-app-1  |   from /root/.rbenv/versions/3.3.1/lib/ruby/3.3.0/pp.rb:201:in `block in pp'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, works for me:

services:
  govuk-developer-docs-lite:
    <<: *govuk-developer-docs
    environment:
      LANG: "C.UTF-8"
      SKIP_PROXY_PAGES: true
      NO_CONTRACTS: true

  govuk-developer-docs-app:
    <<: *govuk-developer-docs
    depends_on:
      - nginx-proxy
    environment:
      VIRTUAL_HOST: govuk-developer-docs.dev.gov.uk
      LANG: "C.UTF-8"
      SKIP_PROXY_PAGES: true
      NO_CONTRACTS: true
    expose:
      - "4567"
    command: bundle exec middleman server --bind-address 0.0.0.0
  1. make govuk-developer-docs in govuk-docker
  2. govuk-docker-up in the govuk-developer-docs repo
  3. Wait for Inspect your site configuration at "http://f7c8440e469d.local:4567/__middleman"
  4. I did continue to get 502 Bad Gateway for a while, but refreshing for a minute or so solved that.

```yml
environment:
LANG: "C.UTF-8"
GITHUB_TOKEN: "<fill it in>"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block is under govuk-developer-docs-lite, but when we run govuk-docker-up it attaches to the govuk-developer-docs-app service, which is the block below. Should we put it in that block instead? or maybe in the common govuk-developer-docs above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've now tweaked the doc to make it clearer to add it to both services. 👍
I don't think it's possible to add to the common govuk-developer-docs because the environment property in -lite and -app override that value rather than merge with it.

App dependency install, build script and startup scripts seemed
oddly dispersed throughout the README, making it difficult to
talk about shared logic such as the ENV variables. I've consolidated
these into their own "Run the app locally" section.

Other things to note:

- I added `--verbose` to the build script, as the build initially
  failed for me and I had to re-run the script with verbose mode
  to see any meaningful output. The output isn't much more verbose
  than without the flag, so there seems no downside.
- I removed the section on `.env` file, as it seems to be an
  implementation detail, and also incompatible with running via
  govuk-docker. But I'd like to revisit this.
- I'd very much like to remove the "docker-compose.yml" hack
  workaround. But better to document the bad and fix it later,
  than leave the bad undocumented!
@ChrisBAshton ChrisBAshton force-pushed the local-dev-doc-improvements branch from 05dd126 to e500e46 Compare February 5, 2025 08:20
Copy link
Contributor

@minhngocd minhngocd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

@ChrisBAshton ChrisBAshton merged commit 128638a into main Feb 5, 2025
5 checks passed
@ChrisBAshton ChrisBAshton deleted the local-dev-doc-improvements branch February 5, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants