Pelican on docker
softwareのpluginを作る機会が多くなってきたので、それ用のblogを作ることにした。
希望条件は以下の通り。
- markdown
- 静的サイトジェネレータ
ということで、Pelican を利用する。
http://docs.getpelican.com/en/stable/
上記の要件を満たすので、 golang製 の hugo も最終候補まで残ったが、source codeの記述や、
拡張性からすると、Pelicanがよさそう。
また、サーバ起動やpublicイメージファイルの作成にMakefileを利用するところが、いい感じ。
docker container setup
当たり前と言えばそうだが、Pelicanは、python3対応。 Mac上に構築するのは、面倒なのでdocker containerで準備する。github.io に公開することも考慮して、python3 の container imageから作成。
FROM python:3-alpine3.6
MAINTAINER kurosuke
RUN apk -U add --no-cache \
perl \
make \
bash \
git
RUN pip install pelican==3.6.3 markdown \
&& pip install mdx_linkify \
&& pip install mdx_del_ins \
&& pip install setuptools \
&& pip install ghp-import
EXPOSE 8000
WORKDIR /site
docker image の build。
$ docker build . -t pelican
Pelican setup
docker run 用に簡単なscriptを用意する。
---
run.sh
#!/bin/bash docker run -it --rm -v $(pwd):/site -p 8000:8000 pelican $*
Pelicanは、quickstart コマンドがあるので、指示に従って起動。
下の例は、github.ioを利用する方法。
$ sh run.sh bash
bash-4.3# pelican-quickstart
Welcome to pelican-quickstart v3.6.3.
This script will help you create a new Pelican-based website.
Please answer the following questions so this script can generate the files
needed by Pelican.
> Where do you want to create your new web site? [.] kurosuke.github.io
> What will be the title of this web site? kurosuke and plugins
> Who will be the author of this web site? kurosuke
> What will be the default language of this web site? [en] ja
> Do you want to specify a URL prefix? e.g., http://example.com (Y/n) n
> Do you want to enable article pagination? (Y/n) y
> How many articles per page do you want? [10]
> What is your time zone? [Europe/Paris] Asia/Tokyo
> Do you want to generate a Fabfile/Makefile to automate generation and publishing? (Y/n) y
> Do you want an auto-reload & simpleHTTP script to assist with theme and site development? (Y/n) y
> Do you want to upload your website using FTP? (y/N) n
> Do you want to upload your website using SSH? (y/N) n
> Do you want to upload your website using Dropbox? (y/N) n
> Do you want to upload your website using S3? (y/N) n
> Do you want to upload your website using Rackspace Cloud Files? (y/N) n
> Do you want to upload your website using GitHub Pages? (y/N) y
> Is this your personal page (username.github.io)? (y/N) y
Done. Your new project is available at /site/kurosuke.github.io
Pelicanの起動と確認
開発用にserverを起動してみる。
$ sh run.sh bash-4.3# make devserver
これで、下記のURLで起動できる。
http://localhost:8000/
githubへ公開
github 公開用のscripts
#!/bin/sh sh run.sh make html sh run.sh ghp-import output git push origin HEAD:master -f