diff --git a/.env.example b/.env.example index 3560f90e..54add52a 100644 --- a/.env.example +++ b/.env.example @@ -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 diff --git a/.template/addons/docker/.env.tt b/.template/addons/docker/.env.tt deleted file mode 100644 index 7be3e1c5..00000000 --- a/.template/addons/docker/.env.tt +++ /dev/null @@ -1,6 +0,0 @@ -DOCKER_REGISTRY_HOST=<%= DOCKER_REGISTRY_HOST %> -DOCKER_IMAGE=<%= DOCKER_IMAGE %> -BRANCH_TAG=latest -PORT=80 -CI=false -TEST_RETRY=0 diff --git a/.template/addons/docker/template.rb b/.template/addons/docker/template.rb index 18b65679..48ec7926 100644 --- a/.template/addons/docker/template.rb +++ b/.template/addons/docker/template.rb @@ -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 diff --git a/.template/hooks/before_complete/copy_env_example.rb b/.template/hooks/before_complete/copy_env_example.rb new file mode 100644 index 00000000..0e7aebab --- /dev/null +++ b/.template/hooks/before_complete/copy_env_example.rb @@ -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 diff --git a/.template/spec/base/template_spec.rb b/.template/spec/base/template_spec.rb index 05816e90..52d03f75 100644 --- a/.template/spec/base/template_spec.rb +++ b/.template/spec/base/template_spec.rb @@ -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 diff --git a/template.rb b/template.rb index 47a0fd2a..ed267ac1 100644 --- a/template.rb +++ b/template.rb @@ -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