Update docs build process for new front page

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>
This commit is contained in:
Torin Sandall
2018-11-26 11:23:35 -08:00
parent fa9ae9437c
commit ce9a6e0c9a
4 changed files with 21 additions and 33 deletions
+2
View File
@@ -12,6 +12,8 @@ wasm/_obj
_test
site.tar.gz
policy.wasm
.npm
.gitbook
# runtime artifacts
policies
+4
View File
@@ -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
+12 -12
View File
@@ -32,19 +32,19 @@ if [ -z "$OUTPUT_DIR" ]; then
exit 2
fi
# build docs
cd $OPA_DIR/docs/book
gitbook install
gitbook build
BOOK_DIR=$OPA_DIR/docs/book
pushd $BOOK_DIR
gitbook -v 3.2.3 build
popd
# 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/ .
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
+3 -21
View File
@@ -21,36 +21,18 @@ 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:
@@ -58,8 +40,8 @@ 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