Jekyll静态站点在docker上的配置
参考:
- How To Deploy A Jekyll Blog In Docker:https://blog.nimbleci.com/2016/08/10/how-to-deploy-a-jekyll-blog-in-docker/
- jekyll/dockerfile :https://hub.docker.com/r/jekyll/jekyll/dockerfile/
- jekyll-docker:https://github.com/envygeeks/jekyll-docker
- jekyll-docker:https://lab.sub.uni-goettingen.de/jekyll-docker.html
- jekyll docker-compose:https://www.brianweet.com/2017/09/17/trying-out-docker-build-jekyll-blog.html
- Jekyll in a Docker Container :https://github.com/BretFisher/jekyll-serve
- Running Jekyll in Docker:https://ddewaele.github.io/running-jekyll-in-docker/
- Building livereload jekyll:https://www.brianweet.com/2017/09/17/trying-out-docker-build-jekyll-blog.html
- Jekyll admin:https://github.com/jekyll/jekyll-admin 等待v1.0的auth功能
- Docker+Jekyll+NGINX 全自动部署:https://blog.kejun.me/technology/2017/08/18/docker-jekyll-nginx-auto-pull.html
- nginx-reverse-proxy:https://www.linode.com/docs/web-servers/nginx/use-nginx-reverse-proxy/
- Creating a gem-based theme:https://jekyllrb.com/docs/themes/
- paginate multiple blogs:https://github.com/scandio/jekyll-paginate-multiple
- Jekyll paginate v2 : https://github.com/sverrirs/jekyll-paginate-v2
- Jekyll 主题:
- 优秀主题
- https://github.com/Liberxue/liberxue.github.io/blob/master/ChinaREADME.md
- https://github.com/volny/creative-theme-jekyll
- https://github.com/Jandaes/Jandaes.github.io
- https://github.com/mushishi78/jekyll-video
- https://github.com/bogoli/-folio/blob/master/_config.yml
- https://portfolio-central.github.io/jekyll-instagram-portfolio-theme/
- https://github.com/Wiredcraft/carte
- https://github.com/ShawnTeoh/matjek
- https://nandomoreirame.github.io/mug/
- https://portfolio-central.github.io/jekyll-instagram-portfolio-theme/
Jekyll in docker搭建过程
创建Jekyll项目
export JEKYLL_VERSION=3.8
mkdir -p ~/Projects/myblog ;
cd ~/Projects/myblog
docker run --rm \
--volume="$PWD:/srv/jekyll" \
--volume="$PWD/vendor/bundle:/usr/local/bundle" \
-it jekyll/jekyll:$JEKYLL_VERSION \
jekyll new . --force -H localhost
构建Jekyll项目
docker run --rm \
--volume="$PWD:/srv/jekyll" \
--volume="$PWD/vendor/bundle:/usr/local/bundle" \
-it jekyll/jekyll:$JEKYLL_VERSION \
jekyll build
编辑Gemfile、_config.yml、配置插件、添加Page/Post等……
// 设置 cayman 主题
// Add this line to your Jekyll site’s Gemfile:
gem "jekyll-theme-cayman-blog"
//添加jekyll-admin
gem 'jekyll-admin', group: :jekyll_plugins
//添加jekyll-manager
# gem 'jekyll-manager', group: :jekyll_plugins
// Add this line to your Jekyll site’s _config.yml file:
theme: jekyll-theme-cayman-blog
启动Jekyll容器
docker run --rm --name my-jekyll \
--network network_mynginx \
--volume="$PWD:/srv/jekyll" \
--volume="$PWD/vendor/bundle:/usr/local/bundle" \
-p 4000:4000 \
-it jekyll/jekyll:$JEKYLL_VERSION \
jekyll serve --watch --drafts
后台运行
docker run -d --rm --name my-jekyll \
--network network_mynginx \
--volume="$PWD:/srv/jekyll" \
--volume="$PWD/vendor/bundle:/usr/local/bundle" \
-p 4000:4000 \
-it jekyll/jekyll:$JEKYLL_VERSION \
jekyll serve --watch --drafts
# 非docker环境下,后台运行
nohup bundle exec jekyll serve --incremental &
使用Dockerfile
Dockerfile文件
FROM jekyll/jekyll:3.8
RUN mkdir -p /srv/jekyll && \
mkdir -p /usr/local/bundle
COPY . /srv/jekyll
WORKDIR /srv/jekyll
EXPOSE 4000 80
CMD [ "bundle", "install"]
.dockerignore文件
*.dockerapp
*.tar.gz
_build/
bin
_site/
.sass-cache/
vendor/
README.md
构建镜像
docker build -t myjekyll:v1.0 .
后台运行docker
docker run -d --rm --name my-jekyll \
--network network_mynginx \
--volume="$PWD:/srv/jekyll" \
--volume="$PWD/vendor/bundle:/usr/local/bundle" \
-p 4000:4000 \
-it myjekyll:v1.0 \
jekyll serve --watch --drafts --incremental
使用docker-compose
docker-compose.yml文件
version: '3.5'
services:
web:
build: .
command: jekyll serve --drafts --future --force_polling
# image: jekyll/jekyll:3.8
image: myjekyll:v1.0 # 指定(生成的)镜像名
container_name: my-jekyll # 指定(生成的)容器名
volumes:
- .:/srv/jekyll
- ./vendor/bundle:/usr/local/bundle
ports:
- 4000:4000
networks:
- jekyll_network
# 引用已存在的网络
networks:
jekyll_network:
external:
name: network_mynginx
docker-compose service的启动、运行及删除
docker-compose up -d //创建并后台启动
docker-compose stop //停止
docker-compose start //启动
docker-compose ps //查看
docker-compose down --rmi all --remove-orphans //删除服务、并删除生成的镜像和容器