From 049b486f82257b0461a420cfd702d011237435e4 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Thu, 8 Oct 2020 21:17:18 +0800 Subject: [PATCH] Add docker support instructions to the docs. --- README.md | 39 +++++++++++++++++++++++++--- _posts/2019-08-09-getting-started.md | 39 +++++++++++++++++++++++++--- 2 files changed, 70 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5898bd2..e10174c 100644 --- a/README.md +++ b/README.md @@ -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 . 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 diff --git a/_posts/2019-08-09-getting-started.md b/_posts/2019-08-09-getting-started.md index 0285a49..10831d9 100644 --- a/_posts/2019-08-09-getting-started.md +++ b/_posts/2019-08-09-getting-started.md @@ -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 . 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.