Sha256: 6204ff1c0d066d4415fb603c1ec4a63a666cc70fdeeb1bfd281c11fd82fc264b

Contents?: true

Size: 1.49 KB

Versions: 34

Compression:

Stored size: 1.49 KB

Contents

module Workarea
  class DockerGenerator < Rails::Generators::Base
    source_root File.expand_path('../templates', __FILE__)
    desc File.read(File.expand_path('../USAGE', __FILE__))

    class_option 'webpack',
      type: :boolean,
      aliases: '-W',
      desc: 'include configuration for webpack/yarn'
    class_option 'sync',
      type: :boolean,
      aliases: '-S',
      desc: 'include configuration for docker-sync'

    def create_dockerfile
      template('Dockerfile.erb', 'Dockerfile')
      template('docker-entrypoint.sh.erb', 'docker-entrypoint.sh')
      template('docker-wait.sh', 'docker-wait.sh')
    end

    def create_docker_compose
      template('docker-compose.yml.erb', 'docker-compose.yml')
    end

    def create_docker_environment_files
      template('docker.env', 'docker.env')
      template('.env.erb', '.env')
    end

    def create_docker_initializer
      template('docker_init.rb.erb', 'config/initializers/z_docker.rb')
    end

    def create_docker_sync
      return unless include_docker_sync?
      template('docker-sync.yml.erb', 'docker-sync.yml')
    end

    def update_gitignore
      append_file '.gitignore', "\n\n# Ignore docker caches\ndocker"

      if include_docker_sync?
        append_file '.gitignore', "\n.docker-sync"
      end
    end

    private

    def app_name
      @app_name ||= Rails.root.to_s.split('/').last
    end

    def include_webpack?
      !!options['webpack']
    end

    def include_docker_sync?
      !!options['sync']
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-core-3.4.45 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.44 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.43 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.42 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.41 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.40 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.39 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.38 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.37 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.36 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.35 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.34 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.33 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.32 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.31 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.30 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.29 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.28 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.27 lib/generators/workarea/docker/docker_generator.rb
workarea-core-3.4.26 lib/generators/workarea/docker/docker_generator.rb