Skip to content

Commit

Permalink
Add Dockerfile to project
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinreedy committed Mar 24, 2015
1 parent beb7184 commit 8e48f38
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.env
.env.test
.git
.rubocop.yml
.travis.yml
log/*
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ruby:2.0.0-p643

# Install deps
RUN apt-get update \
&& apt-get install -y libreadline-dev nano vim \
&& apt-get purge -y --auto-remove

# Ensure Gemfile.lock is up to date
RUN bundle config --global frozen 1

# Install latest released Napa to get baseline dependencies
RUN gem install napa

# Add a simple Procfile parser
ADD contrib/start.rb /start

# Create directory for app
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Copy Gemfile and Gemfile.lock and run bundle install
ONBUILD COPY Gemfile /usr/src/app/
ONBUILD COPY Gemfile.lock /usr/src/app/
ONBUILD RUN bundle install

# Copy rest of app
ONBUILD COPY . /usr/src/app

CMD ["/start", "web"]
19 changes: 19 additions & 0 deletions contrib/start.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/local/bin/ruby

require 'yaml'

# attempt to parse Procfile
begin
proc = YAML.load_file('Procfile')
command = proc[ARGV[0]]

if command
exec(command)
else
puts "Could not find #{ARGV[0]} in Procfile"
exit 1
end
rescue
puts 'Failed to parse Procfile'
exit 2
end

0 comments on commit 8e48f38

Please sign in to comment.