Skip to content

Commit

Permalink
Merge pull request #1216 from transitland/docker-production
Browse files Browse the repository at this point in the history
Docker improvements
  • Loading branch information
irees committed Jan 12, 2018
2 parents ea7a682 + fd02070 commit 17f29c9
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git
.dockerignore
22 changes: 18 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
FROM ruby:2.3.1

# Install essentials
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev postgresql-client libgeos-dev

# Setup /app
RUN mkdir /app
WORKDIR /app
ADD . /app
RUN gem install bundler -v 1.12.5
ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock

# Install bundler
RUN gem install bundler -v 1.16.1

# Install gems
COPY components /app/components
COPY Gemfile /app/Gemfile
COPY Gemfile.lock /app/Gemfile.lock
RUN bundle install

# Install application
COPY . /app

# Run
CMD bundle exec puma -C config/puma.rb
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ gem 'marginalia', group: [:development, :staging]

# web server
gem 'unicorn', group: [:staging, :production]
gem 'puma'

# profiling
gem 'memory_profiler', group: [:test, :development]
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ GEM
binding_of_caller (>= 0.7)
pry (>= 0.9.11)
public_suffix (3.0.1)
puma (3.11.0)
rack (1.6.8)
rack-cors (1.0.2)
rack-protection (1.5.3)
Expand Down Expand Up @@ -852,6 +853,7 @@ DEPENDENCIES
pry-rails
pry-rescue
pry-stack_explorer
puma
rack-cors
rails (= 4.2.10)
rails-erd
Expand Down Expand Up @@ -880,4 +882,4 @@ DEPENDENCIES
whenever

BUNDLED WITH
1.15.4
1.16.1
10 changes: 0 additions & 10 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,3 @@ test:
- RAILS_ENV=test bundle exec rspec -r rspec_junit_formatter --format RspecJunitFormatter -o $CIRCLE_TEST_REPORTS/rspec/junit.xml
- mkdir -p $CIRCLE_ARTIFACTS/profiling
- RAILS_ENV=test bundle exec rake profile:import:nycdot[$CIRCLE_ARTIFACTS/profiling]

deployment:
staging:
branch: master
commands:
- ./deploy/env.rb staging
production:
branch: production
commands:
- ./deploy/env.rb prod
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def self.base_url_options

# use Mandrill to send e-mail
config.action_mailer.smtp_settings = {
address: "smtp.mandrillapp.com",
address: "smtp.sparkpostmail.com",
port: 587,
enable_starttls_auto: true,
user_name: Figaro.env.mandrill_user_name,
Expand Down
4 changes: 4 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
config.logstasher.enabled = true
Sidekiq.logger.formatter = Sidekiq::Logging::Json::Logger.new

if ENV["RAILS_LOG_TO_STDOUT"].present?
config.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
end

# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]

Expand Down
11 changes: 11 additions & 0 deletions config/puma.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env puma
port ENV.fetch("PORT") { 3000 }
environment ENV.fetch("RAILS_ENV") { "development" }

# Preload app
preload_app!

# Configure connections
on_worker_boot do
ActiveRecord::Base.establish_connection
end

0 comments on commit 17f29c9

Please sign in to comment.