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 0757d3f
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
11 changes: 11 additions & 0 deletions .template/hooks/before_complete/copy_env_example.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

def copy_env_example
after_bundle do
use_source_path __dir__

run 'cp .env.example .env'
end
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
1 change: 1 addition & 0 deletions template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def apply_template!(template_root)

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

Expand Down

0 comments on commit 0757d3f

Please sign in to comment.