From 502b55cde15d0d1844aa00285457d3880e4facca Mon Sep 17 00:00:00 2001 From: Ben Parees Date: Thu, 30 Oct 2014 21:36:25 -0400 Subject: [PATCH] fix up db configuration --- Dockerfile | 7 +++++++ sinatra_app/app.rb | 2 +- sinatra_app/config/database.yml | 2 +- sinatra_app/config/environments.rb | 2 +- sinatra_app/start.rb | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0ff08ba5ba..c4a201ad2a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,13 @@ FROM openshift/ruby-20-centos RUN gem install sinatra sinatra-activerecord mysql2 --no-ri --no-rdoc ADD sinatra_app /tmp/ + +USER root + +RUN chown -R ruby:ruby /tmp/* + +USER ruby + WORKDIR /tmp/ EXPOSE 8080 diff --git a/sinatra_app/app.rb b/sinatra_app/app.rb index 15e7967f06..c9e73c4b06 100644 --- a/sinatra_app/app.rb +++ b/sinatra_app/app.rb @@ -3,7 +3,7 @@ require_relative 'models' set :bind, '0.0.0.0' -set :port, ENV["FRONTEND_SERVICE_PORT"] +set :port, 8080 get '/' do Timestamp.create(date: Time.now, text: "This is a message from a database query. The last insertion in the database was at") diff --git a/sinatra_app/config/database.yml b/sinatra_app/config/database.yml index 2dbb81ccd5..205d85bf96 100644 --- a/sinatra_app/config/database.yml +++ b/sinatra_app/config/database.yml @@ -3,5 +3,5 @@ development: database: <%= ENV["MYSQL_DATABASE"] %> username: root password: <%= ENV['MYSQL_ROOT_PASSWORD'] %> - host: <%= ENV["DATABASE_SERVICE_IP_ADDR"] %> + host: <%= ENV["DATABASE_SERVICE_HOST"] %> port: <%= ENV["DATABASE_SERVICE_PORT"] %> diff --git a/sinatra_app/config/environments.rb b/sinatra_app/config/environments.rb index 575a6f2d4c..477865c908 100644 --- a/sinatra_app/config/environments.rb +++ b/sinatra_app/config/environments.rb @@ -4,7 +4,7 @@ def self.connect_to_database begin ActiveRecord::Base.establish_connection( :adapter => "mysql2", - :host => "#{ENV["DATABASE_SERVICE_IP_ADDR"]}", + :host => "#{ENV["DATABASE_SERVICE_HOST"]}", :port => "#{ENV["DATABASE_SERVICE_PORT"]}", :database => "#{ENV["MYSQL_DATABASE"]}", :password => "#{ENV["MYSQL_ROOT_PASSWORD"]}" diff --git a/sinatra_app/start.rb b/sinatra_app/start.rb index 8f54d0355e..cc3f8135c6 100644 --- a/sinatra_app/start.rb +++ b/sinatra_app/start.rb @@ -3,4 +3,4 @@ puts "Run migrations..." %x"rake db:migrate" puts "Run app..." -%x"ruby app.rb &>/dev/null &" +%x"ruby app.rb &" \ No newline at end of file