Skip to content

Commit

Permalink
Merge the .env from docker adddon with .env.example
Browse files Browse the repository at this point in the history
  • Loading branch information
malparty committed Apr 28, 2023
1 parent 01255e1 commit a50529d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Used to verify the integrity of signed cookies. so ensure a secure value is set
SECRET_KEY_BASE=replace_with_lengthy_secure_hex

PORT=80
REDIS_URL=redis://localhost:6379

# CI/CD
Expand Down
6 changes: 0 additions & 6 deletions .template/addons/docker/.env.tt

This file was deleted.

12 changes: 11 additions & 1 deletion .template/addons/docker/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,15 @@
template 'docker-compose.dev.yml.tt'
template 'docker-compose.test.yml.tt'
template 'docker-compose.yml.tt'
template '.env.tt'
template '.dockerignore.tt'

append_to_file '.env.example' do
<<~ENVEXAMPLE
# Docker
DOCKER_REGISTRY_HOST=#{DOCKER_REGISTRY_HOST}
DOCKER_IMAGE=#{DOCKER_IMAGE}
BRANCH_TAG=latest
PORT=80
ENVEXAMPLE
end
9 changes: 9 additions & 0 deletions .template/hooks/before_complete/copy_env_example.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

def copy_env_example
use_source_path __dir__

run 'cp .env.example .env'
end

copy_env_example
4 changes: 2 additions & 2 deletions .template/spec/base/template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
expect(file('.env.example')).to exist
end

it 'does NOT creates .env file' do
expect(file('.env')).not_to exist
it 'creates .env file' do
expect(file('.env')).to exist
end
end
3 changes: 3 additions & 0 deletions template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def apply_template!(template_root)
apply '.template/variants/web/template.rb' if WEB_VARIANT

# A list necessary jobs that run before complete, ex: Fixing rubocop on Ruby files that generated by Rails
# before_bundle
apply '.template/hooks/before_complete/copy_env_example.rb'
# after_bundle
apply '.template/hooks/before_complete/fix_rubocop.rb'
apply '.template/hooks/before_complete/report.rb'
end
Expand Down

0 comments on commit a50529d

Please sign in to comment.