Skip to content

Commit

Permalink
Update docs build process for new front page
Browse files Browse the repository at this point in the history
These changes just update the build process for the new front page. As
part of these changes, the build should now be run under the host user
account instead of as root (this fixes the issue for site build
artifacts being owned by root.) To make that work the gitbook and npm
directories used by the docs build process need to be located under the
root directory so that they're writable by the user.

With these changes, the first time you build the site locally gitbook
needs to be installed but after that it's cached locally in the .gitbook
directory (so subsequent builds are fast when coupled with the vendored
node_modules for the gitbook plugins).

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
  • Loading branch information
tsandall committed Nov 26, 2018
1 parent fa9ae94 commit ce9a6e0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ wasm/_obj
_test
site.tar.gz
policy.wasm
.npm
.gitbook

# runtime artifacts
policies
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,13 @@ docs:
-v $(PWD):/go/src/github.com/open-policy-agent/opa \
-w /go/src/github.com/open-policy-agent/opa \
-p 4000:4000 \
-u $(shell id -u $(USER)):$(shell id -g $(USER)) \
-e GITBOOK_DIR=/go/src/github.com/open-policy-agent/opa/.gitbook \
-e npm_config_cache=/go/src/github.com/open-policy-agent/opa/.npm \
$(REPOSITORY)/release-builder:$(RELEASE_BUILDER_VERSION) \
./build/build-docs.sh --output-dir=/go/src/github.com/open-policy-agent/opa --serve=4000


######################################################
#
# Release targets
Expand Down
26 changes: 13 additions & 13 deletions build/build-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ if [ -z "$OUTPUT_DIR" ]; then
exit 2
fi

# build docs
cd $OPA_DIR/docs/book
gitbook install
gitbook build

# build front page
cd $OPA_DIR/docs
npm install
gulp build

# save output
tar czvf $OUTPUT_DIR/site.tar.gz -C $OPA_DIR/docs/_site/ .
BOOK_DIR=$OPA_DIR/docs/book
pushd $BOOK_DIR
gitbook -v 3.2.3 build
popd

SITE_DIR=$OPA_DIR/docs/_site
rm -fr $SITE_DIR && mkdir $SITE_DIR
cp -r $BOOK_DIR/_book/ $SITE_DIR/docs
cp $OPA_DIR/docs/index.html $SITE_DIR/
cp $OPA_DIR/docs/style.css $SITE_DIR/
cp -r $OPA_DIR/docs/img $SITE_DIR/
tar czvf $OUTPUT_DIR/site.tar.gz -C $SITE_DIR .

if [ -n "$PORT" ]; then
cd $OPA_DIR/docs/_site; python -m SimpleHTTPServer $PORT
cd $SITE_DIR; python -m SimpleHTTPServer $PORT
fi
24 changes: 3 additions & 21 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,27 @@ If you want to build and serve the site locally, you need the following packages
installed on your system:

- npm
- [gulp](http://gulpjs.com/)
- [gitbook](https://github.com/GitbookIO/gitbook)

### Build and preview the docs locally

```
cd book
gitbook install
gitbook serve
```

> This will build the docs under `./book/_book`.
### Build and preview the entire site (front page and docs) locally

```
cd book; gitbook install; gitbook build; cd ..
npm install
gulp copy-book
gulp serve
```

### Build and preview (only) the front page locally

```
npm install
gulp
```

### Build site for release
### Build site for release or preview locally

From the root directory:

```
make docs
```

This will also serve the site on port 4000. The site will be saved to
`site.tar.gz` in the root directory.
This will serve the site on port 4000. The site will be saved to `site.tar.gz`
in the root directory.

### Update the website

Expand Down

0 comments on commit ce9a6e0

Please sign in to comment.