Class: Dockerify::Runner
- Inherits:
-
Object
- Object
- Dockerify::Runner
- Defined in:
- lib/dockerify/dockerify.rb
Constant Summary collapse
- DOCKERIFY_CONFIGS =
[ { filename: 'Dockerfile', default_args: { passenger_ruby_version: 'ruby22', passenger_container_version: 'latest', passenger_port_number: '80', passenger_app_path: '/home/app/webapp' } }, { filename: 'docker-compose.yml', default_args: { docker_compose_port: '80', docker_compose_database_image: 'postgres' } }, { filename: '.env', default_args: { env_secret_key_base: 'TODO' } }, { filename: 'rails-env.conf', default_args: {} } ].freeze
Instance Method Summary collapse
Instance Method Details
#build(path) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/dockerify/dockerify.rb', line 36 def build(path) absolute_path = full_path(path) DOCKERIFY_CONFIGS.map do |dockerify_config| file_path = "#{absolute_path}/#{dockerify_config[:filename]}" if File.exists?(file_path) puts "Skipping #{file_path}. File already exists" next end raw_template = load_template(dockerify_config[:filename]) erb_args = dockerify_config[:default_args].merge({}) rendered_template = render_erb(raw_template, erb_args) write_file(file_path, rendered_template) "Creating #{dockerify_config[:filename]} etc in #{file_path}" end end |
#remove(path) ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/dockerify/dockerify.rb', line 56 def remove(path) absolute_path = full_path(path) DOCKERIFY_CONFIGS.map do |dockerify_config| file_path = "#{absolute_path}/#{dockerify_config[:filename]}" next unless File.exists?(file_path) File.delete(file_path) "Deleting #{dockerify_config[:filename]} etc in #{file_path}" end end |