From 9e9855f762ae14f827c4baa9c43db6256c2f992c Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Thu, 9 Oct 2014 15:08:37 +0200 Subject: [PATCH] docker changes and user authenticated message --- .dockerignore | 1 + Dockerfile | 5 ++++- Gemfile | 1 + Gemfile.lock | 13 ++++++++++--- Procfile | 6 +++--- Procfile.dev | 7 +++++++ app/assets/javascripts/user/app/app.js.coffee | 4 +++- bin/development_build | 4 ++++ bin/drb_counter.rb | 2 ++ config/couchdb.yml | 8 ++++---- config/locales/user.en.yml | 1 + config/locales/user.nl.yml | 1 + 12 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 Procfile.dev create mode 100755 bin/development_build diff --git a/.dockerignore b/.dockerignore index ef620fed..168aaa24 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,3 +3,4 @@ log tmp coverage public/system +.git diff --git a/Dockerfile b/Dockerfile index 0aa7150f..879d74ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ ADD Gemfile.lock /var/www/ RUN chown -R web:web /var/www &&\ mkdir -p /var/bundle &&\ chown -R web:web /var/bundle -RUN su -c "cd /var/www && bundle install --deployment --without development test --path /var/bundle" -s /bin/bash -l web +RUN su -c "cd /var/www && bundle install --deployment --without development test assets --path /var/bundle" -s /bin/bash -l web # Add application source ADD . /var/www @@ -21,4 +21,7 @@ USER web WORKDIR /var/www +#VOLUME ['/Users/bterkuile/companytools/development/rails/mozo_bar/public/system:/var/www/public/system'] +EXPOSE 3000 + CMD ["bundle", "exec", "foreman", "start"] diff --git a/Gemfile b/Gemfile index 3c23bba5..fe04c431 100644 --- a/Gemfile +++ b/Gemfile @@ -113,6 +113,7 @@ end # Use unicorn as the app server # gem 'unicorn' +gem 'foreman' # Deploy with Capistrano # gem 'capistrano' diff --git a/Gemfile.lock b/Gemfile.lock index de99b66a..03fc7611 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -149,6 +149,9 @@ GEM debug_inspector (0.0.2) diff-lcs (1.2.5) docile (1.1.5) + dotenv (0.11.1) + dotenv-deployment (~> 0.0.2) + dotenv-deployment (0.0.2) em-http-request (1.1.2) addressable (>= 2.3.4) cookiejar @@ -194,11 +197,14 @@ GEM multi_json (>= 1.0.0) rack (>= 1.0.0) websocket-driver (>= 0.3.0) - faye-websocket (0.7.4) + faye-websocket (0.7.5) eventmachine (>= 0.12.0) - websocket-driver (>= 0.3.1) + websocket-driver (>= 0.3.5) font-awesome-rails (4.2.0.0) railties (>= 3.2, < 5.0) + foreman (0.75.0) + dotenv (~> 0.11.1) + thor (~> 0.19.1) foundation-rails (5.4.5.0) railties (>= 3.1.0) sass (>= 3.2.0) @@ -409,7 +415,7 @@ GEM binding_of_caller (= 0.7.3.pre1) railties (~> 4.0) sprockets-rails (>= 2.0, < 4.0) - websocket-driver (0.3.4) + websocket-driver (0.3.5) xpath (2.0.0) nokogiri (~> 1.3) @@ -436,6 +442,7 @@ DEPENDENCIES factory_girl_rails faye font-awesome-rails + foreman foundation-rails fuubar iso_country_codes diff --git a/Procfile b/Procfile index f6232277..20e7e41f 100644 --- a/Procfile +++ b/Procfile @@ -1,7 +1,7 @@ #web: bundle exec thin start -p $PORT -faye: thin start -R faye/config.ru -p 9296 --pid tmp/pids/faye.pid +#faye: thin start -R faye/config.ru -p 9296 --pid tmp/pids/faye.pid # database: echo "BuenosAires" | sudo -S couchdb start | ~/bin/couch_output # production: faye: thin start -d -R faye/config.ru -p 9296 -counters: bin/drb_counter.rb run -- development +#counters: bin/drb_counter.rb run -- development # production: conters: bin/drb_counter.rb start -#server: rails s +server: bundle exec rails s -e production diff --git a/Procfile.dev b/Procfile.dev new file mode 100644 index 00000000..f6232277 --- /dev/null +++ b/Procfile.dev @@ -0,0 +1,7 @@ +#web: bundle exec thin start -p $PORT +faye: thin start -R faye/config.ru -p 9296 --pid tmp/pids/faye.pid +# database: echo "BuenosAires" | sudo -S couchdb start | ~/bin/couch_output +# production: faye: thin start -d -R faye/config.ru -p 9296 +counters: bin/drb_counter.rb run -- development +# production: conters: bin/drb_counter.rb start +#server: rails s diff --git a/app/assets/javascripts/user/app/app.js.coffee b/app/assets/javascripts/user/app/app.js.coffee index 51e9c75c..1431a02f 100644 --- a/app/assets/javascripts/user/app/app.js.coffee +++ b/app/assets/javascripts/user/app/app.js.coffee @@ -23,7 +23,9 @@ handleAuthInfo: (user_id, auth_token)-> Qstorage.setItem 'user_id', user_id Qstorage.setItem 'auth_token', auth_token - @__container__.lookup('controller:application').setCurrentList() + controller = @__container__.lookup('controller:application') + controller.setCurrentList() + controller.set 'notice', t('messages.authenticated') App.deferReadiness() Ember.$.ajaxPrefilter (options) -> if options.type.toUpperCase() == 'GET' diff --git a/bin/development_build b/bin/development_build new file mode 100755 index 00000000..5f9552d4 --- /dev/null +++ b/bin/development_build @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +def run(script); `#{script}` end + +run "docker build -t bterkuile/mozo-rails ." diff --git a/bin/drb_counter.rb b/bin/drb_counter.rb index ae2b38b2..7c1e6c00 100755 --- a/bin/drb_counter.rb +++ b/bin/drb_counter.rb @@ -68,6 +68,8 @@ class InMemoryQCounter end end end + rescue RestClient::ResourceNotFound + # view not available, initialize as zero rescue => e raise e end diff --git a/config/couchdb.yml b/config/couchdb.yml index 911a80a8..a213291e 100644 --- a/config/couchdb.yml +++ b/config/couchdb.yml @@ -1,16 +1,16 @@ development: validation_framework: :active_model #optional - #database: qwaiter_development - database: "http://mozo:secret@localhost:5984/qwaiter_development" + #database: "http://mozo:secret@localhost:5984/qwaiter_development" + database: mozo_development test: validation_framework: :active_model #optional #database: "http://mozo:secret@localhost:5984/qwaiter_test" #Testing can only be done as couchdb admin, since it requires creating and destroying the database - database: "qwaiter_test" + database: "mozo_test" # database: "http://admin:secret@localhost:5984/qwaiter_test" production: validation_framework: :active_model #optional database: qwaiter user_app: validation_framework: :active_model #optional - database: qwaiter_development + database: mozo_development diff --git a/config/locales/user.en.yml b/config/locales/user.en.yml index 1be4d253..11651e22 100644 --- a/config/locales/user.en.yml +++ b/config/locales/user.en.yml @@ -20,6 +20,7 @@ en: unknown_supplier_name: unknown unauthorized: Unauthorized action detected order_could_not_be_processed: 'The order could not be processed' + authenticated: Successfully authenticated active_list: title: Active list diff --git a/config/locales/user.nl.yml b/config/locales/user.nl.yml index 15963b13..637e49a1 100644 --- a/config/locales/user.nl.yml +++ b/config/locales/user.nl.yml @@ -20,6 +20,7 @@ nl: unknown_supplier_name: onbekend unauthorized: Niet toegestane actie order_could_not_be_processed: 'De bestelling kan niet worden uitgevoerd' + authenticated: Succesvolle login active_list: title: Actieve lijst needs_payment: Rekening vragen!