From c13378170d9a69ae1d83ea0e1cecee121f4a614e Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 8 Dec 2023 11:18:42 +0100 Subject: [PATCH] inital commit --- Dockerfile | 21 +++++++++++++++++++++ requirements.txt | 1 + whois.py | 11 +++++++++++ 3 files changed, 33 insertions(+) create mode 100644 Dockerfile create mode 100644 requirements.txt create mode 100644 whois.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1085038 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM debian:bookworm +EXPOSE 5000 +RUN \ + apt update && \ + apt -y install \ + python3-pip \ + python3-venv \ + whois + +SHELL ["/bin/bash", "-c"] + +WORKDIR /code +RUN chown daemon /code +USER daemon +ADD --chown=daemon whois.py . +ADD --chown=daemon requirements.txt . + +RUN python3 -m venv _env && \ + source _env/bin/activate && \ + pip install -r requirements.txt +ENTRYPOINT [ "/code/_env/bin/flask", "--app", "whois.py", "run", "--host=0.0.0.0" ] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e3e9a71 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +Flask diff --git a/whois.py b/whois.py new file mode 100644 index 0000000..661be57 --- /dev/null +++ b/whois.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +from flask import Flask, Response +import subprocess + +server = Flask(__name__) + +@server.route('/whois/') +def whois(domain): + whois_cmd = subprocess.run(['/usr/bin/whois', domain], capture_output=True) + return Response(whois_cmd.stdout.decode('utf-8'), mimetype="text/plain") +