# -*- 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.14 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  0e70ec5f15f8a311c77e50335541988a38e8d272 \
                        sha256  54693a6e9b99fdbbe790f346911495aef95cb40efd24562d4b9d092d62a5d82f \
                        size    52293979 \
                    traefik_v${version}_darwin_arm64${extract.suffix} \
                        rmd160  db85c09e11f76f439c4910243d6705292679b46b \
                        sha256  ff42488703fe5b7d627e36e581ab7bb0eb6685262fce9c838d964175cbf0d1fc \
                        size    48107859 \
                    traefik-v${version}.src${extract.suffix} \
                        rmd160  bb49ce33b10ab1214f5a8f6fdea67b22d238a15b \
                        sha256  a5c89da12e74890a2b3aeecf46756ee853a6e8c1e9e27a04fa1ebdaefc68d4ce \
                        size    14492331

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
"
