homebrew-core/Formula/traefik.rb
2018-11-06 08:26:45 +01:00

68 lines
2 KiB
Ruby

class Traefik < Formula
desc "Modern reverse proxy"
homepage "https://traefik.io/"
url "https://github.com/containous/traefik/releases/download/v1.7.4/traefik-v1.7.4.src.tar.gz"
version "1.7.4"
sha256 "4d525114e815f821e2fac51b7798999428294050f2312830c387e198b527b5c0"
head "https://github.com/containous/traefik.git"
bottle do
cellar :any_skip_relocation
sha256 "7fa8e46b9025659aa44c3959b561721dff5ef89cdc470c073a5d2af0195b1280" => :mojave
sha256 "9d7eb709add65229b2785600f14c82fd9aa7e7a45ab97de09b6ea262994bcad3" => :high_sierra
sha256 "42d5b32d906583d1c4387f675c37f50084d2f5d23f6fcc25d2acbe0b1893a8d1" => :sierra
end
depends_on "go" => :build
depends_on "go-bindata" => :build
depends_on "node" => :build
depends_on "yarn" => :build
def install
ENV["GOPATH"] = buildpath
(buildpath/"src/github.com/containous/traefik").install buildpath.children
# Fix yarn + upath@1.0.4 incompatibility; remove once upath is upgraded to 1.0.5+
Pathname.new("#{ENV["HOME"]}/.yarnrc").write("ignore-engines true\n")
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