CircleCIでMeCabを利用してHugoビルドする
以下のコンテナ設定が掴めてきましたので、備忘録として残しておきます。
- Circle CIで、PythonからMeCab、sklearnを利用して関連記事を作成
- Hugoでビルド&さくらVPSにブログを公開
circle.yml
現在のcircle.ymlです。以下のモジュールをインストールして、コンテナの準備、Hugoでビルド、さくらVPSへの公開を行なっています。
- MeCab
- Python
- Hugo
machine:
timezone: Asia/Tokyo
ruby:
version: 2.2.4
python:
version: 3.5.1
dependencies:
cache_directories:
- mecab-0.996
- mecab-ipadic-2.7.0-20070801
pre:
- git config --global user.name "meganii"
- git config --global user.email "[email protected]"
- >
HUGO_VERSION=0.18.1 &&
set -x &&
set -e &&
if [ ! -e $CIRCLE_BUILD_DIR/bin/hugo ] || ![[ `hugo version` =~ v${HUGO_VERSION} ]]; then
wget https://github.com/spf13/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_Linux-64bit.tar.gz &&
tar xvzf hugo_${HUGO_VERSION}_Linux-64bit.tar.gz &&
sudo cp hugo_${HUGO_VERSION}_linux_amd64/hugo_${HUGO_VERSION}_linux_amd64 $CIRCLE_BUILD_DIR/bin/hugo;
fi
- sudo apt-get update -qq
- sudo apt-get install -qq python3-dev
- >
if [[ ! -e mecab-0.996/src/mecab ]]; then
wget -O mecab-0.996.tar.gz "https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7cENtOXlicTFaRUE" &&
tar xvzf mecab-0.996.tar.gz &&
cd mecab-0.996 &&
./configure --enable-utf8-only &&
make
fi
- >
cd mecab-0.996 &&
sudo make install &&
sudo ldconfig
- >
if [[ ! -e mecab-ipadic-2.7.0-20070801/sys.dic ]]; then
wget -O mecab-ipadic-2.7.0-20070801.tar.gz "https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7MWVlSDBCSXZMTXM" &&
tar xvzf mecab-ipadic-2.7.0-20070801.tar.gz &&
cd mecab-ipadic-2.7.0-20070801 &&
./configure --with-charset=utf8 &&
make
fi
- >
cd mecab-ipadic-2.7.0-20070801 &&
sudo make install
- pip install --upgrade pip
- pip install -r requirements.txt
test:
override:
- python -V
- hugo version
deployment:
master:
branch: master
commands:
- rake create_relatedposts
- rake -q deploy_to_sakura_from_circleci
- pwd
- git add data/* tmp/* && git commit -m "[ci skip] publish"; if [ $? -eq 0 ]; then git push origin master; else :; fiHugoインストールの修正
元々はHugoのインストールを以下の通り、都度最新版をダウンロードしていたのですが、Hugoの開発が行われる度、ビルドに失敗するため、バージョン固定としました。
変更前
- go get -u -v github.com/kardianos/govendor
- go get -u -v github.com/spf13/hugo
- cd /home/ubuntu/.go_workspace/src/github.com/spf13/hugo && govendor sync && go install変更後(バイナリをダウンロード)
- >
HUGO_VERSION=0.18.1 &&
set -x &&
set -e &&
if [ ! -e $CIRCLE_BUILD_DIR/bin/hugo ] || ![[ `hugo version` =~ v${HUGO_VERSION} ]]; then
wget https://github.com/spf13/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_Linux-64bit.tar.gz &&
tar xvzf hugo_${HUGO_VERSION}_Linux-64bit.tar.gz &&
sudo cp hugo_${HUGO_VERSION}_linux_amd64/hugo_${HUGO_VERSION}_linux_amd64 $CIRCLE_BUILD_DIR/bin/hugo;
fiRelated contents
TECH
2016.09.08
TECH
2016.08.15
TECH
2017.12.22
TECH
2017.10.14
TECH
2017.10.07
TECH
2017.08.31
TECH
2017.04.09
TECH
2017.03.19