diff --git a/apps/website/Dockerfile b/apps/website/Dockerfile
index 1d9803e..406ab7b 100644
--- a/apps/website/Dockerfile
+++ b/apps/website/Dockerfile
@@ -1,41 +1,73 @@
-FROM alpine:3.19
+FROM php:8.5-fpm-alpine
-RUN apk update && apk add --no-cache \
- apache2 \
- php82 \
- php82-apache2 \
- php82-pdo \
- php82-pdo_sqlite \
- php82-curl \
- curl \
- shadow
+RUN apk add --no-cache \
+ apache2 \
+ curl \
+ libcurl \
+ shadow \
+ sqlite-libs && \
+ apk add --no-cache --virtual .build-deps \
+ $PHPIZE_DEPS \
+ curl-dev \
+ sqlite-dev && \
+ docker-php-ext-install \
+ curl \
+ opcache \
+ pdo_sqlite && \
+ apk del .build-deps
-RUN ln -sf /usr/bin/php82 /usr/bin/php
-
-RUN sed -i 's/#LoadModule rewrite_module/LoadModule rewrite_module/' /etc/apache2/httpd.conf && \
- sed -i 's/#LoadModule headers_module/LoadModule headers_module/' /etc/apache2/httpd.conf && \
- sed -i 's/DirectoryIndex index.html/DirectoryIndex index.php index.html/' /etc/apache2/httpd.conf && \
- sed -i 's/^Listen 80$/Listen 8080/' /etc/apache2/httpd.conf && \
- sed -i 's#^ErrorLog .*#ErrorLog /proc/self/fd/2#' /etc/apache2/httpd.conf && \
- sed -i 's#^CustomLog .*#CustomLog /proc/self/fd/1 combined#' /etc/apache2/httpd.conf && \
+RUN set -eu; \
+ enable_module() { \
+ name="$1"; \
+ path="$2"; \
+ if grep -q "^#LoadModule ${name} " /etc/apache2/httpd.conf; then \
+ sed -i "s|^#LoadModule ${name} .*|LoadModule ${name} ${path}|" /etc/apache2/httpd.conf; \
+ elif ! grep -q "^LoadModule ${name} " /etc/apache2/httpd.conf; then \
+ printf "LoadModule %s %s\n" "$name" "$path" >> /etc/apache2/httpd.conf; \
+ fi; \
+ }; \
+ enable_module rewrite_module modules/mod_rewrite.so; \
+ enable_module headers_module modules/mod_headers.so; \
+ enable_module proxy_module modules/mod_proxy.so; \
+ enable_module proxy_fcgi_module modules/mod_proxy_fcgi.so; \
+ sed -i 's/DirectoryIndex index.html/DirectoryIndex index.php index.html/' /etc/apache2/httpd.conf; \
+ sed -i 's/^Listen 80$/Listen 8080/' /etc/apache2/httpd.conf; \
+ sed -i 's#^ErrorLog .*#ErrorLog /proc/self/fd/2#' /etc/apache2/httpd.conf; \
+ sed -i 's#^CustomLog .*#CustomLog /proc/self/fd/1 combined#' /etc/apache2/httpd.conf; \
if grep -q '^PidFile ' /etc/apache2/httpd.conf; then \
sed -i 's#^PidFile .*#PidFile /tmp/httpd.pid#' /etc/apache2/httpd.conf; \
else \
printf '\nPidFile /tmp/httpd.pid\n' >> /etc/apache2/httpd.conf; \
- fi
+ fi; \
+ printf '\nServerName localhost\n' >> /etc/apache2/httpd.conf; \
+ sed -i 's#^listen = .*#listen = 127.0.0.1:9000#' /usr/local/etc/php-fpm.d/www.conf; \
+ sed -i 's#^;clear_env = no#clear_env = no#' /usr/local/etc/php-fpm.d/www.conf; \
+ sed -i 's#^pm.max_children = .*#pm.max_children = 6#' /usr/local/etc/php-fpm.d/www.conf; \
+ sed -i 's#^pm.start_servers = .*#pm.start_servers = 2#' /usr/local/etc/php-fpm.d/www.conf; \
+ sed -i 's#^pm.min_spare_servers = .*#pm.min_spare_servers = 1#' /usr/local/etc/php-fpm.d/www.conf; \
+ sed -i 's#^pm.max_spare_servers = .*#pm.max_spare_servers = 3#' /usr/local/etc/php-fpm.d/www.conf
+
+COPY httpd-php-fpm.conf /etc/apache2/conf.d/php-fpm.conf
+COPY opcache.ini /usr/local/etc/php/conf.d/zz-opcache.ini
+COPY php-fpm-runtime.conf /usr/local/etc/php-fpm.d/zz-runtime.conf
+COPY start-website.sh /usr/local/bin/start-website
COPY . /var/www/localhost/htdocs/
-RUN rm -f /var/www/localhost/htdocs/index.html
-
-RUN mkdir -p /var/www/localhost/htdocs/db && \
- chown -R apache:apache /var/www/localhost/htdocs/db && \
- chmod -R 755 /var/www/localhost/htdocs/db
-
-RUN usermod -u 1000 apache && \
+RUN rm -f /var/www/localhost/htdocs/index.html && \
+ usermod -u 1000 apache && \
groupmod -g 1000 apache && \
- mkdir -p /run/apache2 /var/log/apache2 /tmp/website-lang && \
- chown -R apache:apache /run/apache2 /var/log/apache2 /tmp/website-lang /var/www/localhost/htdocs/db
+ mkdir -p \
+ /run/apache2 \
+ /var/log/apache2 \
+ /var/www/localhost/htdocs/db \
+ /tmp/website-lang && \
+ chown -R apache:apache \
+ /run/apache2 \
+ /var/log/apache2 \
+ /var/www/localhost/htdocs/db \
+ /tmp/website-lang && \
+ chmod 0755 /usr/local/bin/start-website
ENV WEBSITE_LANG_WRITE_DIR=/var/www/localhost/htdocs/db/lang
ENV OLLAMA_HOST=http://192.168.100.68:11434
@@ -45,4 +77,4 @@ USER apache
EXPOSE 8080
-CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]
+CMD ["start-website"]
diff --git a/apps/website/httpd-php-fpm.conf b/apps/website/httpd-php-fpm.conf
new file mode 100644
index 0000000..dc468b8
--- /dev/null
+++ b/apps/website/httpd-php-fpm.conf
@@ -0,0 +1,8 @@
+
+ SetHandler "proxy:fcgi://127.0.0.1:9000"
+
+
+
+ AllowOverride None
+ Require all granted
+
diff --git a/apps/website/opcache.ini b/apps/website/opcache.ini
new file mode 100644
index 0000000..2ac4ab4
--- /dev/null
+++ b/apps/website/opcache.ini
@@ -0,0 +1,7 @@
+opcache.enable=1
+opcache.enable_cli=1
+opcache.validate_timestamps=0
+opcache.memory_consumption=64
+opcache.interned_strings_buffer=8
+opcache.max_accelerated_files=4000
+opcache.jit=0
diff --git a/apps/website/php-fpm-runtime.conf b/apps/website/php-fpm-runtime.conf
new file mode 100644
index 0000000..9c05c21
--- /dev/null
+++ b/apps/website/php-fpm-runtime.conf
@@ -0,0 +1,3 @@
+[global]
+pid = /tmp/php-fpm.pid
+error_log = /proc/self/fd/2
diff --git a/apps/website/start-website.sh b/apps/website/start-website.sh
new file mode 100644
index 0000000..4750345
--- /dev/null
+++ b/apps/website/start-website.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+set -eu
+
+mkdir -p \
+ /run/apache2 \
+ /var/log/apache2 \
+ "$WEBSITE_LANG_WRITE_DIR" \
+ "${WEBSITE_IDEAS_WRITE_DIR:-/var/www/localhost/htdocs/db/ideas}" \
+ /tmp/website-lang
+
+php-fpm -D
+
+exec httpd -D FOREGROUND
diff --git a/apps/website/web-app.yaml b/apps/website/web-app.yaml
index 1914ec7..a810785 100644
--- a/apps/website/web-app.yaml
+++ b/apps/website/web-app.yaml
@@ -89,10 +89,10 @@ spec:
periodSeconds: 30
resources:
requests:
- cpu: 25m
- memory: 64Mi
+ cpu: 100m
+ memory: 128Mi
limits:
- memory: 256Mi
+ memory: 384Mi
volumeMounts:
- name: apache-run
mountPath: /run/apache2