Class: DockerComposeDeploy::Actions::Skeleton

Inherits:
Struct
  • Object
show all
Defined in:
lib/docker_compose_deploy/actions/skeleton.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



3
4
5
# File 'lib/docker_compose_deploy/actions/skeleton.rb', line 3

def name
  @name
end

#shellObject

Returns the value of attribute shell

Returns:

  • (Object)

    the current value of shell



3
4
5
# File 'lib/docker_compose_deploy/actions/skeleton.rb', line 3

def shell
  @shell
end

Instance Method Details

#createObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/docker_compose_deploy/actions/skeleton.rb', line 5

def create
  shell.notify("Creating new skeleton")
  if File.exist?(name)
    shell.warn("Directory or file: '#{name}' already exists. Exiting.")
    exit(1)
  end

  begin
    Dir.mkdir(name)
    Dir.rmdir(name)
  rescue
    shell.warn("Unable to make directory '#{name}'. Is it a valid directory name? Exiting.")
  end

  template_path = File.expand_path(File.join(__dir__, "../../../template"))
  FileUtils.cp_r(template_path, name)
  shell.notify("Created skeleton app in '#{name}'.")
  shell.puts <<-MESSAGE
To see the skeleton app in action, run the following commands

# Move into the directory
1. cd #{name}

# Use vagrant to create the virtual machine for testing (it will open a window and will display Ubuntu's desktop)
2. vagrant up

# Install docker and docker-compose on the vagrant machine
3. dcd provision

# Deploy the skeleton app to the vagrant machine
4. dcd deploy

# See the server in action:
5. Open firefox on the vagrant machine and visit http://www.test
  MESSAGE
end