Add docker support instructions to the docs.

This commit is contained in:
Cotes Chung 2020-10-08 21:17:18 +08:00
parent 8f11f91677
commit 049b486f82
2 changed files with 70 additions and 8 deletions

View File

@ -72,6 +72,14 @@ In order to generate some extra files (_categories_, _tags_ and _last modified l
$ brew install coreutils
```
### Setting up Docker environment (optional)
If you're a loyal fan of [**Docker**](https://www.docker.com/) or just too lazy to install the packages mentioned in [_Setting up the local envrionment_](#setting-up-the-local-envrionment), please make sure you have **Docker Engine** installed and running, and then get Docker image `jekyll/jekyll` from Docker Hub by the following command:
```console
$ docker pull jekyll/jekyll:latest
```
## Usage
Running [**Chirpy**](https://github.com/cotes2020/jekyll-theme-chirpy/) requires some extra files, which cannot be generated by Jekyll native commands, so please strictly follow the methods mentioned below to run or deploy your website.
@ -119,6 +127,19 @@ Then open a browser and visit to <http://localhost:4000>.
Few days later, you may find that the file changes does not refresh in real time by using `run.sh`. Don't worry, the advanced option `-r` (or `--realtime`) will solve this problem, but it requires [**fswatch**](http://emcrisostomo.github.io/fswatch/) to be installed on your machine.
### Run on Docker
Run the site on Docker with the following command:
```terminal
$ docker run --rm -it \
--volume="$PWD:/srv/jekyll" \
-p 4000:4000 jekyll/jekyll \
bash tools/run.sh --docker
```
Please note that on Docker containers, you'll lose the real-time refresh feature.
### Deployment
Before the deployment begins, checkout the file `_config.yml` and make sure the `url` is configured correctly. Furthermore, if you prefer the [_project site_](https://help.github.com/en/github/working-with-github-pages/about-github-pages#types-of-github-pages-sites) and don't use a custom domain, or you want to visit your website with a base url on a web server other than **GitHub Pages**, remember to change the `baseurl` to your project name that starting with a slash. For example, `/project`.
@ -131,8 +152,7 @@ For security reasons, GitHub Pages build runs on `safe` mode, which restricts us
1. Push any commit to `origin/master` to trigger the GitHub Actions workflow. Once the build is complete and successful, a new remote branch named `gh-pages` will appear to store the built site files.
2. Browse to your repository on GitHub and choose the branch `gh-pages` as the [publishing source](https://docs.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) throught _Settings_
_Options__GitHub Pages_:
2. Browse to your repository on GitHub and choose the branch `gh-pages` as the [publishing source](https://docs.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) throught _Settings__Options__GitHub Pages_:
![gh-pages-sources](https://raw.githubusercontent.com/cotes2020/jekyll-theme-chirpy/master/assets/img/sample/gh-pages-sources.png)
3. Visit your website at the address indicated by GitHub.
@ -144,10 +164,21 @@ On platforms other than GitHub, we cannot enjoy the convenience of **GitHub Acti
Go to the root of the source project, build your site by:
```console
$ bash tools/build.sh -d /path/to/site/
$ bash tools/build.sh
```
The generated site files will be placed in folder `/path/to/site/`. Now you should upload those files to your web server.
> **Note**: The output path can be specified with the option `-d`.
Or, build the site with Docker by:
```terminal
$ docker run --rm -it \
--volume="$PWD:/srv/jekyll" \
jekyll/jekyll \
bash tools/build.sh --docker
```
Unless you specified the output path, the generated site files will be placed in folder `_site` of the project's root directory. Now you should upload those files to your web server.
### Documentation

View File

@ -42,6 +42,14 @@ In order to generate some extra files (_categories_, _tags_ and _last modified l
$ brew install coreutils
```
### Setting up Docker environment (optional)
If you're a loyal fan of [**Docker**](https://www.docker.com/) or just too lazy to install the packages mentioned in [_Setting up the local envrionment_](#setting-up-the-local-envrionment), please make sure you have **Docker Engine** installed and running, and then get Docker image `jekyll/jekyll` from Docker Hub by the following command:
```console
$ docker pull jekyll/jekyll:latest
```
## Usage
Running [**Chirpy**](https://github.com/cotes2020/jekyll-theme-chirpy/) requires some extra files, which cannot be generated by Jekyll native commands, so please strictly follow the methods mentioned below to run or deploy your website.
@ -89,6 +97,19 @@ Then open a browser and visit to <http://localhost:4000>.
Few days later, you may find that the file changes does not refresh in real time by using `run.sh`. Don't worry, the advanced option `-r` (or `--realtime`) will solve this problem, but it requires [**fswatch**](http://emcrisostomo.github.io/fswatch/) to be installed on your machine.
### Run on Docker
Run the site on Docker with the following command:
```terminal
$ docker run --rm -it \
--volume="$PWD:/srv/jekyll" \
-p 4000:4000 jekyll/jekyll \
bash tools/run.sh --docker
```
Please note that on Docker containers, you'll lose the real-time refresh feature.
### Deployment
Before the deployment begins, checkout the file `_config.yml` and make sure the `url` is configured correctly. Furthermore, if you prefer the [_project site_](https://help.github.com/en/github/working-with-github-pages/about-github-pages#types-of-github-pages-sites) and don't use a custom domain, or you want to visit your website with a base url on a web server other than **GitHub Pages**, remember to change the `baseurl` to your project name that starting with a slash. For example, `/project`.
@ -101,8 +122,7 @@ For security reasons, GitHub Pages build runs on `safe` mode, which restricts us
1. Push any commit to `origin/master` to trigger the GitHub Actions workflow. Once the build is complete and successful, a new remote branch named `gh-pages` will appear to store the built site files.
2. Browse to your repository on GitHub and choose the branch `gh-pages` as the [publishing source](https://docs.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) throught _Settings_
_Options__GitHub Pages_:
2. Browse to your repository on GitHub and choose the branch `gh-pages` as the [publishing source](https://docs.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) throught _Settings__Options__GitHub Pages_:
![gh-pages-sources](/assets/img/sample/gh-pages-sources.png){: width="650"}
3. Visit your website at the address indicated by GitHub.
@ -114,7 +134,18 @@ On platforms other than GitHub, we cannot enjoy the convenience of **GitHub Acti
Go to the root of the source project, build your site by:
```console
$ bash tools/build.sh -d /path/to/site/
$ bash tools/build.sh
```
The generated site files will be placed in folder `/path/to/site/`. Now you should upload those files to your web server.
> **Note**: The output path can be specified with the option `-d`.
Or, build the site with Docker by:
```terminal
$ docker run --rm -it \
--volume="$PWD:/srv/jekyll" \
jekyll/jekyll \
bash tools/build.sh --docker
```
Unless you specified the output path, the generated site files will be placed in folder `_site` of the project's root directory. Now you should upload those files to your web server.