commit c13378170d9a69ae1d83ea0e1cecee121f4a614e Author: Chris Date: Fri Dec 8 11:18:42 2023 +0100 inital commit 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") +