Simplify and make reproducible the website setup (#491)

* Simplify and make reproducible the website setup

We still need to make an image so it doesn’t take forever but at least
this is reproducible and working

* Fix for liquid exception

Liquid Exceptions: No repo name found. Specify using PAGES_REPO_NWO
environment variables

* added info about faster subsequent starts by reusing the image

* typo
This commit is contained in:
Laurent Demailly 2017-09-21 18:35:25 -07:00 committed by GitHub
parent 80669ca121
commit cb784195dc
2 changed files with 22 additions and 40 deletions

View File

@ -13,51 +13,31 @@ familiar with these before editing.
To run the site locally with Docker, use the following command:
```bash
docker run --rm --label=jekyll --volume=$(pwd):/srv/jekyll -it -p 127.0.0.1:4000:4000 jekyll/jekyll sh -c "bundle install && jekyll serve"
# First time: (slow)
docker run --name istio-jekyll --volume=$(pwd):/srv/jekyll -it -p 127.0.0.1:4000:4000 jekyll/jekyll:3.5.2 sh -c "bundle install && rake test && jekyll serve"
# Subsequent, each time you want to see a new change and you stopped the previous run: (much faster)
docker start istio-jekyll -a -i
# Clean up, only needed if you won't be previewing website changes for a long time or you want to start over:
docker rm istio-jekyll
```
Make sure you are not introducing html errors or bad links:
```bash
docker run --rm --label=jekyll --volume=$(pwd):/srv/jekyll -it jekyll/jekyll sh -c "bundle install && rake test"
```
The `rake test` part is to make sure you are not introducing html errors or bad links, you should see
```
HTML-Proofer finished successfully.
```
in the output
#### Side note for those on non-linux machines
If you're developing locally but not on a Linux machine, you have a couple options.
You can opt to use [Docker for Mac](https://docs.docker.com/docker-for-mac/) / [Docker for Windows](https://docs.docker.com/docker-for-windows/). This will give you a docker environment from which to run the above docker container (which has all the of the correct Jekyll dependencies and Ruby versions installed). Alternatively, you could use minikube.
If doing Istio development on Kubernetes locally with [minikube](https://kubernetes.io/docs/getting-started-guides/minikube/) and native virtualization (for example, on Mac OS X with[xhyve driver](https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#xhyve-driver), then bootstrap like this:
```bash
minikube start --vm-driver=xhyve
```
You can see more about this command and how to install the [xhyve](https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#xhyve-driver) drivers by [taking a look at the xhyve driver documentation](https://github.com/zchee/docker-machine-driver-xhyve#install)
Then build and run the website with minikube and bind to your `minikube ip` like this:
```bash
docker run --rm --label=jekyll --volume=$(pwd):/srv/jekyll -it -p $(minikube ip):4000:4000 jekyll/jekyll jekyll serve
```
To see the web page locally on `localhost:4000`, you can port-forward the minikube port `4000` to your local machine. Run this command in a separate tab/window:
```bash
minikube ssh -- -vnNTL *:4000:$(minikube ip):4000
```
## Local/Native Jekyll install:
Alternatively, if you just want to develop locally w/o Docker/Kubernetes/Minikube, you can try installing Jekyll locally. You may need to install other prerequisites manually (which is where using the docker image shines). Here's an example of doing so for Mac OS X:
$ xcode-select --install
$ brew install ruby
$ sudo gem install bundler
$ sudo gem install jekyll
$ cd istio.github.io
$ bundle install
$ bundle exec jekyll build
$ bundle exec jekyll serve
```
xcode-select --install
brew install ruby
sudo gem install bundler
sudo gem install jekyll
cd istio.github.io
bundle install
rake test
bundle exec jekyll serve
```

View File

@ -61,3 +61,5 @@ exclude:
- repos/*.html
- repos/*.md
repository:
istio/istio.github.io