module Kubes::Compiler::Dsl::Core::Helpers

Public Instance Methods

dockerfile_port() click to toggle source
# File lib/kubes/compiler/dsl/core/helpers.rb, line 3
def dockerfile_port
  path = "#{Kubes.root}/Dockerfile"
  File.exist?(path) ? parse_for_dockerfile_port(path) : 80
end

Private Instance Methods

parse_for_dockerfile_port(path) click to toggle source
# File lib/kubes/compiler/dsl/core/helpers.rb, line 9
def parse_for_dockerfile_port(path)
  lines = IO.read(path).split("\n")
  expose_line = lines.find { |l| l =~ /^EXPOSE / }
  if expose_line
    md = expose_line.match(/EXPOSE (\d+)/)
    port = md[1] if md
  end
  port ? port.to_i : 80
end