Files
scenar-creator/Dockerfile
Martin Sukany b7b56fe15f
Some checks failed
Build & Push Docker / build (push) Has been cancelled
Refactor: Oddělení business logiky + inline editor
- Nový modul scenar/core.py (491 řádků čisté logiky)
- Refactored cgi-bin/scenar.py (450 řádků CGI wrapper)
- Inline editor s JavaScript row managementem
- Custom exceptions (ScenarsError, ValidationError, TemplateError)
- Kompletní test coverage (10 testů, všechny )
- Fixed Dockerfile (COPY scenar/, requirements.txt)
- Fixed requirements.txt (openpyxl==3.1.5)
- Fixed pytest.ini (pythonpath = .)
- Nové testy: test_http_inline.py, test_inline_builder.py
- HTTP testy označeny jako @pytest.mark.integration
- Build script: scripts/build_image.sh
- Dokumentace: COMPLETION.md
2025-11-13 16:06:32 +01:00

65 lines
2.0 KiB
Docker

FROM python:3.12-slim
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# OS packages: Apache + curl
RUN apt-get update \
&& apt-get install -y --no-install-recommends apache2 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
# 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) ---
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
EXPOSE 8080
CMD ["apachectl", "-D", "FOREGROUND"]