Skip to content

Commit 128638a

Browse files
authored
Merge pull request #4875 from alphagov/local-dev-doc-improvements
Improvements to documentation around getting Developer Docs running locally
2 parents 346ff54 + e500e46 commit 128638a

File tree

2 files changed

+35
-33
lines changed

2 files changed

+35
-33
lines changed

README.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,54 @@
44

55
This is a static site generated with Middleman, using [alphagov/tech-docs-template](https://github.com/alphagov/tech-docs-template).
66

7-
Some of the files (like the CSS, javascripts and layouts) are managed in the template and are not supposed to be modified here. Any project-specific
8-
Ruby code needs to go into `/app`.
7+
Some of the files (like the CSS, javascripts and layouts) are managed in the template and are not supposed to be modified here. Any project-specific Ruby code needs to go into `/app`.
98

10-
## Build the app locally
9+
## Run the app locally
1110

12-
```sh
13-
bundle install
14-
```
11+
Run govuk-developer-docs either inside or outside govuk-docker, configuring its behaviour with the ENV variables below.
1512

16-
## Run the tests locally
13+
### ENV variables
1714

18-
```
19-
bundle exec rake
20-
```
15+
- `GITHUB_TOKEN=<your private token>` - token to use to make authenticated requests to GitHub's API. Authenticated requests have a much higher rate limit. *You _will_ need to specify a `GITHUB_TOKEN` if you want to build the entire Developer Docs site*. [Create the token on GitHub](https://github.com/settings/tokens/new) (the token doesn't need any scopes).
16+
- `SKIP_PROXY_PAGES=true` - avoid fetching remote 'docs/' for each repo (i.e. just build the docs that live within govuk-developer-docs itself). You can use this if you don't have a `GITHUB_TOKEN` or if you don't care about including the remote docs.
17+
- `NO_CONTRACTS=true` - [recommended setting](https://github.com/alphagov/govuk-developer-docs/commit/4b624a72761490c8e9b99a1aa7a10371415381e6) for speeding up the site build process
2118

22-
## Run the app locally
19+
### Run with govuk-docker
2320

24-
```sh
25-
SKIP_PROXY_PAGES=true ./startup.sh
21+
govuk-docker doesn't have great support for passing ENV vars into the application startup. You'll need to [edit the docker-compose.yml](https://github.com/alphagov/govuk-docker/blob/ed98d3547708286f534598c78fb5c57ee3c8d112/projects/govuk-developer-docs/docker-compose.yml#L12-L17) to add the necessary ENV vars (e.g. `GITHUB_TOKEN`) under the `environment` property for both the `govuk-developer-docs-app` and `govuk-developer-docs-lite` groups, eg:
22+
23+
```yml
24+
environment:
25+
GITHUB_TOKEN: "<fill it in>"
2626
```
2727
28-
## Proxy pages
28+
1. In govuk-docker:
29+
1. Edit `govuk-docker/projects/govuk-developer-docs/docker-compose.yml` as above
30+
1. [make the project](https://docs.publishing.service.gov.uk/repos/govuk-docker.html#usage)
31+
1. In govuk-developer-docs:
32+
1. Install the dependencies (`govuk-docker-run bundle install`)
33+
1. Run the application (`govuk-docker-up`)
34+
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.
35+
1. Visit <http://govuk-developer-docs.dev.gov.uk/>
2936

30-
The live docs site includes pages from other alphagov GitHub repositories. To test this locally, omit `SKIP_PROXY_PAGES=true` from the command above.
37+
### Run without govuk-docker
3138

32-
The app downloads these "proxy pages" at startup and this can cause GitHub to rate limit your requests. You can pass a valid GitHub API token to the app to help avoid this:
39+
1. Install the dependencies (`bundle install`)
40+
1. Start up the site with `./startup.sh` (passing ENV vars on the CLI if necessary)
3341

34-
1. [Create a GitHub token](https://github.com/settings/tokens/new). The token doesn't need any scopes.
42+
## Building the project, and running tests
3543

36-
1. Store the token in a `.env` file:
44+
If you just want to create the site (a `build/` directory containing a set of HTML files), but not actually start up the application, you can do so as follows (again, the ENV variables described above apply here too):
3745

38-
```sh
39-
GITHUB_TOKEN=somethingsomething
40-
```
46+
```sh
47+
NO_CONTRACTS=true bundle exec middleman build --verbose
48+
```
4149

42-
1. Start the application:
50+
To run the tests:
4351

44-
```sh
45-
./startup.sh
46-
```
52+
```
53+
bundle exec rake
54+
```
4755

4856
## Update to the latest Tech Docs template
4957

@@ -58,14 +66,6 @@ We host GOV.UK Developer Docs as a static site on GitHub Pages. The [ci.yml] Git
5866
- when a PR is merged to the default branch
5967
- on an hourly schedule, to pick up changes to docs included from other repos
6068

61-
### Build the static site locally
62-
63-
```sh
64-
NO_CONTRACTS=true bundle exec middleman build
65-
```
66-
67-
This will create a `build` directory containing a set of HTML files.
68-
6969
## Licence
7070

7171
[MIT License](LICENCE)

app/document_types.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ def shift_low_value_schemas(schemas)
8080
generic_with_external_links
8181
placeholder
8282
].each do |low_value_schema|
83+
raise "Error building document-types page. Is ~/govuk/publishing-api is up to date?" if schemas.nil?
84+
8385
if schemas.include?(low_value_schema)
8486
schemas.delete(low_value_schema)
8587
schemas.append(low_value_schema)

0 commit comments

Comments
 (0)