Last active
January 25, 2016 12:20
-
-
Save yamamoto-febc/9f6e524fa7507a255dbb to your computer and use it in GitHub Desktop.
RubyをインストールせずにdockerでGitHub Pagesのプレビュー環境を作るメモ ref: http://qiita.com/yamamoto-febc/items/8c5b50acb4b6075ee15d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dockerホスト作成 | |
$ docker-machine create -d sakuracloud \ | |
--sakuracloud-access-token=[ACCESS TOKEN] \ | |
--sakuracloud-access-token-secret=[ACCESS TOKEN SECRET] \ | |
sakura-pages | |
# dockerコマンドから作成したdockerホストを使う | |
$ eval $(docker-machine env sakura-pages) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker-machine ssh sakura-pages -f -N -L 4000:localhost:4000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# jekyllイメージ(GitHubPages用)を指定 | |
FROM jekyll/jekyll:pages | |
# カレントディレクトリのファイルをイメージへコピー | |
COPY . /srv/jekyll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ # 初回だけ chmod +x preview.sh | |
$ ./preview.sh # jekyllコンテナがフォアグラウンド実行される。終了は`Ctrl + c` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DOCKER_IMAGE_NAME="github_pages_static_preview" | |
DOCKER_CONTAINER_NAME="github_pages_static_container" | |
# もし起動しているコンテナがあれば削除 | |
if [[ $(docker ps -a | grep $DOCKER_CONTAINER_NAME) != "" ]]; then | |
docker rm -f $DOCKER_CONTAINER_NAME 2>/dev/null | |
fi | |
# カレントディレクトリのDockerfileを使ってイメージ作成 | |
docker build -t $DOCKER_IMAGE_NAME . | |
# コンテナ起動(dockerホストの127.0.0.1:4000をコンテナの4000番へ) | |
docker run --rm -it \ | |
--name $DOCKER_CONTAINER_NAME \ | |
-p 127.0.0.1:4000:4000 \ | |
$DOCKER_IMAGE_NAME \ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment