commit c58323c5885825a932754eac6850bab193e2e158 Author: D. Scott Boggs Date: Tue May 27 14:11:33 2025 -0400 initial commit diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6868a0c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +Dockerfile +.dockerignore +.gitignore +**/*.egg-info +**/__pycache__ +.env/ +build/ +.mypy_cache/ \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6e3af5b --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.env +.mypy_cache +build/ +**/*.egg-info +**/__pycache__ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..692b7a5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM python:3.13-alpine +EXPOSE 1312 +WORKDIR /app +COPY ./pyproject.toml ./wsgi-conf.py /app/ +RUN pip install --no-cache-dir --upgrade . +COPY ./fnb_redirecter/ /app/fnb_redirecter +RUN pip install --no-cache-dir --upgrade . +CMD ["python", "-m", "fnb_redirecter"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..519c092 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +services: + fnb-redirecter: + build: . + labels: + traefik.http.routers.fnb-redirecter.rule: Host(`rocfnb.org`) + traefik.http.routers.fnb-redirecter.tls.certresolver: letsencrypt_standalone + networks: [ public ] \ No newline at end of file diff --git a/fnb_redirecter/__init__.py b/fnb_redirecter/__init__.py new file mode 100644 index 0000000..2f31474 --- /dev/null +++ b/fnb_redirecter/__init__.py @@ -0,0 +1 @@ +from fnb_redirecter.server import app \ No newline at end of file diff --git a/fnb_redirecter/__main__.py b/fnb_redirecter/__main__.py new file mode 100644 index 0000000..6264389 --- /dev/null +++ b/fnb_redirecter/__main__.py @@ -0,0 +1,3 @@ +from os import execlp + +execlp('gunicorn', 'gunicorn', '--conf', '/app/wsgi-conf.py', '--bind', '0.0.0.0:1312', 'fnb_redirecter:app') \ No newline at end of file diff --git a/fnb_redirecter/server.py b/fnb_redirecter/server.py new file mode 100644 index 0000000..2967ca7 --- /dev/null +++ b/fnb_redirecter/server.py @@ -0,0 +1,16 @@ +from flask import Flask, redirect + +app = Flask(__name__.split('.')[0]) + +@app.route('/ig') +def ig_redir(): + return redirect('https://instagram.com/RocFNB') + +@app.route('/donate') +def donate_redir(): + return redirect('https://venmo.com/RocFoodNotBombs') + +@app.errorhandler(404) +def redirect_other(_): + return redirect('https://linktr.ee/RocFNB') + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..6f7bb0b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,16 @@ +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[project] +name = "fnb_redirecter" +authors = [{ name = "D. Scott Boggs", email = "scott@techwork.zone" }] +description = "Temporary placeholder for fnb web site" +readme = "README.md" +requires-python = ">=3.11" # Self type added +license = "AGPL-3.0-only" +dependencies = ["flask", "gunicorn"] +dynamic = ["version"] + +[project.scripts] +# Put scripts here diff --git a/wsgi-conf.py b/wsgi-conf.py new file mode 100644 index 0000000..cad3455 --- /dev/null +++ b/wsgi-conf.py @@ -0,0 +1,9 @@ +# Gunicorn config variables +loglevel = "info" +errorlog = "-" # stderr +accesslog = "-" # stdout +worker_tmp_dir = "/dev/shm" +graceful_timeout = 120 +timeout = 120 +keepalive = 5 +threads = 3