class WSlaveDocker
Public Class Methods
new()
click to toggle source
# File lib/wslave_docker.rb, line 5 def initialize puts 'Initializing WSlave Docker Control' end
Public Instance Methods
_check()
click to toggle source
# File lib/wslave_docker.rb, line 75 def _check() return true if (File.exist?("./config/.wslave") && File.exist?("docker-compose.yml")) puts "This does not appear to be the root of a WSlave managed app." false end
_force_down()
click to toggle source
# File lib/wslave_docker.rb, line 82 def _force_down() `docker-compose down --remove-orphans` end
_unfuck_dot_htaccess()
click to toggle source
Sometimes the docker container or a windows fs will screw up or delete .htaccess
# File lib/wslave_docker.rb, line 87 def _unfuck_dot_htaccess() begin FileUtils.cp_r("#{__dir__}/../base/public/.htaccess", "./public/.htaccess") # FileUtils.chmod(0444, "./public/.htaccess") rescue => e # noop end end
console()
click to toggle source
# File lib/wslave_docker.rb, line 70 def console() return unless _check() system("docker-compose exec web /bin/bash") end
log()
click to toggle source
# File lib/wslave_docker.rb, line 60 def log() return unless _check() begin system("docker-compose logs -f") rescue Exception => e puts "\n\nEnding log trace. NOTE: Server containers are still running!\n\n" return end end
remove(force = false)
click to toggle source
# File lib/wslave_docker.rb, line 54 def remove(force = false) return unless _check() _force_down() if force `docker-compose down -v` end
reset(force = false)
click to toggle source
# File lib/wslave_docker.rb, line 46 def reset(force = false) return unless _check() _force_down() if force `docker-compose down -v` `docker-compose build` `docker-compose up -d` end
server(command = :start, force = false)
click to toggle source
# File lib/wslave_docker.rb, line 9 def server(command = :start, force = false) case (command) when :start start(force) when :stop stop(force) when :reset reset(force) when :remove remove(force) when :log log() when :console console() else puts "server subcommand \"#{command.to_s}\" not found." puts "Available commands: start stop log console" end end
start(force = false)
click to toggle source
# File lib/wslave_docker.rb, line 29 def start(force = false) return unless _check() _force_down() if force `docker-compose stop` # Shutdown existing instances _unfuck_dot_htaccess() WSlaveTools.set_dev_perms `docker-compose build` `docker-compose start -d` `docker-compose up -d` end
stop(force = false)
click to toggle source
# File lib/wslave_docker.rb, line 40 def stop(force = false) return unless _check() _force_down() if force `docker-compose stop` end