LoginSignup
20
21

More than 5 years have passed since last update.

otto で開発環境構築

Posted at

ottoとは

簡単にいうとvagrantの後継で、
開発者がインフラ環境構築の知識を必要とせずに
開発環境、本番環境の構築を各言語のデファクトスタンダートに合わせて自動で構築を行ってくれるツール
サービスを動かす環境は言語によって大体同じであり、
セキュリティを意識して構築することは面倒で難しい。
それをottoは楽に実現する。と言っている。
https://www.hashicorp.com/blog/otto.html

DL-インストール

https://ottoproject.io/downloads.html
上記から自身の環境にあったバイナリをDL
zipを解凍。

解凍したディレクトリでコマンドを実行

export PATH=$PATH:`pwd`
お試しなのでこれで。

sample環境を構築してみる

git clone https://github.com/hashicorp/otto-getting-started.git
cd otto-getting-started
otto compile
==> Loading Appfile...
==> No Appfile found! Detecting project information...
    No Appfile was found. If there is no Appfile, Otto will do its best
    to detect the type of application this is and set reasonable defaults.
    This is a good way to get started with Otto, but over time we recommend
    writing a real Appfile since this will allow more complex customizations,
    the ability to reference dependencies, versioning, and more.
==> Fetching all Appfile dependencies...
==> Compiling...
    Application:    otto-getting-started (ruby)
    Project:        otto-getting-started
    Infrastructure: aws (simple)

    Compiling infra...
    Compiling foundation: consul
==> Compiling main application...
==> Compilation success!
    This means that Otto is now ready to start a development environment,
    deploy this application, build the supporting infastructure, and
    more. See the help for more information.

    Supporting files to enable Otto to manage your application from
    development to deployment have been placed in the output directory.
    These files can be manually inspected to determine what Otto will do.

Appfileが見つからないので、
いい感じにプロジェクト構成を元に環境を作るよ。とのこと。
Appfileで自分で設定することにより、より詳細に環境を構築できるのだと思います。

Otto detected the application is a Ruby application and automatically built us an environment tailored to Ruby development.

Rubyであることを検出してそれに合わせて構築すると言っています。

otto dev

を実行。

Would you like Otto to install Vagrant?
  An older version of vagrant was found installed (1.6.5). Otto requires
  version 1.7.4 or higher. Otto can install the latest version of vagrant
  for you (1.7.4). Would you like Otto to update vagrant for you?

  Please enter 'yes' to continue. Any other value will exit.

  Enter a value: 

vagrantが古かった為、置き換えるか聞かれています。
yes を入力します。

==> Vagrant installed successfully!
==> Caching SSH credentials from Vagrant...
==> Development environment successfully created!
    IP address: 172.16.1.162

    A development environment has been created for writing a generic
    Ruby-based app.

    Ruby is pre-installed. To work on your project, edit files locally on your
    own machine. The file changes will be synced to the development environment.

    When you're ready to build your project, run 'otto dev ssh' to enter
    the development environment. You'll be placed directly into the working
    directory where you can run 'bundle' and 'ruby' as you normally would.

    You can access any running web application using the IP above.

省略しています。

開発環境用のvmが立ち上がりました。

otto dev ssh でログインできます。

bundle && rackup --host 0.0.0.0 のコマンドでアプリを立ち上げます。

以下のURLにアクセスできるようになります。
http://172.16.1.162:9292/

環境について

vagrant@precise64:/vagrant$ ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux-gnu]

Rubyのverは最新の模様
自動でインストールされるversionが最新にどれだけ追いつくのかはわかりませんが、
versionの指定が必要がなく単純に開発環境を作りたいのであれば非常に楽に構築できることがわかりました。

ファイル編集について

otto devを行ったディレクトリが、vm上の /vagrant と共有されているため
開発はローカルのファイルに対して修正を行えばよい。
/vagrantが共有なのは、vagrantと同様。

他の機能について

今回は開発環境の構築でしたが、
aws等にdeployする機能もあるため、
そちらは随時触っていきます。

20
21
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
21