homebrew-core/Formula/traefik@1.rb

104 lines
3.1 KiB
Ruby

class TraefikAT1 < Formula
desc "Modern reverse proxy (v1.7)"
homepage "https://traefik.io/"
url "https://github.com/traefik/traefik/releases/download/v1.7.28/traefik-v1.7.28.src.tar.gz"
sha256 "1baa2ca726c4eac71931284229b867a7f15cecb41c3ce8df3619502880ab6719"
license "MIT"
livecheck do
url "https://github.com/traefik/traefik.git"
regex(/^v?(1(?:\.\d+)+)$/i)
end
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "34c1ced84f74a815d10048832232bc46acba74b149271365f1178de9f3ad7ddc"
sha256 cellar: :any_skip_relocation, big_sur: "2ebc160c9500db7fe90b9f3312a8d43bcdac819a16a4c1e641702b61c3e948a6"
sha256 cellar: :any_skip_relocation, catalina: "4225edf0cb5466dd6031cb8bf149c764f8614c0fc97aa799c8271e373268a3f5"
sha256 cellar: :any_skip_relocation, mojave: "a014d6c20348aab5eaf4a775906bf7b450d89edb16373328840d4f3a3d9e80cb"
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
ENV["GO111MODULE"] = "auto"
(buildpath/"src/github.com/traefik/traefik").install buildpath.children
cd "src/github.com/traefik/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", shell_output(cmd)
sleep 1
cmd = "curl -sIm3 -XGET http://localhost:#{web_port}/dashboard/"
assert_match "200 OK", shell_output(cmd)
ensure
Process.kill(9, pid)
Process.wait(pid)
end
end
end