Dockerfile

This commit is contained in:
Martin Sukany
2025-11-10 17:37:21 +01:00
parent c22ee0af3a
commit 604e159dd3

61
Dockerfile Normal file
View File

@@ -0,0 +1,61 @@
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 for the app
RUN mkdir -p /var/www/htdocs/tmp \
&& chown -R www-data:www-data /var/www/htdocs/tmp /var/www/htdocs/templates \
&& chmod 0775 /var/www/htdocs/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"]