LoginSignup
5
5

More than 3 years have passed since last update.

(Docker + Sinatra)をAWS Elastic Beanstalkにデプロイ (デプロイ)

Last updated at Posted at 2015-02-08

準備

mkdir sinatra && cd sinatra

各種ファイルの用意

app.rb
require 'sinatra'
get '/' do
  'Hello Docker'
end
config.ru
require './app.rb'
run Sinatra::Application
Gemfile
source 'http://rubygems.org'
gem 'sinatra'
gem 'foreman'
gem 'thin'
Procfile
web: bundle exec rackup config.ru -p 4567 -s thin -o 0.0.0.0
Dockerfile
FROM rneuo/docker-centos-base
MAINTAINER rneuo

RUN useradd --create-home -s /bin/bash webapp
RUN echo -n 'webapp:webapp' | chpasswd

ADD Gemfile /home/webapp/
ADD app.rb /home/webapp/
ADD config.ru /home/webapp/
ADD Procfile /home/webapp/
RUN chown -R webapp /home/webapp

USER webapp
WORKDIR /home/webapp
RUN bundle install --path vendor/bundle

VOLUME ["/var/log"]
EXPOSE 4567
CMD bundle exec foreman start -d . -p 4567
  • rubyのインストールとかはベースのDockerイメージでやっています。
    • rneuo/docker-centos-base
Dockerrun.aws.json
{
  "AWSEBDockerrunVersion": "1",
  "Image": {
    "Name": "sinatra",
    "Update": "true"
  },
  "Ports": [
    {
      "ContainerPort": "4567"
    }
  ],
  "Logging": "/var/log/"
}

コミット & プッシュ

git init 
git add .
git commit -a -m "add sinatra"
git aws.push
5
5
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
5
5