Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 838f1d1

Browse files
authoredDec 18, 2024··
Merge pull request #413 from vim-jp/build-by-docker
add how to build and check with local docker
2 parents 6cfe256 + f08938f commit 838f1d1

File tree

4 files changed

+119
-0
lines changed

4 files changed

+119
-0
lines changed
 

‎README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,71 @@
11
# vim-jp.github.io
22

3+
Source of <https://vim-jp.org/>
4+
35
* [EditSite](https://github.com/vim-jp/vim-jp.github.io/wiki/EditSite) サイト編集の手順 (ローカル環境での確認方法)
46

57
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="クリエイティブ・コモンズ・ライセンス" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />この 作品 は <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">クリエイティブ・コモンズ 表示 4.0 国際 ライセンス</a>の下に提供されています。
8+
9+
## ローカルでビルド・確認する方法
10+
11+
### 必要なもの
12+
13+
* Docker
14+
* (オプション) Python 3: ローカルHTTPサーバーをPython 3で動かす
15+
16+
### ビルド
17+
18+
以下のコマンドを実行すると `_site/` ディレクトリにHTML他が出力される。
19+
20+
```console
21+
$ ./_scripts/docker_jekyll jekyll build
22+
```
23+
24+
以下のようにするとインクリメンタルビルドが有効になり、
25+
2回目以降のビルド時間が短縮される。
26+
27+
```console
28+
$ ./_scripts/docker_jekyll jekyll build -I
29+
```
30+
31+
### ローカルサーバー
32+
33+
以下のコマンドで `jekyll serve` を実行し、ビルドした上でローカルHTTPサーバーが
34+
起動し、手元のWebブラウザで内容を確認できる。
35+
36+
```console
37+
$ ./_scripts/docker_jekyll_serve
38+
```
39+
40+
これは4000番のポートでコンテンツを供給する。
41+
Webブラウザで <http://127.0.0.1:4000/> を開くことで内容を確認できる。
42+
43+
また以下のように同コマンドへオプションを指定すると、インクリメンタルビルドと
44+
変更監視&自動再ビルド機能が有効になる。
45+
46+
```console
47+
$ ./_scripts/docker_jekyll_serve -wI
48+
```
49+
50+
Windowsなどのシステムでは変更監視が機能しない場合がある。
51+
そのようなケースではPython 3でローカルサーバーを立て、
52+
ビルドは手動でやってしまったほうが手っ取り早い場合があるかもしれない。
53+
そのやり方の詳しくは後述。
54+
55+
ローカルサーバーだけが必要で、変更監視や自動更新が不要な場合は次のように
56+
起動しても良いかもしれない。
57+
58+
```console
59+
$ ./_scripts/docker_jekyll_serve --skip-initial-build --no-watch
60+
```
61+
62+
#### Pythonを使用したローカルサーバー
63+
64+
以下のコマンドでPythonによるローカルHTTPサーバーを起動できる
65+
66+
```console
67+
$ ./_scripts/python_http_server
68+
```
69+
70+
これは8000番のポートでコンテンツを供給するので、
71+
Webブラウザで <http://127.0.0.1:8000/> を開くことで内容を確認できる。

‎_scripts/docker_jekyll

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
#
3+
# This uses GitHub Container Registry.
4+
# So you need to login ghcr.io with Personal Access Token which have scope read:packages at least.
5+
#
6+
# Example:
7+
#
8+
# cat | docker login ghcr.io -u USERNAME --password-stdin
9+
# (type your PAT and Ctrl-D twice)
10+
11+
set -eu
12+
13+
dir="$(pwd)"
14+
15+
case $(uname -s) in
16+
MSYS*) dir=$(cygpath -w $dir) ;;
17+
esac
18+
19+
docker run --rm -it \
20+
--workdir //srv/jekyll \
21+
-v "${dir}:/srv/jekyll" \
22+
-p 4000:4000 \
23+
--entrypoint "" \
24+
ghcr.io/actions/jekyll-build-pages:v1.0.13 \
25+
"$@"

‎_scripts/docker_jekyll_serve

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
#
3+
# This uses GitHub Container Registry.
4+
# So you need to login ghcr.io with Personal Access Token which have scope read:packages at least.
5+
#
6+
# Example:
7+
#
8+
# cat | docker login ghcr.io -u USERNAME --password-stdin
9+
# (type your PAT and Ctrl-D twice)
10+
11+
set -eu
12+
13+
dir="$(pwd)"
14+
15+
case $(uname -s) in
16+
MSYS*) dir=$(cygpath -w $dir) ;;
17+
esac
18+
19+
docker run --rm -it \
20+
--workdir //srv/jekyll \
21+
-v "${dir}:/srv/jekyll" \
22+
-p 4000:4000 \
23+
--entrypoint jekyll \
24+
ghcr.io/actions/jekyll-build-pages:v1.0.13 \
25+
server -H 0.0.0.0 "$@"

‎_scripts/python_http_server

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
python3 -m http.server 8000 --directory _site

0 commit comments

Comments
 (0)
Please sign in to comment.