101 lines
2.9 KiB
Ruby
101 lines
2.9 KiB
Ruby
class Traefik < Formula
|
|
desc "Modern reverse proxy"
|
|
homepage "https://traefik.io/"
|
|
url "https://github.com/containous/traefik/releases/download/v1.7.11/traefik-v1.7.11.src.tar.gz"
|
|
version "1.7.11"
|
|
sha256 "b6ef9ecfebdd6bcb998de17276ef9af3174a3c6f78e1198ed7b8ac2f3f9d0168"
|
|
head "https://github.com/containous/traefik.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "041bbf550c9be38e2d0be287022b26f21d9c841bfd021933b06d970456e59400" => :mojave
|
|
sha256 "4bb4f435d04af07e2a86b06f9efae19cc3970765e1a0bcb308fd77cf680d363b" => :high_sierra
|
|
sha256 "8cdcca676468851fb0254ba3cc422fcb80a540efe46bb73855708a27433aa88f" => :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
|
|
|
|
plist_options :manual => "traefik"
|
|
|
|
def plist
|
|
<<~EOS
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>KeepAlive</key>
|
|
<false/>
|
|
<key>Label</key>
|
|
<string>#{plist_name}</string>
|
|
<key>ProgramArguments</key>
|
|
<array>
|
|
<string>#{opt_bin}/traefik</string>
|
|
<string>--configfile=#{etc/"traefik/traefik.toml"}</string>
|
|
</array>
|
|
<key>EnvironmentVariables</key>
|
|
<dict>
|
|
</dict>
|
|
<key>RunAtLoad</key>
|
|
<true/>
|
|
<key>WorkingDirectory</key>
|
|
<string>#{var}</string>
|
|
<key>StandardErrorPath</key>
|
|
<string>#{var}/log/traefik.log</string>
|
|
<key>StandardOutPath</key>
|
|
<string>#{var}/log/traefik.log</string>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
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
|