DockerHub AutomatedBuild

表題の通り。先日のエントリで作成したDockerfileをGitHubでversion管理し、変更(commit)がGitHubのレポジトリにpushされたタイミングでDockerHubの”Automated Build“によって自動的にビルドされるようにしたい。

■ 環境

  • GitHub
  • DockerHub

■ Dockerfile

先日のエントリの通りである。そこからは特に修正を入れていない。

ZooKeeperの独自Dockerfileを作成

■ GitHub

新規でレポジトリを作成する。

automatedbuild-001

以降、下記。

$ mkdir docker-zookeeper
$ cd docker-zookeeper
$ git init
$ 

とりあえず”README.md“を適当に用意し、アップすることにする。

$ ls
README.md
$ git add README.md
$ git commit -m "initialize."
$ git remote add origin https://github.com/withsin/docker-zookeeper.git
$ git push -u origin master

■ DockerHub

DockerHubのアカウントは以前、下記のエントリにて作成している。

DockerHubのアカウント作成

ログイン後、アカウントの横にある”Create“から”Create Automated Build“を選択する。

automatedbuild-002

まだGitHubとの連携等をしていなければ下記のような画面が出るはずである。

automatedbuild-003

automatedbuild-004

Link Accounts“から”Link Github“を選択する。

automatedbuild-005

オススメされている”Public and Privae“を選択しておく。現状では”Private“を使うことはないであろうが。

GitHub側の認証を通せば下記のようにリンクされるはずである。

automatedbuild-006

再度、”Create Automated Build“から行くと、下記のように自身の”GitHub“のレポジトリの一覧が取得できているはずだ。

automatedbuild-007

この中から前述の通り”docker-zookeeper“を選択。

automatedbuild-008

Dockerのコンテナ名や説明に”Docker“という文字は不要であるのでそれぞれ書き換えている。

  • Name: zookeeper
  • Short Description: Apache ZooKeeper

Create“を実行。レポジトリが作成された。

automatedbuild-009

■ Automated Build

では、実際にDockerfileを`push`してコンテナがビルドされるか試してみる。Dockerfileは先日のエントリの通りである。

$ ls
Dockerfile    README.md
$ gis status
# On branch master
# Untracked files:
#   (use "git add ..." to include in what will be committed)
#
#    Dockerfile
nothing added to commit but untracked files present (use "git add" to track)
$
$ git add Dockerfile
$ git commit -m "add Dockerfile."
$ git push
Username for 'https://github.com': withsin
Password for 'https://withsin@github.com':
Counting objects: 4, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 565 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/withsin/docker-zookeeper.git
   d5f780c..04efe2a  master -> master
$

これでDockerHubを確認する。”Build Details“を見ると下記のようになっていた。

automatedbuild-010

“Queued”でコンテナがビルドされる順番待ちであるようである。しばらく待って再度アクセスすればコンテナがビルドされているであろう。

automatedbuild-011

以上。

■ 関連

GitHub API rate limit

■ 環境

  • Mac OSX (10.10.5)

■ message

表題の件、先日`brew search`を何度か実行していたら下記のメッセージが出力された。

$ brew search ...
  :
Error: GitHub API rate limit exceeded for XXX.XXX.XXX.XXX. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)
Try again in 25 minutes 26 seconds, or create a personal access token:
  https://github.com/settings/tokens/new?scopes=&description=Homebrew
and then set the token as: HOMEBREW_GITHUB_API_TOKEN
$

確かに`brew search`は何度もしたけれども、制限にかかるほど実行したわけではなかったはずなのだが…。メッセージにある通りにGitHubでトークンを作成し環境変数に登録しておけば、このようなメッセージも防ぐことができるようであるが、特に必要としていないので今回は見送ることにする。

以上。