feat(docker): add webhook to auto-redeploy on master commit, remove old docker-related files
Build and deploy / deploy (push) Successful in 35s

This commit is contained in:
2026-07-26 18:07:49 +02:00
parent e9a5eef051
commit eff6f48425
6 changed files with 120 additions and 10 deletions
+3
View File
@@ -0,0 +1,3 @@
FROM python:3-alpine
COPY receive.py /receive.py
CMD ["python", "/receive.py"]
+34
View File
@@ -0,0 +1,34 @@
from http.server import HTTPServer, BaseHTTPRequestHandler
import os, tarfile, io, shutil, time
SECRET = os.environ["WEBHOOK_SECRET"]
class Handler(BaseHTTPRequestHandler):
def do_POST(self):
if self.headers.get("X-Webhook-Secret") != SECRET:
self.send_response(401)
self.end_headers()
return
body = self.rfile.read(int(self.headers["Content-Length"]))
for item in os.listdir("/data"):
path = os.path.join("/data", item)
if os.path.isdir(path):
shutil.rmtree(path)
else:
os.remove(path)
with tarfile.open(fileobj=io.BytesIO(body), mode="r:gz") as tar:
tar.extractall("/data", filter="data")
with open("/data/.deploy-timestamp", "w") as f:
f.write(str(time.time()))
self.send_response(200)
self.end_headers()
self.wfile.write(b"OK")
HTTPServer(("0.0.0.0", 9000), Handler).serve_forever()