Improve Docker image
- Fixes bug in DB volume set in the wrong container.
- Adds persistence for PHP sessions between container recreations.
- Adds production settings to php.ini (error and log settings).
Fixed: pastanagapp:1
Change-Id: Ibfeee630f514f09ec033a9316c37c69441e4fd7a
diff --git a/Dockerfile b/Dockerfile
index 2a32252..7f3d694 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,8 +1,15 @@
FROM php:8.1-apache
RUN docker-php-ext-install mysqli
RUN docker-php-ext-enable mysqli
+RUN mkdir -p /var/phpsessions && chown www-data /var/phpsessions
+VOLUME /var/phpsessions
RUN cd /usr/local/etc/php/conf.d/ && \
+ echo 'display_errors = Off' >> /usr/local/etc/php/conf.d/docker-php-custom.ini && \
+ echo 'display_startup_errors = Off' >> /usr/local/etc/php/conf.d/docker-php-custom.ini && \
+ echo 'error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT' >> /usr/local/etc/php/conf.d/docker-php-custom.ini && \
+ echo 'log_errors = On' >> /usr/local/etc/php/conf.d/docker-php-custom.ini && \
echo 'memory_limit = 128M' >> /usr/local/etc/php/conf.d/docker-php-custom.ini && \
echo 'session.gc_maxlifetime = 604800' >> /usr/local/etc/php/conf.d/docker-php-custom.ini && \
- echo 'session.cookie_lifetime = 604800' >> /usr/local/etc/php/conf.d/docker-php-custom.ini
+ echo 'session.cookie_lifetime = 604800' >> /usr/local/etc/php/conf.d/docker-php-custom.ini && \
+ echo 'session.save_path = /var/phpsessions' >> /usr/local/etc/php/conf.d/docker-php-custom.ini
COPY ./ /var/www/html/