feat: refactor to FastAPI architecture v2.0
Some checks failed
Build & Push Docker / build (push) Has been cancelled

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-20 16:28:21 +01:00
parent 87f1fc2c7a
commit e2bdadd0ce
32 changed files with 2896 additions and 55 deletions

View File

@@ -1,64 +1,21 @@
FROM python:3.12-slim
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONDONTWRITEBYTECODE=1 \
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# OS packages: Apache + curl
RUN apt-get update \
&& apt-get install -y --no-install-recommends apache2 curl \
&& apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*
# Enable CGI and disable default /usr/lib/cgi-bin alias
RUN a2enmod cgid && a2disconf serve-cgi-bin || true
WORKDIR /app
# Use /var/www/htdocs as DocumentRoot to match your layout
RUN mkdir -p /var/www/htdocs
WORKDIR /var/www/htdocs
# Copy app (including scenar package for imports)
COPY cgi-bin ./cgi-bin
COPY templates ./templates
COPY scenar ./scenar
COPY requirements.txt ./requirements.txt
# Ensure CGI scripts are executable
RUN find /var/www/htdocs/cgi-bin -type f -name "*.py" -exec chmod 0755 {} \;
# Writable tmp + kompatibilita s /scripts/tmp (skrypt nic neupravujeme)
RUN mkdir -p /var/www/htdocs/tmp \
/var/www/htdocs/scripts/tmp \
&& chown -R www-data:www-data /var/www/htdocs/tmp /var/www/htdocs/scripts \
&& chmod 0775 /var/www/htdocs/tmp /var/www/htdocs/scripts/tmp
# --- Python dependencies (from requirements.txt) ---
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Listen on 8080
RUN sed -ri 's/Listen 80/Listen 8080/g' /etc/apache2/ports.conf
# Vhost: enable CGI in DocumentRoot; index => scenar.py
RUN printf '%s\n' \
'<VirtualHost *:8080>' \
' ServerName localhost' \
' ServerAdmin webmaster@localhost' \
' DocumentRoot /var/www/htdocs' \
'' \
' <Directory /var/www/htdocs>' \
' Options +ExecCGI -Indexes' \
' AllowOverride None' \
' Require all granted' \
' AddHandler cgi-script .py' \
' DirectoryIndex /cgi-bin/scenar.py' \
' </Directory>' \
'' \
' ErrorLog ${APACHE_LOG_DIR}/error.log' \
' CustomLog ${APACHE_LOG_DIR}/access.log combined' \
'</VirtualHost>' \
> /etc/apache2/sites-available/000-default.conf
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
CMD curl -fsS http://127.0.0.1:8080/ >/dev/null || exit 1
COPY . .
EXPOSE 8080
CMD ["apachectl", "-D", "FOREGROUND"]
HEALTHCHECK --interval=30s --timeout=5s CMD curl -fsS http://localhost:8080/api/health || exit 1
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080"]