openrat-cms

OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs | README

commit a11dda29f1b0ae75aa5a33e5fed958b90c7762c3
parent ac40092f45820cb1f60f507a12ed29f36f4320ee
Author: Jan Dankert <develop@jandankert.de>
Date:   Sat, 27 Feb 2021 20:12:04 +0100

Enhanced Docker-Image with a separate port for generated content

Diffstat:
MDockerfile | 65++++++++++++++++++++++++++++++++++++++++++++++-------------------
MREADME.md | 105+++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------
Adev-helper/docker/openrat-dev/docker-compose.yml | 41+++++++++++++++++++++++++++++++++++++++++
Mdoc/examples/docker-compose.yml | 7++++++-
Mmodules/cms/generator/target/LocalTarget.class.php | 7++++++-
Mmodules/cms/ui/themes/default/html/views/page/info.php | 6++++++
Mmodules/cms/ui/themes/default/html/views/page/info.tpl.src.xml | 3+++
7 files changed, 184 insertions(+), 50 deletions(-)

diff --git a/Dockerfile b/Dockerfile @@ -5,40 +5,65 @@ LABEL maintainer="Jan Dankert" # Install packages RUN apk --update --no-cache add \ apache2 apache2-http2 \ - php7 php7-apache2 php7-session php7-pdo php7-pdo_mysql php7-pdo_pgsql php7-json php7-ftp php7-iconv php7-openssl php7-mbstring \ - git curl + php7 php7-apache2 php7-session php7-pdo php7-pdo_mysql php7-pdo_pgsql php7-json php7-ftp php7-iconv php7-openssl php7-mbstring ENV DB_TYPE="mysql" \ DB_HOST="localhost" \ DB_NAME="cms" \ DB_USER="cms" \ DB_PASS="" \ - CMS_MOTD="Welcome to dockerized CMS" \ + CMS_MOTD="" \ CMS_NAME="OpenRat CMS (Docker)" \ CMS_OPERATOR="" \ CMS_LOG_LEVEL="info" \ CMS_PRODUCTION="true" \ - DOCROOT="/var/www/localhost/htdocs" + DOCROOT="/var/www/localhost/cms" # Configuring apache webserver # - disable access log # - enable HTTP/2 -RUN sed -i '/CustomLog/s/^/#/g' /etc/apache2/httpd.conf && \ - sed -i '/LoadModule http2_module/s/^#//g' /etc/apache2/httpd.conf && \ - sed -i 's/^Listen 80/Listen 8080/g' /etc/apache2/httpd.conf && \ +RUN sed -i '/CustomLog/s/^/#/g' /etc/apache2/httpd.conf && \ + # Enable apache modules + sed -i '/LoadModule http2_module/s/^#//g' /etc/apache2/httpd.conf && \ + sed -i '/LoadModule vhost_alias_module/s/^#//g' /etc/apache2/httpd.conf && \ + # Listening on ports + sed -i 's/^Listen 80/Listen 8080\nListen 8081\nListen 8082/g' /etc/apache2/httpd.conf && \ chown apache /var/log/apache2 && \ chown apache /run/apache2 && \ - rm -r $DOCROOT/* && \ - mkdir -p /var/www/localhost/preview && \ - chown apache /var/www/localhost/preview && \ - echo "Alias /preview /var/www/localhost/preview" >> /etc/apache2/httpd.conf && \ - echo "<Directory \"/var/www/localhost/preview\"> " >> /etc/apache2/httpd.conf && \ - echo " AllowOverride None" >> /etc/apache2/httpd.conf && \ - echo " Options None" >> /etc/apache2/httpd.conf && \ - echo " Require all granted" >> /etc/apache2/httpd.conf && \ - echo "</Directory>" >> /etc/apache2/httpd.conf && \ - echo "Protocols h2 h2c http/1.1" >> /etc/apache2/httpd.conf && \ - echo "H2ModernTLSOnly off" >> /etc/apache2/httpd.conf + mkdir $DOCROOT && \ + mkdir -p /var/www/localhost/public && \ + chown apache /var/www/localhost/public && \ + # Virtual host for CMS + echo "<VirtualHost *:8080>" >> /etc/apache2/httpd.conf && \ + echo " DocumentRoot $DOCROOT" >> /etc/apache2/httpd.conf && \ + echo "</VirtualHost>" >> /etc/apache2/httpd.conf && \ + # Virtual host for generated pages + echo "<VirtualHost *:8081>" >> /etc/apache2/httpd.conf && \ + echo " DocumentRoot /var/www/localhost/public" >> /etc/apache2/httpd.conf && \ + echo " ServerSignature Off" >> /etc/apache2/httpd.conf && \ + echo " php_value engine off" >> /etc/apache2/httpd.conf && \ + echo "</VirtualHost>" >> /etc/apache2/httpd.conf && \ + # Virtual host for multiple domains + echo "<VirtualHost *:8082>" >> /etc/apache2/httpd.conf && \ + echo " UseCanonicalName Off" >> /etc/apache2/httpd.conf && \ + echo " VirtualDocumentRoot /var/www/localhost/public/%0" >> /etc/apache2/httpd.conf && \ + echo " ServerSignature Off" >> /etc/apache2/httpd.conf && \ + echo " php_value engine off" >> /etc/apache2/httpd.conf && \ + echo "</VirtualHost>" >> /etc/apache2/httpd.conf && \ + # Directory configuration + echo "<Directory \"/var/www/localhost/cms\"> " >> /etc/apache2/httpd.conf && \ + echo " AllowOverride None" >> /etc/apache2/httpd.conf && \ + echo " Options None" >> /etc/apache2/httpd.conf && \ + echo " Require all granted" >> /etc/apache2/httpd.conf && \ + echo "</Directory>" >> /etc/apache2/httpd.conf && \ + echo "<Directory \"/var/www/localhost/public\"> " >> /etc/apache2/httpd.conf && \ + echo " Options Indexes" >> /etc/apache2/httpd.conf && \ + echo " AllowOverride None" >> /etc/apache2/httpd.conf && \ + echo " Require all granted" >> /etc/apache2/httpd.conf && \ + echo "</Directory>" >> /etc/apache2/httpd.conf && \ + # Enable HTTP/2 + echo "Protocols h2 h2c http/1.1" >> /etc/apache2/httpd.conf && \ + echo "H2ModernTLSOnly off" >> /etc/apache2/httpd.conf # Copy the application to document root COPY . $DOCROOT @@ -77,7 +102,7 @@ production: ${env:CMS_PRODUCTION}\n\ \n\ publish:\n\ filesystem:\n\ - directory: /var/www/localhost/preview\n\ + directory: /var/www/localhost/public\n\ \n\ application:\n\ name: "${env:CMS_NAME}"\n\ @@ -90,6 +115,8 @@ RUN ln -sf /dev/stdout $DOCROOT/log/cms.log && \ ln -sf /dev/stderr /var/log/apache2/error.log EXPOSE 8080 +EXPOSE 8081 +EXPOSE 8082 WORKDIR $DOCROOT diff --git a/README.md b/README.md @@ -27,8 +27,82 @@ You need a server with PHP >= 5.5 and a relational database. MariaDB and MySQL are recommended, while PostgresQL and SQLite are supported too. +### Docker + +#### Docker-Compose + +The easiest way is to start the content-management-system inside a docker machine. +Copy the following lines to a file named `docker-compose.yml`. + +``` +version: '3.3' + +services: + db: + image: mysql:5.7 + volumes: + - db_data:/var/lib/mysql + restart: always + environment: + MYSQL_ROOT_PASSWORD: uoia97723sdsd9782 + MYSQL_DATABASE: cms + MYSQL_USER: cms + MYSQL_PASSWORD: dsfg77er35fsd08435 + cms: + depends_on: + - db + image: openrat/openrat-cms:latest + ports: + - "8000:8080" # CMS + - "8001:8081" # public + - "8002:8082" # public with host routing + restart: always + environment: + DB_TYPE: mysql + DB_HOST: db + DB_USER: cms + DB_PASS: dsfg77er35fsd08435 + DB_NAME: cms + CMS_MOTD: + CMS_NAME: Content-Management + CMS_OPERATOR: Your Company + volumes: + db_data: {} +``` + +Start the environment with `docker-compose up -d`. + +Now the CMS is available on http://localhost:8000 +The published website is available on http://localhost:8001 + +#### Run the docker container + +Download and run the docker image from [Dockerhub](https://hub.docker.com/r/openrat/openrat-cms): + +`docker run -d -p 8080:8080 -e DB_HOST=$host -e DB_NAME=$name -e DB_USER=$user -e DB_PASS=$pass openrat/openrat-cms` + +Be sure to replace the variables. You need a database to use this way. + +#### Environment variables for Docker + +The following environment variables could be set in the docker container: + +| Name | Description | Default | +| ----------- | ----------- | ------- | +|DB_TYPE|database type|mysql +|DB_HOST|database hostname|localhost +|DB_NAME|database schema|cms +|DB_USER|database user| +|DB_PASS|database password| +|CMS_MOTD|Message of the day|Welcome to dockerized CMS +|CMS_NAME|Software name|OpenRat CMS (Docker) +|CMS_OPERATOR|Name of your company|Docker-Host + + ### Local installation - + +Of course the old style local installation is possible with the following steps. + #### Download and untar it Download the last release from Github and install it on your server: @@ -48,7 +122,7 @@ or from Github #### Add database configuration Edit the file `config/config.yml` and enter your database access data, like: - + database: db: enabled : true @@ -56,30 +130,3 @@ Edit the file `config/config.yml` and enter your database access data, like: user : "user" password: "password" -### Docker - -OpenRat-CMS is available [at Dockerhub](https://hub.docker.com/r/openrat/openrat-cms). - -#### Run the docker container - -Download and run the docker image from dockerhub: - -`docker run -d -p 8080:8080 -e DB_HOST=$host -e DB_NAME=$name -e DB_USER=$user -e DB_PASS=$pass openrat/openrat-cms` - -Be sure to replace the variables. - -#### Environment variables for Docker - -The following environment variables could be set in the docker container: - -| Name | Description | Default | -| ----------- | ----------- | ------- | -|DB_TYPE|database type|mysql -|DB_HOST|database hostname|localhost -|DB_NAME|database schema|cms -|DB_USER|database user| -|DB_PASS|database password| -|CMS_MOTD|Message of the day|Welcome to dockerized CMS -|CMS_NAME|Software name|OpenRat CMS (Docker) -|CMS_OPERATOR|Name of your company|Docker-Host - diff --git a/dev-helper/docker/openrat-dev/docker-compose.yml b/dev-helper/docker/openrat-dev/docker-compose.yml @@ -0,0 +1,41 @@ +version: '3.3' + +# development environment for openrat cms +services: + db: + image: mysql:5.7 + volumes: + - db_data:/var/lib/mysql + restart: always + environment: + MYSQL_ROOT_PASSWORD: gshsdsdnjshcjk + MYSQL_DATABASE: cms + MYSQL_USER: cms + MYSQL_PASSWORD: dsfg77er35fsd084351 + + cms: + depends_on: + - db + build: ../../../ + ports: + - "8000:8080" # CMS + - "8001:8081" # public + - "8002:8082" # public with host routing + restart: always + volumes: + - cms_public:/var/www/localhost/public + environment: + DB_TYPE: mysql + DB_HOST: db + DB_USER: cms + DB_PASS: dsfg77er35fsd084351 + DB_NAME: cms + CMS_MOTD: + CMS_NAME: OpenRat Development + CMS_OPERATOR: + CMS_PRODUCTION: "false" + CMS_LOG_LEVEL: "debug" + container_name: cms +volumes: + db_data: {} + cms_public: {} diff --git a/doc/examples/docker-compose.yml b/doc/examples/docker-compose.yml @@ -17,7 +17,11 @@ services: - db image: openrat/openrat-cms:latest ports: - - "8000:8080" + - "8000:8080" # CMS + - "8001:8081" # public + - "8002:8082" # public with host routing + volumes: + - cms_public:/var/www/localhost/public restart: always environment: DB_TYPE: mysql @@ -33,3 +37,4 @@ services: container_name: cms volumes: db_data: {} + cms_public: {} diff --git a/modules/cms/generator/target/LocalTarget.class.php b/modules/cms/generator/target/LocalTarget.class.php @@ -57,7 +57,6 @@ class LocalTarget extends BaseTarget $this->localDestinationDirectory = FileUtils::toAbsolutePath([$fileSystemConfig->get('directory','/var/www'),$targetDir]); } - // Sofort pruefen, ob das Zielverzeichnis ueberhaupt beschreibbar ist. if ( $this->localDestinationDirectory && $this->localDestinationDirectory[0] == '#') $this->localDestinationDirectory = ''; @@ -72,12 +71,18 @@ class LocalTarget extends BaseTarget */ public function put($source, $dest, $lastChangeDate) { + // Is the output directory existent? + if ( !is_dir( $this->localDestinationDirectory ) ) + mkdir( $this->localDestinationDirectory ); // try to create this directory. + // Is the output directory writable? if ( !is_writeable( $this->localDestinationDirectory ) ) throw new PublisherException('directory not writable: ' . $this->localDestinationDirectory); + $dest = $this->localDestinationDirectory.'/'.$dest; + // Is the destination writable? if ( is_file($dest) && !is_writeable( $dest ) ) throw new PublisherException('file not writable: ' . $dest); diff --git a/modules/cms/ui/themes/default/html/views/page/info.php b/modules/cms/ui/themes/default/html/views/page/info.php @@ -103,6 +103,12 @@ <span><?php echo O::escapeHtml(''.@$objectid.'') ?></span> </div> </section> + <section class="<?php echo O::escapeHtml('or-fieldset') ?>"><?php echo O::escapeHtml('') ?> + <h3 class="<?php echo O::escapeHtml('or-fieldset-label') ?>"><?php echo O::escapeHtml(''.@O::lang('pageid').'') ?></h3> + <div class="<?php echo O::escapeHtml('or-fieldset-value') ?>"><?php echo O::escapeHtml('') ?> + <span><?php echo O::escapeHtml(''.@$pageid.'') ?></span> + </div> + </section> </div> </section> diff --git a/modules/cms/ui/themes/default/html/views/page/info.tpl.src.xml b/modules/cms/ui/themes/default/html/views/page/info.tpl.src.xml @@ -59,6 +59,9 @@ <fieldset label="${message:id}"> <text value="${objectid}"/> </fieldset> + <fieldset label="${message:pageid}"> + <text value="${pageid}"/> + </fieldset> </group> <include file="../include/timestamps"/> </output>