103 lines
2.9 KiB
Ruby
103 lines
2.9 KiB
Ruby
class TraefikAT1 < Formula
|
|
desc "Modern reverse proxy (v1.7)"
|
|
homepage "https://traefik.io/"
|
|
url "https://github.com/containous/traefik/releases/download/v1.7.26/traefik-v1.7.26.src.tar.gz"
|
|
sha256 "37334deb0dcd0c393e3ce003334b497d173a5f84cb412a21f19fbbd61211a0ef"
|
|
license "MIT"
|
|
|
|
livecheck do
|
|
url "https://github.com/containous/traefik.git"
|
|
regex(/^v?(1(?:\.\d+)+)$/i)
|
|
end
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "dc50cb5af800c8f062e330e3b103bce1a2d0a78c6fdbd73d742c7197252c151b" => :catalina
|
|
sha256 "3ac187701cefeba894c3440bb9353e4e85cf716ef38cacfe35f3b5e474c52362" => :mojave
|
|
sha256 "89c846b73437bef8360f1acd1cdd5aceb9f8bc160d6400ac77331ac8452169b7" => :high_sierra
|
|
end
|
|
|
|
keg_only :versioned_formula
|
|
|
|
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
|
|
|
|
cd "src/github.com/containous/traefik" do
|
|
cd "webui" do
|
|
system "yarn", "upgrade"
|
|
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
|
|
web_port = free_port
|
|
http_port = free_port
|
|
|
|
(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://127.0.0.1:#{http_port}/"
|
|
assert_match /404 Not Found/m, shell_output(cmd)
|
|
sleep 1
|
|
cmd = "curl -sIm3 -XGET http://localhost:#{web_port}/dashboard/"
|
|
assert_match /200 OK/m, shell_output(cmd)
|
|
ensure
|
|
Process.kill(9, pid)
|
|
Process.wait(pid)
|
|
end
|
|
end
|
|
end
|