File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ venv *
2+ config.json
3+ __pycache__ /
Original file line number Diff line number Diff line change 1- FROM python:2.7-alpine
2- MAINTAINER "Matjaž Finžgar" <matjaz@finzgar.net>
1+ FROM python:3.8-alpine
2+
3+ ARG PORT=5000
34
45WORKDIR /app
6+ COPY . .
57
6- COPY requirements.txt /app
78RUN pip install -r requirements.txt
89
9- COPY . /app
1010
11- EXPOSE 5000
12- CMD [ " python" , " webhooks.py" ]
11+ EXPOSE ${PORT}
12+ CMD python webhooks.py $PORT
Original file line number Diff line number Diff line change 1+ docker build . -t github-webhook
2+ docker run -d --name github-webhook -p 5000:5000 -v /home/tyson/dev/python-github-webhooks/hooks:/app/hooks -v /home/tyson/dev/python-github-webhooks/config.json:/app/config.json github-webhook
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
12# -*- coding: utf-8 -*-
23#
34# Copyright (C) 2014, 2015, 2016 Carlos Jenkins <carlos@jenkins.co.cr>
1617# under the License.
1718
1819import logging
20+ import sys
1921from sys import stderr , hexversion
2022logging .basicConfig (stream = stderr )
2123
@@ -70,7 +72,7 @@ def index():
7072 abort (403 )
7173
7274 # Enforce secret
73- secret = config .get ('enforce_secret' , '' )
75+ secret = config .get ('enforce_secret' , '' ). encode ( 'utf-8' )
7476 if secret :
7577 # Only SHA1 is supported
7678 header_signature = request .headers .get ('X-Hub-Signature' )
@@ -82,7 +84,7 @@ def index():
8284 abort (501 )
8385
8486 # HMAC requires the key to be bytes, but data is string
85- mac = hmac .new (str ( secret ) , msg = request .data , digestmod = 'sha1' )
87+ mac = hmac .new (secret , msg = request .data , digestmod = 'sha1' )
8688
8789 # Python prior to 2.7.7 does not have hmac.compare_digest
8890 if hexversion >= 0x020707F0 :
@@ -203,4 +205,7 @@ def index():
203205
204206
205207if __name__ == '__main__' :
206- application .run (debug = True , host = '0.0.0.0' )
208+ port = 5000
209+ if sys .argv [1 :]:
210+ port = int (sys .argv [1 ])
211+ application .run (host = '0.0.0.0' , port = port )
You can’t perform that action at this time.
0 commit comments