# -*- 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.7.5 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  946572b6f1f2907f1cc4878b8663780cecdb3f83 \
                        sha256  852fec783ecdd2761b6a78634c1f65706605654c119a60de6b267b4c5ad860fb \
                        size    49801678 \
                    traefik_v${version}_darwin_arm64${extract.suffix} \
                        rmd160  3608ee3f689da41316b20aa616fc3e1ea0b3084a \
                        sha256  403fd02b59cbc655378d99450fb9da08c37559b64ec485dc8e470d7250ba5383 \
                        size    45941192 \
                    traefik-v${version}.src${extract.suffix} \
                        rmd160  353837f6c585db37a027d280382bda0907eb3a17 \
                        sha256  09e44f902945eeced6521c0e561c31c3bdf19f82882945aca049ae31a8e9055d \
                        size    14176737

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
"
