consorsbank-kit / Dockerfile
CJs
Replace WebSocket with SSE for real-time panel updates (works through HF proxy)
8852d8c
Raw History Blame Contribute Delete
1.8 kB
FROM php:8.2-apache
# --- PHP extensions: PDO MySQL (compose) + PDO SQLite (zero-config HF Space) + sockets ---
RUN apt-get update \
&& apt-get install -y --no-install-recommends libsqlite3-dev curl ca-certificates \
&& docker-php-ext-install pdo_mysql pdo_sqlite sockets \
&& a2enmod rewrite headers \
&& rm -rf /var/lib/apt/lists/*
# --- Kit at the docroot ---
COPY . /var/www/html/
# --- Writable SQLite dir (data/live.db) + captures dir ---
# 777 so the SQLite file is writable whether Apache runs as root (compose) or as
# an arbitrary non-root uid (Hugging Face Docker Spaces run containers as uid 1000).
RUN mkdir -p /var/www/html/data /var/www/html/captures \
&& chown -R www-data:www-data /var/www/html/data /var/www/html/captures \
&& chmod -R 777 /var/www/html/data /var/www/html/captures
# --- Listen on 80 (docker-compose) *and* 7860 (HF Space app_port >= 1025) ---
# Non-root Spaces cannot bind privileged ports, so expose a high port too.
RUN printf 'Listen 80\nListen 7860\n' > /etc/apache2/ports.conf \
&& printf '<VirtualHost *:7860>\n\tDocumentRoot /var/www/html\n\t<Directory /var/www/html>\n\t\tOptions Indexes FollowSymLinks\n\t\tAllowOverride All\n\t\tRequire all granted\n\t</Directory>\n\tErrorLog ${APACHE_LOG_DIR}/error.log\n\tCustomLog ${APACHE_LOG_DIR}/access.log combined\n</VirtualHost>\n' >> /etc/apache2/sites-available/000-default.conf
# --- Allow .htaccess overrides ---
RUN sed -ri -e 's!AllowOverride None!AllowOverride All!g' /etc/apache2/apache2.conf \
&& printf 'ServerName localhost\n' >> /etc/apache2/apache2.conf
# --- Runtime dirs writable for a non-root container user (HF Spaces) ---
RUN mkdir -p /var/run/apache2 /var/lock/apache2 /var/log/apache2 \
&& chmod -R 777 /var/run/apache2 /var/lock/apache2 /var/log/apache2
EXPOSE 80 7860