Sha256: ef4ef30cf2904c1376a1fdad22b17ab7b3721840d010c488382baccc2b443359

Contents?: true

Size: 1.47 KB

Versions: 23

Compression:

Stored size: 1.47 KB

Contents

module Minke
  module Docker
    class DockerComposeFactory
      def initialize system_runner
        @system_runner = system_runner
      end

      def create compose_file
        Minke::Docker::DockerCompose.new compose_file, @system_runner
      end
    end

    class DockerCompose
      @compose_file = nil

      def initialize compose_file, system_runner
        @compose_file = compose_file
        @system_runner = system_runner
      end

      ##
      # start the containers in a stack defined by the docker compose file
      def up
        @system_runner.execute "docker-compose -f #{@compose_file} up -d"
        sleep 2
      end

      ##
      # stop the containers in a stack defined by the docker compose file
      def stop
        @system_runner.execute "docker-compose -f #{@compose_file} stop"
      end

      ##
      # remove the containers started in a stack defined by the docker compose file
      def rm
        @system_runner.execute "echo y | docker-compose -f #{@compose_file} rm -v" unless ::Docker.info["Driver"] == "btrfs"
      end

      ##
      # stream the logs for the current running stack
      def logs
        @system_runner.execute "docker-compose -f #{@compose_file} logs -f"
      end

      ##
      # return the local address and port of a containers private port
      def public_address container, private_port
        @system_runner.execute_and_return "docker-compose -f #{@compose_file} port #{container} #{private_port}"
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
minke-1.5.9 lib/minke/docker/docker_compose.rb
minke-1.5.8 lib/minke/docker/docker_compose.rb
minke-1.5.7 lib/minke/docker/docker_compose.rb
minke-1.5.6 lib/minke/docker/docker_compose.rb
minke-1.5.5 lib/minke/docker/docker_compose.rb
minke-1.5.4 lib/minke/docker/docker_compose.rb
minke-1.5.3 lib/minke/docker/docker_compose.rb
minke-1.5.2 lib/minke/docker/docker_compose.rb
minke-1.5.1 lib/minke/docker/docker_compose.rb
minke-1.5.0 lib/minke/docker/docker_compose.rb
minke-1.4.0 lib/minke/docker/docker_compose.rb
minke-1.3.0 lib/minke/docker/docker_compose.rb
minke-1.2.0 lib/minke/docker/docker_compose.rb
minke-1.1.0 lib/minke/docker/docker_compose.rb
minke-1.0.9 lib/minke/docker/docker_compose.rb
minke-1.0.8 lib/minke/docker/docker_compose.rb
minke-1.0.7 lib/minke/docker/docker_compose.rb
minke-1.0.6 lib/minke/docker/docker_compose.rb
minke-1.0.5 lib/minke/docker/docker_compose.rb
minke-1.0.4 lib/minke/docker/docker_compose.rb