仙台の山奥で自転車に乗ったり転んだり

愛車の GIOS でサイクリングしたりポタリングしたり、それをブログに記録してみたり。ロードバイクや自転車や坂のことを書いてみたり。ときたまプログラムのことを忘れないようにメモってみたり。

開発環境の Docker ホストに barge が良さげなので試す

秘伝のタレ化してゴテゴテと開発環境を積んだ vagrant のイメージ上で Docer も動かしていたが、色々と無駄も多そうで Mac で開発していて Docker だけサクッと動かしたいときにムダもあったので軽量な専用ホストを用意してみたかった。

ここら辺を読んで良さげだったので試してみた。

いきなりドキュメントどおりにやってみたらコケた。

$ vagrant box add ailispaw/barge
The box 'ailispaw/barge' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Atlas, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:

URL: ["https://atlas.hashicorp.com/ailispaw/barge"]
Error:

バージョンが古いのが臭かったので、公式サイトから最新版をダウンロードしてきて再試行

$ vagrant -v
Vagrant 1.8.7

$ vagrant -v
Vagrant 1.9.3

いけそうだけどプラグインもバージョンが古いって怒られたから、とりあえず何も考えずに言われたとおり再インストールする。

$ vagrant box add ailispaw/barge
Vagrant failed to initialize at a very early stage:

The plugins failed to initialize correctly. This may be due to manual
modifications made within the Vagrant home directory. Vagrant can
attempt to automatically correct this issue by running:

  vagrant plugin repair

If Vagrant was recently updated, this error may be due to incompatible
versions of dependencies. To fix this problem please remove and re-install
all plugins. Vagrant can attempt to do this automatically by running:

  vagrant plugin expunge --reinstall

Error message given during initialization: Unable to resolve dependency: user requested 'vagrant-vbguest (> 0)'
```

いけたから virtualbox を選択して追加を実行
>|sh|
$ vagrant box add ailispaw/barge
==> box: Loading metadata for box 'ailispaw/barge'
    box: URL: https://atlas.hashicorp.com/ailispaw/barge
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.

1) veertu
2) virtualbox

Enter your choice: 2
==> box: Adding box 'ailispaw/barge' (v2.4.5) for provider: virtualbox
    box: Downloading: https://atlas.hashicorp.com/ailispaw/boxes/barge/versions/2.4.5/providers/virtualbox.box
==> box: Successfully added box 'ailispaw/barge' (v2.4.5) for 'virtualbox'!

できたから試しにイメージを作ってみて設定を少しいじって遊んでみる。

$ mkdir docker-host
$ cd !$
$ vagrant init -m ailispaw/barge
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

$ vim Vagrantfile

$ vagrant ssh

docker compose が欲しいから、とりあえず手動でインストールする。
素朴な発見として、/user/local/bin は無くて、/opt/bin にPATHが通ってるから、そこを使えってことぽい。

vagrant> wget -L https://github.com/docker/compose/releases/download/1.11.2/docker-compose-`uname -s`-`uname -m`
vagrant> chmod +x docker-compose-`uname -s`-`uname -m`
vagrant> sudo mv docker-compose-`uname -s`-`uname -m` /opt/bin/docker-compose
vagrant> sudo chown root:root /opt/bin/docker-compose

試しに vagrant で共有ディレクトリを設定しておいたプロジェクトの中で、docker-compose を使ってコンテナを作成して起動してみる。

vagrant> cd project
vagrant> docker-compose up -d --build

良い感じに動くし開発環境上の Docker より動作が早そうな感じ

vagrant> docker-compose exec php composer test

(蛇足)
良くわからないけど Clear-Screen が効かないので、無理やりキーバインド設定で解決してみた。
(あと、.bash_profile に『export HISTIGNORE='clear '』を入れておいた)

$ cat <<EOT > ~/.inputrc
> Control-l: "clear \C-m"
>
> EOT