homebrew-core/Formula/traefik.rb
2018-02-12 08:38:33 -08:00

77 lines
2.2 KiB
Ruby

require "language/go"
class Traefik < Formula
desc "Modern reverse proxy"
homepage "https://traefik.io/"
url "https://github.com/containous/traefik/releases/download/v1.5.2/traefik-v1.5.2.src.tar.gz"
version "1.5.2"
sha256 "c8a053717593d764318abc9b79736cd9407ce0db770760d4e4a25df6bf33b915"
head "https://github.com/containous/traefik.git"
bottle do
cellar :any_skip_relocation
sha256 "dbe14444abd1e0df4d6a1c1726cbf2b227540626dc1001c28e9941385f207bff" => :high_sierra
sha256 "4fe3d376b4ca335d47ebc5350456fbeb5d905acdae87b7f942d2d4226fe3ce9c" => :sierra
sha256 "4e783f44ed089612dc4cc3aedf4b6bb419ce19e0400d5f4e4ee5b6fa97f96c36" => :el_capitan
end
depends_on "go" => :build
depends_on "node" => :build
depends_on "yarn" => :build
go_resource "github.com/containous/go-bindata" do
url "https://github.com/containous/go-bindata.git",
:revision => "e237f24c9fab3ae0ed95bf04e3699e92c2a41283"
end
def install
ENV["GOPATH"] = buildpath
(buildpath/"src/github.com/containous/traefik").install buildpath.children
ENV.prepend_create_path "PATH", buildpath/"bin"
Language::Go.stage_deps resources, buildpath/"src"
cd "src/github.com/containous/go-bindata/go-bindata" do
system "go", "install"
end
cd "src/github.com/containous/traefik" do
cd "webui" do
system "yarn", "install"
system "yarn", "run", "build"
end
system "go", "generate"
system "go", "build", "-o", bin/"traefik", "./cmd/traefik"
prefix.install_metafiles
end
end
test do
require "socket"
web_server = TCPServer.new(0)
http_server = TCPServer.new(0)
web_port = web_server.addr[1]
http_port = http_server.addr[1]
web_server.close
http_server.close
(testpath/"traefik.toml").write <<~EOS
[web]
address = ":#{web_port}"
[entryPoints.http]
address = ":#{http_port}"
EOS
begin
pid = fork do
exec bin/"traefik", "--configfile=#{testpath}/traefik.toml"
end
sleep 5
cmd = "curl -sIm3 -XGET http://localhost:#{web_port}/dashboard/"
assert_match /200 OK/m, shell_output(cmd)
ensure
Process.kill("HUP", pid)
end
end
end