Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
FROM python:3-slim AS builder
FROM python:3.11-bullseye

RUN pip install --target=/app requests openziti

# https://github.com/GoogleContainerTools/distroless
FROM gcr.io/distroless/python3-debian12
COPY --from=builder /app /app
COPY ./zhook.py /app/zhook.py
WORKDIR /app
COPY ./zhook.py /app/zhook.py

RUN pip install --no-cache-dir requests openziti

ENV PYTHONPATH=/app
ENV ZITI_LOG=6
ENV TLSUV_DEBUG=6
CMD ["/app/zhook.py"]
#ENV ZITI_LOG=6
#ENV TLSUV_DEBUG=6

CMD ["python", "/app/zhook.py"]
5 changes: 5 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
docker run --rm -it \
-v "$PWD":/app -w /app \
-e INPUT_ZITIID="$(< /tmp/zmm.json)" \
--env-file ./zmm.env \
zmm
3 changes: 3 additions & 0 deletions zhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import openziti
import json
import os
import sys


class MattermostWebhookBody:
Expand Down Expand Up @@ -393,6 +394,8 @@ def dumpJson(self):
print(f"Response Status: {r.status_code}")
print(r.headers)
print(r.content)
sys.exit(0)
except Exception as e:
print(f"Exception posting webhook: {e}")
raise e
sys.exit(1)
5 changes: 5 additions & 0 deletions zmm.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
INPUT_WEBHOOKURL=http://webhook.mattermost.ziti.internal/hooks/__set__
INPUT_DESTCHANNEL=mmnotificationtest
INPUT_SENDERUSERNAME=GitHubZ
GITHUB_EVENT_NAME=push
INPUT_EVENTJSON={"repository":{"full_name":"org/repo","html_url":"https://github.com/org/repo","stargazers_count":0},"sender":{"login":"some-user","html_url":"https://github.com/some-user","avatar_url":"https://avatars.githubusercontent.com/u/0","url":"https://api.github.com/users/some-user"},"forced":false,"commits":[{"id":"abcdef1","url":"https://github.com/org/repo/commit/abcdef1","message":"local test"}],"compare":"https://github.com/org/repo/compare/abcdef1..abcdef2","ref":"refs/heads/main"}