added patch and dockerfile

This commit is contained in:
gurkenhabicht 2025-12-23 00:44:08 +01:00
parent 80e5c93e25
commit 0799deb727
8 changed files with 110 additions and 3 deletions

41
Dockerfile Normal file
View File

@ -0,0 +1,41 @@
# ----------------------------
# Build stage
# ----------------------------
FROM python:3.11.0-alpine AS builder
RUN apk add --no-cache \
# python3 \
# py3-pip \
git \
# build-base \
# curl
ENV POETRY_VERSION=2.2.0
RUN pip install --no-cache-dir "poetry==$POETRY_VERSION" # --break-system-packages is not needed
ENV POETRY_VIRTUALENVS_CREATE=false
ENV POETRY_NO_INTERACTION=1
WORKDIR /app
RUN git clone https://git.stefan.works/stefan/website.git .
RUN poetry install --only main ## --no-root
# RUN poetry run python -m scripts/patch_flask_frozen
RUN poetry run patch-frozen
RUN poetry run python freezer.py
# ----------------------------
# Runtime stage
# ----------------------------
FROM alpine:3.20
RUN apk add --no-cache nginx
RUN rm -rf /usr/share/nginx/html/* \
&& mkdir -p /run/nginx
COPY --from=builder /app/build /usr/share/nginx/html
COPY container-nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

View File

@ -1,2 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0"><channel><title>Website of Stefan Friese</title><link>https://stefan.works</link><description>test</description><atom:link href="https://stefan.works" rel="self"/><docs>http://www.rssboard.org/rss-specification</docs><generator>python-feedgen</generator><language>en-us</language><lastBuildDate>Sun, 20 Jul 2025 22:08:29 +0000</lastBuildDate><item><title>Directory Writeup — TryHackMe</title><link>https://stefan.works/blog/Directory Writeup — TryHackMe/index.html</link><guid isPermaLink="false">https://stefan.works/blog/Directory Writeup — TryHackMe/index.html</guid><pubDate>Sun, 20 Jul 2025 00:00:00 +0200</pubDate></item><item><title>Restoring (NT)Backups From a SCSI Tape Drive</title><link>https://stefan.works/blog/Restoring (NT)Backups From a SCSI Tape Drive/index.html</link><guid isPermaLink="false">https://stefan.works/blog/Restoring (NT)Backups From a SCSI Tape Drive/index.html</guid><pubDate>Wed, 27 Sep 2023 00:00:00 +0200</pubDate></item><item><title>The Joy of One-Liners</title><link>https://stefan.works/blog/The Joy of One-Liners/index.html</link><guid isPermaLink="false">https://stefan.works/blog/The Joy of One-Liners/index.html</guid><pubDate>Sun, 29 May 2022 00:00:00 +0200</pubDate></item><item><title>Keep It Simple</title><link>https://stefan.works/blog/Keep It Simple/index.html</link><guid isPermaLink="false">https://stefan.works/blog/Keep It Simple/index.html</guid><pubDate>Tue, 01 Jun 2021 00:00:00 +0200</pubDate></item></channel></rss>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0"><channel><title>Website of Stefan Friese</title><link>https://stefan.works</link><description>test</description><atom:link href="https://stefan.works" rel="self"/><docs>http://www.rssboard.org/rss-specification</docs><generator>python-feedgen</generator><language>en-us</language><lastBuildDate>Mon, 22 Dec 2025 23:05:02 +0000</lastBuildDate><item><title>Directory Writeup — TryHackMe</title><link>https://stefan.works/blog/Directory Writeup — TryHackMe/index.html</link><guid isPermaLink="false">https://stefan.works/blog/Directory Writeup — TryHackMe/index.html</guid><pubDate>Sun, 20 Jul 2025 00:00:00 +0200</pubDate></item><item><title>Restoring (NT)Backups From a SCSI Tape Drive</title><link>https://stefan.works/blog/Restoring (NT)Backups From a SCSI Tape Drive/index.html</link><guid isPermaLink="false">https://stefan.works/blog/Restoring (NT)Backups From a SCSI Tape Drive/index.html</guid><pubDate>Wed, 27 Sep 2023 00:00:00 +0200</pubDate></item><item><title>The Joy of One-Liners</title><link>https://stefan.works/blog/The Joy of One-Liners/index.html</link><guid isPermaLink="false">https://stefan.works/blog/The Joy of One-Liners/index.html</guid><pubDate>Sun, 29 May 2022 00:00:00 +0200</pubDate></item><item><title>Keep It Simple</title><link>https://stefan.works/blog/Keep It Simple/index.html</link><guid isPermaLink="false">https://stefan.works/blog/Keep It Simple/index.html</guid><pubDate>Tue, 01 Jun 2021 00:00:00 +0200</pubDate></item></channel></rss>

View File

@ -1,2 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0"><channel><title>Website of Stefan Friese</title><link>https://stefan.works</link><description>test</description><atom:link href="https://stefan.works" rel="self"/><docs>http://www.rssboard.org/rss-specification</docs><generator>python-feedgen</generator><language>en-us</language><lastBuildDate>Wed, 11 Oct 2023 19:32:42 +0000</lastBuildDate><item><title>Restoring (NT)Backups From a SCSI Tape Drive</title><link>https://stefan.works/blog/Restoring (NT)Backups From a SCSI Tape Drive/index.html</link><guid isPermaLink="false">https://stefan.works/blog/Restoring (NT)Backups From a SCSI Tape Drive/index.html</guid><pubDate>Wed, 27 Sep 2023 00:00:00 +0200</pubDate></item><item><title>The Joy of One-Liners</title><link>https://stefan.works/blog/The Joy of One-Liners/index.html</link><guid isPermaLink="false">https://stefan.works/blog/The Joy of One-Liners/index.html</guid><pubDate>Sun, 29 May 2022 00:00:00 +0200</pubDate></item><item><title>Keep It Simple</title><link>https://stefan.works/blog/Keep It Simple/index.html</link><guid isPermaLink="false">https://stefan.works/blog/Keep It Simple/index.html</guid><pubDate>Tue, 01 Jun 2021 00:00:00 +0200</pubDate></item></channel></rss>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0"><channel><title>Website of Stefan Friese</title><link>https://stefan.works</link><description>test</description><atom:link href="https://stefan.works" rel="self"/><docs>http://www.rssboard.org/rss-specification</docs><generator>python-feedgen</generator><language>en-us</language><lastBuildDate>Sun, 20 Jul 2025 22:08:29 +0000</lastBuildDate><item><title>Directory Writeup — TryHackMe</title><link>https://stefan.works/blog/Directory Writeup — TryHackMe/index.html</link><guid isPermaLink="false">https://stefan.works/blog/Directory Writeup — TryHackMe/index.html</guid><pubDate>Sun, 20 Jul 2025 00:00:00 +0200</pubDate></item><item><title>Restoring (NT)Backups From a SCSI Tape Drive</title><link>https://stefan.works/blog/Restoring (NT)Backups From a SCSI Tape Drive/index.html</link><guid isPermaLink="false">https://stefan.works/blog/Restoring (NT)Backups From a SCSI Tape Drive/index.html</guid><pubDate>Wed, 27 Sep 2023 00:00:00 +0200</pubDate></item><item><title>The Joy of One-Liners</title><link>https://stefan.works/blog/The Joy of One-Liners/index.html</link><guid isPermaLink="false">https://stefan.works/blog/The Joy of One-Liners/index.html</guid><pubDate>Sun, 29 May 2022 00:00:00 +0200</pubDate></item><item><title>Keep It Simple</title><link>https://stefan.works/blog/Keep It Simple/index.html</link><guid isPermaLink="false">https://stefan.works/blog/Keep It Simple/index.html</guid><pubDate>Tue, 01 Jun 2021 00:00:00 +0200</pubDate></item></channel></rss>

25
docker-nginx.conf Normal file
View File

@ -0,0 +1,25 @@
worker_processes 1;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
}

View File

@ -21,3 +21,6 @@ toml = "*"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.poetry.scripts]
patch-frozen = "scripts.patch_flask_frozen:patch_flask_frozen"

0
scripts/__init__.py Normal file
View File

View File

@ -0,0 +1,38 @@
from pathlib import Path
def patch_flask_frozen():
try:
import flask_frozen
except ImportError:
print("flask_frozen is not installed.")
return
init_path = Path(flask_frozen.__file__).parent / "__init__.py"
if not init_path.exists():
print("Could not find flask_frozen __init__.py")
return
with open(init_path, "r") as f:
lines = f.readlines()
changed = False
for i, line in enumerate(lines):
if "url_encoding = self.app.url_map.charset" in line:
lines[i] = " url_encoding = 'utf-8' # patched charset\n"
changed = True
if changed:
with open(init_path, "w") as f:
f.writelines(lines)
print("✅ flask_frozen patched successfully.")
else:
print("⚠️ Patch already applied or target line not found.")
if __name__ == "__main__":
patch_flask_frozen()

View File

@ -1,2 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0"><channel><title>Website of Stefan Friese</title><link>https://stefan.works</link><description>test</description><atom:link href="https://stefan.works" rel="self"/><docs>http://www.rssboard.org/rss-specification</docs><generator>python-feedgen</generator><language>en-us</language><lastBuildDate>Sun, 20 Jul 2025 22:08:29 +0000</lastBuildDate><item><title>Directory Writeup — TryHackMe</title><link>https://stefan.works/blog/Directory Writeup — TryHackMe/index.html</link><guid isPermaLink="false">https://stefan.works/blog/Directory Writeup — TryHackMe/index.html</guid><pubDate>Sun, 20 Jul 2025 00:00:00 +0200</pubDate></item><item><title>Restoring (NT)Backups From a SCSI Tape Drive</title><link>https://stefan.works/blog/Restoring (NT)Backups From a SCSI Tape Drive/index.html</link><guid isPermaLink="false">https://stefan.works/blog/Restoring (NT)Backups From a SCSI Tape Drive/index.html</guid><pubDate>Wed, 27 Sep 2023 00:00:00 +0200</pubDate></item><item><title>The Joy of One-Liners</title><link>https://stefan.works/blog/The Joy of One-Liners/index.html</link><guid isPermaLink="false">https://stefan.works/blog/The Joy of One-Liners/index.html</guid><pubDate>Sun, 29 May 2022 00:00:00 +0200</pubDate></item><item><title>Keep It Simple</title><link>https://stefan.works/blog/Keep It Simple/index.html</link><guid isPermaLink="false">https://stefan.works/blog/Keep It Simple/index.html</guid><pubDate>Tue, 01 Jun 2021 00:00:00 +0200</pubDate></item></channel></rss>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0"><channel><title>Website of Stefan Friese</title><link>https://stefan.works</link><description>test</description><atom:link href="https://stefan.works" rel="self"/><docs>http://www.rssboard.org/rss-specification</docs><generator>python-feedgen</generator><language>en-us</language><lastBuildDate>Mon, 22 Dec 2025 23:05:02 +0000</lastBuildDate><item><title>Directory Writeup — TryHackMe</title><link>https://stefan.works/blog/Directory Writeup — TryHackMe/index.html</link><guid isPermaLink="false">https://stefan.works/blog/Directory Writeup — TryHackMe/index.html</guid><pubDate>Sun, 20 Jul 2025 00:00:00 +0200</pubDate></item><item><title>Restoring (NT)Backups From a SCSI Tape Drive</title><link>https://stefan.works/blog/Restoring (NT)Backups From a SCSI Tape Drive/index.html</link><guid isPermaLink="false">https://stefan.works/blog/Restoring (NT)Backups From a SCSI Tape Drive/index.html</guid><pubDate>Wed, 27 Sep 2023 00:00:00 +0200</pubDate></item><item><title>The Joy of One-Liners</title><link>https://stefan.works/blog/The Joy of One-Liners/index.html</link><guid isPermaLink="false">https://stefan.works/blog/The Joy of One-Liners/index.html</guid><pubDate>Sun, 29 May 2022 00:00:00 +0200</pubDate></item><item><title>Keep It Simple</title><link>https://stefan.works/blog/Keep It Simple/index.html</link><guid isPermaLink="false">https://stefan.works/blog/Keep It Simple/index.html</guid><pubDate>Tue, 01 Jun 2021 00:00:00 +0200</pubDate></item></channel></rss>