« 06.01 DotCloudをGit serverにしてみる | ココ | 06.03 伊香保で浸かってうどんを食す »

2012年6月 2日

DotCloudをGit serverにしてみる(2)  このエントリーを含むはてなブックマーク 

前回はGitのサーバーとして動かすのに必要なNginXとDAVモジュール拡張をデプロイするところまでできた。ので、実際にGitレポジトリを入れてみる。

カスタムNginXの設定ファイルでは、ドキュメントルートが/home/dotcloud/current/staticになっているので、staticディレクトリの下にレポジトリを作る。$testgit_dirはdotcloud.ymlがあるディレクトリ。

$ cd $testgit_dir/static
$ mkdir test.git
$ cd test.git
$ git init --bare

これで、http://~/test.git でアクセスできる(予定の)レポジトリができたはず。$testgit_dirに戻って、デプロイするファイルの確認。

$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: static/test.git/HEAD
# new file: static/test.git/config
# new file: static/test.git/description
# new file: static/test.git/hooks/applypatch-msg.sample
# new file: static/test.git/hooks/commit-msg.sample
# new file: static/test.git/hooks/post-commit.sample
# new file: static/test.git/hooks/post-receive.sample
# new file: static/test.git/hooks/post-update.sample
# new file: static/test.git/hooks/pre-applypatch.sample
# new file: static/test.git/hooks/pre-commit.sample
# new file: static/test.git/hooks/pre-rebase.sample
# new file: static/test.git/hooks/prepare-commit-msg.sample
# new file: static/test.git/hooks/update.sample
# new file: static/test.git/info/exclude
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: dotcloud.yml
# modified: nginx/builder
# modified: nginx/nginx.conf.in
# modified: static/index.html
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# nginx-dav-ext-module/


よし、これでpushする!

$ dotcloud push --all testgit
# upload /home/user/dcprojects/testgit ssh://dotcloud@uploader.dotcloud.com:443/testgit
# rsync
Pseudo-terminal will not be allocated because stdin is not a terminal.
building file list ... done
./
nginx/
nginx/builder
nginx/nginx.conf.in
static/
static/index.html
static/test.git/
static/test.git/HEAD
static/test.git/config
static/test.git/description
static/test.git/branches/
static/test.git/hooks/
static/test.git/hooks/applypatch-msg.sample
static/test.git/hooks/commit-msg.sample
static/test.git/hooks/post-commit.sample
static/test.git/hooks/post-receive.sample
static/test.git/hooks/post-update.sample
static/test.git/hooks/pre-applypatch.sample
static/test.git/hooks/pre-commit.sample
static/test.git/hooks/pre-rebase.sample
static/test.git/hooks/prepare-commit-msg.sample
static/test.git/hooks/update.sample
static/test.git/info/
static/test.git/info/exclude
static/test.git/objects/
static/test.git/objects/info/
static/test.git/objects/pack/
static/test.git/refs/
static/test.git/refs/heads/
static/test.git/refs/tags/

sent 9.01K bytes received 428 bytes 1.72K bytes/sec
total size is 42.39K speedup is 4.49
14:24:25 ---> Deploy of "testgit" scheduled for revision rsync-1338560664639 at 2012-06-01 14:24:25
14:24:26 ---> Building the application...
(省略)
14:24:51 [nginx.0] Deploying build revision rsync-1338560664639...
14:24:59 [nginx.0] Running postinstall script...
14:25:03 [nginx.0] Launching...
14:25:07 [nginx.0] Waiting for the instance to become responsive...
14:25:11 [nginx.0] Re-routing traffic to the new build...
14:25:11 [nginx.0] Successfully deployed build revision rsync-1338560664639
14:25:11 ---> Deploy finished
14:25:11 ---> Application fully deployed

Deployment finished. Your application is available at the following URLs
nginx: http://testgit-67yk2h4g.dotcloud.com/

さあレポジトリも一緒にデプロイされたし、別のディレクトリから試しに複製してみる。

$ git clone http://testgit-67yk2h4g.dotcloud.com/test.git
Cloning into test...
fatal: http://testgit-67yk2h4g.dotcloud.com/test.git/info/refs not found: did you run git update-server-info on the server?

あれ…なにこのエラー。

Git のリモートリポジトリから HTTP で pull するためのメモ(ref. akihiko’s tech note)

上によると、test.gitディレクトリの下で"git update-server-info"を実行しなければならないらしく(自動化するには、さらにhooks/post-updateを作成して更新が起こるたびに実行されるようにしなければならない)。とりあえず実行してtest.git/info/refsファイルが作成されたことを確認して再度git commit, dotcloud push testgitを実行。

$ git clone http://testgit-67yk2h4g.dotcloud.com/test.git
Cloning into test...
warning: You appear to have cloned an empty repository.
$ ls
test

おお、これでHTTP経由でgitのクローンが作れたぞ!あとはSSHで更新ができたりするようにすればいいんだと思う(多分、普通にdotcloud CLIでpushできてるから同じようにすればいいんだと勝手に思ってるけど、まだこれから試す)。

By ただ at 00:26 カテゴリー ; プログラミングとか

« 06.01 DotCloudをGit serverにしてみる | 06月の記事 | 06.03 伊香保で浸かってうどんを食す »




トラックバック

このエントリーのトラックバックURL:
http://pinmarch.sakura.ne.jp/mt/mt-tb.cgi/1805