# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0

github.setup        traefik traefik 3.6.7 v
github.tarball_from releases
revision            0

categories          net security devel
maintainers         {judaew @judaew} openmaintainer
license             MIT

description         The Cloud Native Application Proxy
long_description    \
    Traefik (pronounced traffic) is a modern HTTP reverse proxy and load \
    balancer that makes deploying microservices easy. Traefik integrates with \
    your existing infrastructure components (Docker, Swarm mode, Kubernetes, \
    Marathon, Consul, Etcd, Rancher, Amazon ECS, ...) and configures itself \
    automatically and dynamically. Pointing Traefik at your orchestrator \
    should be the only configuration step you need.

set arch ${build_arch}

if {${build_arch} eq "x86_64"} {
    set arch "amd64"
}

distfiles           traefik_v${version}_darwin_${arch}${extract.suffix} \
                    traefik-v${version}.src${extract.suffix}

checksums           traefik_v${version}_darwin_amd64${extract.suffix} \
                        rmd160  a2cb8c0eddaeeb3731eb9fde1395367b1e89f8df \
                        sha256  8fdffea94cb7fbc8533b1ccb8a889584054507819d08e53c1e4a25191c909add \
                        size    48942597 \
                    traefik_v${version}_darwin_arm64${extract.suffix} \
                        rmd160  90f999a4796358adf03b0368991201bdf32d7954 \
                        sha256  a2b01cdf0d7d202402b9716666ed86b9d6755a9f777063142aef5798a9d220af \
                        size    45891963 \
                    traefik-v${version}.src${extract.suffix} \
                        rmd160  4b06093f3b0f4527dc7d067d1a8ab420975637d8 \
                        sha256  59158f0a46a8cfeb4766e4633a686a19bfb18bcdc44bedcca141e7e20aaa1a02 \
                        size    14195490

extract.mkdir       yes
use_configure       no
build {}

destroot {
    xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/

    xinstall -d ${destroot}${prefix}/share/examples/${name}
    xinstall -m 0644 -W ${worksrcpath} \
        traefik.sample.toml traefik.sample.yml \
        ${destroot}${prefix}/share/examples/${name}

    xinstall -d ${destroot}${prefix}/etc/${name}
}
destroot.keepdirs ${destroot}${prefix}/etc/${name}

startupitem.create  yes
startupitem.start   \
    "${prefix}/bin/${name} --configfile=${prefix}/etc/${name}/traefik.toml"
startupitem.stop    "kill \$(cat ${prefix}/var/run/${name}.pid) "
startupitem.pidfile auto ${prefix}/var/run/${name}.pid

github.livecheck.regex  {([^"r-]+)}

notes "
A config must be created in
    ${prefix}/etc/traefik/traefik.toml

An example config is
    ${prefix}/share/examples/traefik/traefik.toml

Launch ${name} as daemon with
    sudo port load ${name}
or
    sudo launchctl load -w \\
        /Library/LaunchDaemons/org.macports.traefik.plist
"
