Skip to content

Commit

Permalink
KBP-175 KBP-181 #time 2h fix environment variable definition and add …
Browse files Browse the repository at this point in the history
…sidekiq control in docker
  • Loading branch information
İsmail Akbudak committed Jan 8, 2018
1 parent dae9146 commit 1cd981c
Show file tree
Hide file tree
Showing 27 changed files with 70 additions and 53 deletions.
13 changes: 6 additions & 7 deletions lib/cybele/generators/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ def configure_mail_setting
say 'Setup mail settings'
build :configure_action_mailer
build :configure_smtp
build :setup_mailtrap
end

def gitignore_files_and_folders
Expand All @@ -242,12 +241,6 @@ def configure_error_pages
build :configure_error_pages
end

def docker_development_env
return if @options[:skip_docker]
say 'Setup docker development environment', :green
build :setup_docker_development_env
end

def setup_pronto_config
say 'Setup pronto config', :green
build :configure_pronto
Expand Down Expand Up @@ -281,6 +274,12 @@ def customize_optional_view_files
build :configure_basic_authentication
end

def docker_development_env
return if @options[:skip_docker]
say 'Setup docker development environment', :green
build :setup_docker_development_env
end

def setup_git_and_git_flow
say 'Initialize git and git flow'
build :git_and_git_flow_commands
Expand Down
26 changes: 19 additions & 7 deletions lib/cybele/helpers/docker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,31 @@ def setup_docker_development_env
template 'docker/start-app.sh.erb',
'bin/start-app.sh',
force: true
template 'docker/start-sidekiq.sh.erb',
'bin/start-sidekiq.sh',
force: true

unless @options[:skip_sidekiq]
template 'docker/start-sidekiq.sh.erb',
'bin/start-sidekiq.sh',
force: true
end
docker_dotenv_files
end

private

def docker_dotenv_files
append_file('env.sample', template_content('docker/docker_env_sample.erb'))
%w[local staging production].each do |env|
append_file(".env.#{env}", template_content("docker/docker_env_#{env}.erb"))
unless @options[:skip_sidekiq]
%w[.env.local env.sample].each do |env|
append_file(env, template_content('docker/docker_env_local_sample_sidekiq.erb'))
end
%w[staging production].each do |env|
append_file(".env.#{env}", template_content('docker/docker_env_staging_production_sidekiq.erb'))
end
end
append_file('env.sample', template_content('docker/docker_env_local_sample.erb'))
append_file('.env.local', template_content('docker/docker_env_local_sample.erb'))
unless @options[:skip_sidekiq]
%w[.env.local env.sample].each do |env|
append_file(env, template_content('docker/docker_env_local_sample_host.erb'))
end
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions lib/cybele/helpers/general.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ def force_ssl_setting
/# config.force_ssl = true/, "config.force_ssl = ENV['RAILS_FORCE_SSL'].present?"
gsub_file 'config/environments/staging.rb',
/# config.force_ssl = true/, "config.force_ssl = ENV['RAILS_FORCE_SSL'].present?"
append_file('.env.staging', template_content('ssl/ssl_env_staging.erb'))
append_file('.env.production', template_content('ssl/ssl_env_production.erb'))
%w[.env.local .env.production .env.staging env.sample].each do |env|
append_file(env, template_content('ssl/ssl_env_all.erb'))
end
end

def add_editor_config
Expand Down
9 changes: 4 additions & 5 deletions lib/cybele/helpers/mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ def configure_smtp
template_content('recipient_interceptor/recipient_interceptor_staging.rb.erb')
configure_environment 'production', template_content('mailer/smtp.rb.erb')
configure_environment 'staging', template_content('mailer/smtp.rb.erb')
append_template_to_file 'config/settings.yml', 'mailer/mailer_settings.yml.erb'
end

def setup_mailtrap
configure_environment 'development', template_content('mailer/smtp.rb.erb')
append_file('.env.local', "\n\n#{template_content('mailer/.env.local.erb')}")
append_template_to_file 'config/settings.yml', 'mailer/mailer_settings.yml.erb'
%w[.env.local .env.production .env.staging env.sample].each do |env|
append_file(env, template_content('mailer/.env.local.erb'))
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions templates/Gemfile.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ gem 'ransack', '~> 1.8', '>= 1.8.4'
# will_paginate
gem 'will_paginate', '~> 3.1', '>= 3.1.6'
gem 'will_paginate-bootstrap', '~> 1.0', '>= 1.0.1'
gem 'will-paginate-i18n', '~> 0.1.15'

# Excell export
gem 'to_xls', '~> 1.5', '>= 1.5.3'
Expand Down
7 changes: 7 additions & 0 deletions templates/README.md.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# <%= app_name.capitalize %>

# TODOs
- Change email sender domain address and basic_auth info in `config/settings.yml`
- Change email sender domain address in `config/initializers/devise.rb`
- Add your secret keys to `.env.local` file

