63 lines
1.9 KiB
Docker
63 lines
1.9 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
|
|
COPY cgi-bin ./cgi-bin
|
|
COPY templates ./templates
|
|
|
|
# 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 (add more as needed) ---
|
|
RUN pip install --no-cache-dir pandas openpyxl
|
|
|
|
# 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"]
|