File Dockerfile

Last commit: Fri Feb 17 21:04:55 2023 +0100	Jan Dankert	Docker-healthcheck should install/upgrade the database.
1 FROM alpine:3.13 2 3 LABEL maintainer="Jan Dankert" 4 5 # Install packages 6 RUN apk --update --no-cache add \ 7 apache2 apache2-http2 curl \ 8 php7 php7-apache2 php7-session php7-pdo php7-pdo_mysql php7-pdo_pgsql php7-json php7-ftp php7-iconv php7-openssl php7-mbstring php7-dom php7-xml 9 10 ENV DB_TYPE="mysql" \ 11 DB_HOST="localhost" \ 12 DB_NAME="cms" \ 13 DB_USER="cms" \ 14 DB_PASS="" \ 15 CMS_MOTD="" \ 16 CMS_NAME="OpenRat CMS (Docker)" \ 17 CMS_OPERATOR="" \ 18 CMS_LOG_LEVEL="info" \ 19 CMS_PRODUCTION="true" \ 20 CMS_TIMEZONE="" \ 21 CMS_LANGUAGE="" \ 22 DOCROOT="/var/www/localhost/cms" 23 24 # Configuring apache webserver 25 # - disable access log 26 # - enable HTTP/2 27 RUN sed -i '/CustomLog/s/^/#/g' /etc/apache2/httpd.conf && \ 28 # Enable apache modules 29 sed -i '/LoadModule http2_module/s/^#//g' /etc/apache2/httpd.conf && \ 30 sed -i '/LoadModule vhost_alias_module/s/^#//g' /etc/apache2/httpd.conf && \ 31 # Listening on ports 32 sed -i 's/^Listen 80/Listen 8080\nListen 8081\nListen 8082/g' /etc/apache2/httpd.conf && \ 33 chown apache /var/log/apache2 && \ 34 chown apache /run/apache2 && \ 35 mkdir $DOCROOT && \ 36 mkdir -p /var/www/localhost/public && \ 37 chown apache /var/www/localhost/public && \ 38 # Virtual host for CMS 39 echo "<VirtualHost *:8080>" >> /etc/apache2/httpd.conf && \ 40 echo " DocumentRoot $DOCROOT" >> /etc/apache2/httpd.conf && \ 41 echo "</VirtualHost>" >> /etc/apache2/httpd.conf && \ 42 # Virtual host for generated pages 43 echo "<VirtualHost *:8081>" >> /etc/apache2/httpd.conf && \ 44 echo " DocumentRoot /var/www/localhost/public" >> /etc/apache2/httpd.conf && \ 45 echo " ServerSignature Off" >> /etc/apache2/httpd.conf && \ 46 echo " php_value engine off" >> /etc/apache2/httpd.conf && \ 47 echo "</VirtualHost>" >> /etc/apache2/httpd.conf && \ 48 # Virtual host for multiple domains 49 echo "<VirtualHost *:8082>" >> /etc/apache2/httpd.conf && \ 50 echo " UseCanonicalName Off" >> /etc/apache2/httpd.conf && \ 51 echo " VirtualDocumentRoot /var/www/localhost/public/%0" >> /etc/apache2/httpd.conf && \ 52 echo " ServerSignature Off" >> /etc/apache2/httpd.conf && \ 53 echo " php_value engine off" >> /etc/apache2/httpd.conf && \ 54 echo "</VirtualHost>" >> /etc/apache2/httpd.conf && \ 55 # Directory configuration 56 echo "<Directory \"/var/www/localhost/cms\"> " >> /etc/apache2/httpd.conf && \ 57 echo " AllowOverride None" >> /etc/apache2/httpd.conf && \ 58 echo " Options None" >> /etc/apache2/httpd.conf && \ 59 echo " Require all granted" >> /etc/apache2/httpd.conf && \ 60 echo "</Directory>" >> /etc/apache2/httpd.conf && \ 61 echo "<Directory \"/var/www/localhost/public\"> " >> /etc/apache2/httpd.conf && \ 62 echo " Options Indexes" >> /etc/apache2/httpd.conf && \ 63 echo " AllowOverride None" >> /etc/apache2/httpd.conf && \ 64 echo " Require all granted" >> /etc/apache2/httpd.conf && \ 65 echo "</Directory>" >> /etc/apache2/httpd.conf && \ 66 # Enable HTTP/2 67 echo "Protocols h2 h2c http/1.1" >> /etc/apache2/httpd.conf && \ 68 echo "H2ModernTLSOnly off" >> /etc/apache2/httpd.conf 69 70 # Copy the application to document root 71 COPY . $DOCROOT 72 73 # Place configuration in /etc, outside the docroot. 74 RUN echo "include: /etc/openrat.yml" > $DOCROOT/config/config.yml 75 76 # Create configuration 77 RUN echo -e '\ 78 # OpenRat CMS configuration for Docker\n\ 79 login:\n\ 80 motd: "${env:CMS_MOTD}"\n\ 81 \n\ 82 database-default:\n\ 83 default-id: db\n\ 84 \n\ 85 \n\ 86 database:\n\ 87 db:\n\ 88 enabled : true\n\ 89 dsn : "${env:DB_TYPE}:host=${env:DB_HOST}; dbname=${env:DB_NAME}"\n\ 90 description: "PDO"\n\ 91 name : "PRO"\n\ 92 user : ${env:DB_USER}\n\ 93 password : ${env:DB_PASS}\n\ 94 base64 : true # store binary as BASE64 (should be true for postgresql)\n\ 95 prefix : cms_\n\ 96 suffix : _or\n\ 97 \n\ 98 log:\n\ 99 file : ""\n\ 100 level: "${env:CMS_LOG_LEVEL}"\n\ 101 stdout: true\n\ 102 \n\ 103 production: ${env:CMS_PRODUCTION}\n\ 104 \n\ 105 publish:\n\ 106 filesystem:\n\ 107 directory: /var/www/localhost/public\n\ 108 \n\ 109 application:\n\ 110 name: "${env:CMS_NAME}"\n\ 111 operator: "${env:CMS_OPERATOR}"\n\ 112 ui:\n\ 113 timezone: "${env:CMS_TIMEZONE}"\n\ 114 i18n:\n\ 115 default: "${env:CMS_LANGUAGE}"\n\ 116 \n\ 117 ' >> /etc/openrat.yml 118 119 # Logfiles are redirected to standard out 120 RUN ln -sf /dev/stdout $DOCROOT/log/cms.log && \ 121 ln -sf /dev/stderr /var/log/apache2/error.log 122 123 EXPOSE 8080 124 EXPOSE 8081 125 EXPOSE 8082 126 127 WORKDIR $DOCROOT 128 129 USER apache 130 131 HEALTHCHECK --interval=10s --timeout=5m --retries=1 CMD curl -f http://localhost:8080/status/?upgrade || exit 1 132 CMD /usr/sbin/httpd -D FOREGROUND
Download Dockerfile
History Fri, 17 Feb 2023 21:04:55 +0100 Jan Dankert Docker-healthcheck should install/upgrade the database. Wed, 9 Mar 2022 01:57:45 +0100 dankert Fix: Do not write the language to a cookie. Thu, 18 Nov 2021 00:18:18 +0100 Jan Dankert Fix: Needing php-dom and php-xml for the template compiler (only for development) Sat, 6 Nov 2021 01:35:37 +0100 Jan Dankert New: Healthcheck for Docker container. Sat, 27 Feb 2021 20:12:04 +0100 Jan Dankert Enhanced Docker-Image with a separate port for generated content Thu, 19 Nov 2020 22:43:33 +0100 Jan Dankert New: Configure separate logging endpoints (file, syslog, stdout, stderr), so docker container may write directly to stdout. Thu, 19 Nov 2020 17:59:57 +0100 Jan Dankert New: Control log level with environment variables. Fri, 22 Nov 2019 23:05:44 +0100 Jan Dankert Redirecting logfiles in docker container to standard out and standard error. No logfile should be written in a container. Tue, 19 Nov 2019 20:39:45 +0100 Jan Dankert Fix permissions for preview folder; Added docker documentation. Tue, 19 Nov 2019 19:35:06 +0100 Jan Dankert Fix: Need for PHP multibyte string operation module Tue, 1 Oct 2019 22:25:24 +0200 Jan Dankert New: Enable HTTP/2 with h2c. Tue, 1 Oct 2019 22:19:02 +0200 Jan Dankert New: Enable Logfile in Docker image Tue, 1 Oct 2019 01:14:05 +0200 Jan Dankert Fix: Example configuration for Docker. Tue, 1 Oct 2019 00:31:57 +0200 Jan Dankert New: Install Git, HTTP/2 active Tue, 1 Oct 2019 00:18:35 +0200 Jan Dankert New: Docker-Image is now based on Alpine Linux. Added the USER command for security reasons. Fri, 25 May 2018 01:49:48 +0200 Jan Dankert Dockerfile auf Basis von Debian Stretch