From 604e159dd39acb36ddd2fe680ae584885553ca64 Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Mon, 10 Nov 2025 17:37:21 +0100 Subject: [PATCH] Dockerfile --- Dockerfile | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9138879 --- /dev/null +++ b/Dockerfile @@ -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' \ +'' \ +' ServerName localhost' \ +' ServerAdmin webmaster@localhost' \ +' DocumentRoot /var/www/htdocs' \ +'' \ +' ' \ +' Options +ExecCGI -Indexes' \ +' AllowOverride None' \ +' Require all granted' \ +' AddHandler cgi-script .py' \ +' DirectoryIndex /cgi-bin/scenar.py' \ +' ' \ +'' \ +' ErrorLog ${APACHE_LOG_DIR}/error.log' \ +' CustomLog ${APACHE_LOG_DIR}/access.log combined' \ +'' \ +> /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"]