require 'erb' module Dockman module Dockify class SkeletonGenerator < Rails::Generators::NamedBase source_root File.expand_path('../templates', __FILE__) def copy_warehouse directory 'warehouse' end def copy_infra directory 'infra' if File.exist?('config/database.yml') File.rename('config/database.yml',"config/database.#{Time.now.to_i}.yml") end copy_file 'config/database.yml' end def copy_docker_related copy_file 'docker-compose.yml' copy_file 'docker-compose.dbs.yml' copy_file 'Dockerfile' copy_file 'docker-sync.yml' copy_file '.dockerignore' template 'envrc.erb', '.env.development' end def ignore_responsibly append_to_file '.gitignore' do <<-IGN /warehouse/ /.docker-sync/ /.envrc IGN end end def create_docker_volumes_and_networks system "docker volume create #{file_name}-web-sync" system "docker volume create #{file_name}-bundle-sync" system "docker network create #{file_name}-nginx-proxy" end end end end