77 lines
2.2 KiB
Ruby
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.4.4/traefik-v1.4.4.src.tar.gz"
|
|
version "1.4.4"
|
|
sha256 "8fb8b986dd6e79a3d474904fe6524cd04b6c3247f1f42c992019532d48049561"
|
|
head "https://github.com/containous/traefik.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "8a231d9a5863be58f66bed95ed87d5285f071b552986f4d87e25a4b7f050c604" => :high_sierra
|
|
sha256 "141f1dc28a29f85467832a46e796519cfd6cacadf8bff0629d1e10c69b42cc7e" => :sierra
|
|
sha256 "f0e2e8f1cd31c64f562423ffcb482aa77412270c178441dd230f28ffcef4927b" => :el_capitan
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
depends_on "node" => :build
|
|
depends_on "yarn" => :build
|
|
|
|
go_resource "github.com/jteeuwen/go-bindata" do
|
|
url "https://github.com/jteeuwen/go-bindata.git",
|
|
:revision => "a0ff2567cfb70903282db057e799fd826784d41d"
|
|
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/jteeuwen/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
|