homebrew-core/Formula/traefik@1.rb

98 lines
2.8 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.24/traefik-v1.7.24.src.tar.gz"
version "1.7.24"
sha256 "8f9e0ba3cbb6537e47c675c806d6e6de3267241a48ea7291b19673d524f78a88"
bottle do
cellar :any_skip_relocation
sha256 "f50589618ba4147731cadda2451d08f95a6d56ad79f823b657ab64db73f590ed" => :catalina
sha256 "993885ac94857dd2828fdf05188326a6ebd9e8da38d5deaafbcfa4094b4738d2" => :mojave
sha256 "2c00bae6b3c468a32cdaaa59f58d33cc3de61899723a355d99cf34f0bd93c773" => :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