# -*- 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 2.11.0 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  e0c8caa1ab50f0bb1070f157e0a398c18add093d \
                        sha256  9fb706a29fedcaec4046fbfb3799ae8546083b2112539fc22d80cdff0a9fc70f \
                        size    41566458 \
                    traefik_v${version}_darwin_arm64${extract.suffix} \
                        rmd160  73b3ba3de2f9e55e9c4c26ed9da7973bc3d39084 \
                        sha256  b845fd1617f530574908851f5b2838060d2a4fe1541d4562bab69c54d21af14b \
                        size    39694581 \
                    traefik-v${version}.src${extract.suffix} \
                        rmd160  3924180a6ee70f2e6a2f9e74788e076481a28a12 \
                        sha256  b431d4a802d7c06912427b3e876c44fc4cc0284bb05268c466dd6a0fbb59e9c2 \
                        size    11500258

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
"
