Class: WSlaveDocker

Inherits:
Object
  • Object
show all
Defined in:
lib/wslave_docker.rb

Instance Method Summary collapse

Constructor Details

#initializeWSlaveDocker

Returns a new instance of WSlaveDocker.



5
6
7
# File 'lib/wslave_docker.rb', line 5

def initialize
  puts 'Initializing WSlave Docker Control'
end

Instance Method Details

#_checkObject



23
24
25
26
27
28
29
# File 'lib/wslave_docker.rb', line 23

def _check()
  return true if (File.exist?("./config/.wslave") &&
                  File.exist?("Dockerfile") &&
                  File.exist?("docker-compose.yml"))
  puts "This does not appear to be the root of a WSlave managed app."
  false
end

#_force_downObject



31
32
33
# File 'lib/wslave_docker.rb', line 31

def _force_down()
  `docker-compose down --remove-orphans`
end

#_unfuck_dot_htaccessObject

Sometimes the docker container or a windows fs will screw up or delete .htaccess



36
37
38
39
40
41
42
43
# File 'lib/wslave_docker.rb', line 36

def _unfuck_dot_htaccess()
  begin
    FileUtils.cp_r("#{__dir__}/../base/public/.htaccess", "./public/.htaccess")
    # FileUtils.chmod(0444, "./public/.htaccess")
  rescue => e
    # noop
  end
end

#server(force) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/wslave_docker.rb', line 9

def server(force)
  return unless _check()
  _force_down() if force
  _unfuck_dot_htaccess()
  WSlaveTools.set_dev_perms
  `docker-compose up -d`
end

#stop(force, volume) ⇒ Object



17
18
19
20
21
# File 'lib/wslave_docker.rb', line 17

def stop(force, volume)
  return unless _check()
  _force_down() if force
  `docker-compose down#{volume ? ' -v' : ''}`
end