<% unless @options[:skip_docker] %>
# Docker development
➜ ✗ docker-compose build
➜ ✗ docker-compose run app bundle
➜ ✗ docker-compose run app bundle exec rails db:create
➜ ✗ docker-compose run app bundle exec rails db:migrate
➜ ✗ docker-compose run app bundle exec rails db:seed
➜ ✗ docker-compose up
Look: localhost:3000 or lvh.me:3000
<% end %>
2 changes: 1 addition & 1 deletion templates/basic_authentication/no_basic_authentication.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

BASIC_AUTH_IS_ACTIVE=no
BASIC_AUTH_IS_ACTIVE=no
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

BASIC_AUTH_IS_ACTIVE=yes
BASIC_AUTH_IS_ACTIVE=yes
6 changes: 5 additions & 1 deletion templates/docker/docker-compose.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ services:
- "3000:3000"
links:
- postgres
<% unless @options[:skip_sidekiq] %>
- redis
<% end %>
volumes_from:
- box
box:
Expand All @@ -21,6 +23,7 @@ services:
image: postgres:9.5
ports:
- "5433:5432"
<% unless @options[:skip_sidekiq] %>
redis:
image: redis:3.2
env_file: ./.env.local
Expand All @@ -39,4 +42,5 @@ services:
links:
- postgres
- redis
command: bash ./bin/start-sidekiq.sh
command: bash ./bin/start-sidekiq.sh
<% end %>
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@


REDISTOGO_URL=redis://redis:6379/0

##### Docker compose environments

# Set Rails/Rack environment
RACK_ENV=development
POSTGRESQL_HOST=postgres
REDIS_HOST=redis
1 change: 1 addition & 0 deletions templates/docker/docker_env_local_sample_host.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REDIS_HOST=redis
2 changes: 2 additions & 0 deletions templates/docker/docker_env_local_sample_sidekiq.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

REDISTOGO_URL=redis://redis:6379/0
10 changes: 0 additions & 10 deletions templates/docker/docker_env_sample.erb

This file was deleted.

3 changes: 0 additions & 3 deletions templates/docker/docker_env_staging.erb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@


REDISTOGO_URL=
2 changes: 2 additions & 0 deletions templates/dotenv/.env.local.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ROOT_PATH=http://localhost:3000

SECRET_KEY_BASE=

ROLLBAR_ACCESS_TOKEN=
4 changes: 2 additions & 2 deletions templates/dotenv/.env.production.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ROOT_PATH=https://<%= app_name %>.herokuapp.com

ROLLBAR_ACCESS_TOKEN=

SECRET_KEY_BASE=

ROLLBAR_ACCESS_TOKEN=
4 changes: 2 additions & 2 deletions templates/dotenv/.env.staging.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ROOT_PATH=https://staging-<%= app_name %>.herokuapp.com

ROLLBAR_ACCESS_TOKEN=

SECRET_KEY_BASE=

ROLLBAR_ACCESS_TOKEN=
2 changes: 2 additions & 0 deletions templates/dotenv/env.sample.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ROOT_PATH=http://localhost:3000

SECRET_KEY_BASE=

ROLLBAR_ACCESS_TOKEN=
3 changes: 2 additions & 1 deletion templates/mailer/.env.local.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

# SMTP Get username and password from https://mailtrap.io
SMTP_USER_NAME=
SMTP_PASSWORD=
SMTP_PORT=2525
SMTP_ADDRESS=smtp.mailtrap.io
SMTP_AUTHENTICATION=cram_md5
SMTP_AUTHENTICATION=cram_md5
3 changes: 2 additions & 1 deletion templates/paperclip/paperclip_env_local.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

# S3 Settings
S3_BUCKET_NAME=<%= app_name %>-development
AWS_RAW_URL=<%= app_name %>-development.s3.amazonaws.com
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_SECRET_ACCESS_KEY=
3 changes: 2 additions & 1 deletion templates/paperclip/paperclip_env_production.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

# S3 Settings
S3_BUCKET_NAME=<%= app_name %>
AWS_RAW_URL=<%= app_name %>.s3.amazonaws.com
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_SECRET_ACCESS_KEY=
3 changes: 2 additions & 1 deletion templates/paperclip/paperclip_env_sample.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

# S3 Settings
S3_BUCKET_NAME=
AWS_RAW_URL=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_SECRET_ACCESS_KEY=
3 changes: 2 additions & 1 deletion templates/paperclip/paperclip_env_staging.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

# S3 Settings
S3_BUCKET_NAME=<%= app_name %>-staging
AWS_RAW_URL=<%= app_name %>-staging.s3.amazonaws.com
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_SECRET_ACCESS_KEY=
2 changes: 2 additions & 0 deletions templates/ssl/ssl_env_all.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

RAILS_FORCE_SSL=
1 change: 0 additions & 1 deletion templates/ssl/ssl_env_production.erb

This file was deleted.

1 change: 0 additions & 1 deletion templates/ssl/ssl_env_staging.erb

This file was deleted.

0 comments on commit 1cd981c

Please sign in to comment.