Skip to content

Commit c6352d5

Browse files
cuixqtymzd
authored andcommitted
docs: add instructions for running the documentation site locally (google#4818)
This PR updates `docs/README.md` to provide clearer instructions for contributors to run and test the documentation site locally in docker or natively. To run documentation site in docker, this PR introduces `docs/docs.Dockerfile` to allow consistent local documentation serving without requiring a local Ruby environment.
1 parent 8e3f360 commit c6352d5

2 files changed

Lines changed: 55 additions & 4 deletions

File tree

docs/README.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
1-
# OpenAPI generation
1+
# README
22

3-
## Prerequisites
3+
The [OSV.dev docs](https://osv.dev/docs) are hosted on [GitHub Pages](https://pages.github.com/).
4+
5+
## Running docs locally (docker)
6+
7+
You can run the docs locally consistently through docker. From the `docs` directory, run:
8+
9+
```bash
10+
docker build -t osvdev-docs -f docs.Dockerfile .
11+
docker run -p 4000:4000 osvdev-docs
12+
```
13+
14+
## Running docs locally (native)
15+
16+
To run the docs locally:
17+
18+
- Install `ruby (>= 3.1.0)`. This should come with `bundler`.
19+
- On Debian, you need to install them separately:
20+
- `ruby`
21+
- `ruby-bundler`
22+
- In this directory:
23+
- `bundle install`
24+
- `bundle exec jekyll serve`
25+
26+
Here's the full documentation on GitHub for [running Jekyll locally].
27+
28+
[running Jekyll locally]: https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/testing-your-github-pages-site-locally-with-jekyll#building-your-site-locally
29+
30+
## OpenAPI generation
31+
32+
### Prerequisites
433

534
Install `protoc` for your platform:
635

@@ -28,8 +57,8 @@ To install the protobuf service converter, run:
2857
go mod download
2958
```
3059

31-
## Generation
60+
### Generation
3261

33-
```
62+
```bash
3463
python3 ./build_swagger.py
3564
```

docs/docs.Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Use an official Ruby runtime as a parent image.
2+
FROM ruby:3
3+
4+
# Set the working directory in the container.
5+
WORKDIR /usr/src/app
6+
7+
# Copy the Gemfile and Gemfile.lock, and the bundle config.
8+
# This is done first to leverage Docker's layer caching.
9+
COPY ./Gemfile* ./
10+
11+
# Install the dependencies.
12+
RUN bundle install
13+
14+
# Copy the rest of the documentation files.
15+
COPY ./ ./
16+
17+
# Expose port 4000 for the Jekyll server.
18+
EXPOSE 4000
19+
20+
# The command to run when the container starts.
21+
# --host 0.0.0.0 is important to make the server accessible from outside the container.
22+
CMD ["bundle", "exec", "jekyll", "serve", "--host", "0.0.0.0"]

0 commit comments

Comments
 (0)