FROM alpine:latest

# ponytail: resolves latest upstream release at build time via the /releases/latest redirect
# (no GitHub API rate limit); pin WEBHOOK_VERSION if a release ever breaks.
ARG WEBHOOK_VERSION=latest
RUN apk add --no-cache \
    curl \
    docker-cli \
    docker-cli-compose && \
    v="$WEBHOOK_VERSION" && \
    [ "$v" != latest ] || v=$(basename "$(curl -sIL -o /dev/null -w '%{url_effective}' https://github.com/adnanh/webhook/releases/latest)") && \
    curl -fsSL "https://github.com/adnanh/webhook/releases/download/$v/webhook-linux-amd64.tar.gz" \
      | tar xz --strip-components=1 -C /usr/local/bin webhook-linux-amd64/webhook && \
    webhook -version

EXPOSE 9000
ENTRYPOINT ["webhook"]
