# this file describes how to build tsuru go image # to run it: # 1- install docker # 2- run: $ docker build -t tsuru/go https://raw.github.com/tsuru/basebuilder/master/go/Dockerfile
from ubuntu:14.04 run apt-get update run apt-get install wget -y --force-yes run wget http://github.com/tsuru/basebuilder/tarball/master -O basebuilder.tar.gz --no-check-certificate run mkdir /var/lib/tsuru run tar -xvf basebuilder.tar.gz -C /var/lib/tsuru --strip 1 run cp /var/lib/tsuru/go/deploy /var/lib/tsuru #run cp /var/lib/tsuru/base/restart /var/lib/tsuru run cp /var/lib/tsuru/go/start /var/lib/tsuru run /var/lib/tsuru/go/install run /var/lib/tsuru/base/setup
$ tsuru app-create helloworld go App "helloworld" is being created! Use app-info to check the status of the app and its units. Your repository for"helloworld" project is "git@10.1.1.17:helloworld.git"
$ tsuru app-info -a helloworld Application: helloworld Repository: git@10.1.1.17:helloworld.git Platform: go Teams: admin Address: helloworld.masato.pw Owner: admin@example.com Deploys: 0
デプロイ先のremoteリポジトリを追加します。
$ git remote add tsuru git@10.1.1.17:helloworld.git $ git push tsuru master ... remote: ---- Starting 1 unit ---- remote: ---> Started unit 1/1... remote: remote: ---> App will be restarted, please check its logs for more details... remote: remote: remote: OK To git@10.1.1.17:helloworld.git * [new branch] master -> master
Procfileの作成
HerokuのようなProfileを作成して、Goアプリの起動コマンドを記述します。
~/go_apps/hello/Proflile
web:./main
Procfileの追加してgit pushするとデプロイが完了して、アプリが起動します。
$ git add Procfile $ git commit -m "Procfile: added file" $ git push tsuru master ... remote: ---- Starting 1 unit ---- remote: ---> Started unit 1/1... remote: remote: ---> App will be restarted, please check its logs for more details... remote: remote: remote: OK To git@10.1.1.17:helloworld.git 696793b..0195778 master -> master
確認
app-listで確認すると、正常にデプロイがされ、アプリが開始しています。
$ tsuru app-list Application: helloworld Repository: git@10.1.1.17:helloworld.git Platform: go Teams: admin Address: helloworld.masato.pw Owner: admin@example.com Deploys: 2 Units: +------------------------------------------------------------------+---------+ | Unit | State | +------------------------------------------------------------------+---------+ | ed5cd59d36b849e6770d32fc57506987ceb6e3df0de6c32094d219c69ae97f90 | started | +------------------------------------------------------------------+---------+