Public | Automated Build

Last pushed: 6 months ago
Short Description
TYPO3 CMS on Ubuntu 14.04, PHP-FPM and nginx.
Full Description

Docker TYPO3 CMS


Container with TYPO3 CMS, served by nginx and PHP-FPM. As of January 2016 on PHP7.
Great for learning, testing and demo's. Don't use in production!

This little project was started to get some personal experience with multiple Docker-containers and TYPO3.
Keep in mind there are far better alternatives to be found, for example the TYPO3-docker-boilerplate!

The TYPO3-container needs a MySQL-container to link to.
I started out in 2014 with "paintedfox/mariadb", but swapped to the official Docker image "percona:56" by the end of January 2016.

I was inspired by and have borrowed from paimpozhil/magento-docker.

Quick start

  • Install Docker and docker-compose
  • Clone this repository: git clone https://github.com/hbokh/docker-typo3-cms.git .
  • cd docker-typo3-cms
  • Run docker-compose -p typo3 up ("typo3" is the projectname)
  • In a browser connect to the IP address of the Docker host. Most of the time this is localhost or 192.168.99.100. http://<$DOCKER_HOST_IP>/
  • Step [1] needs no extra input
  • In step "[2] Database connection", use typo3 / p4ssw0rd for Username / Password and db for Host.
  • In step "[3] Select database", select "Use an existing empty database: TYPO3"
  • In step "[4] Create user and import base data" add an admin-user with any password
  • In step [5], if you want a pre-configured site, select "Yes"
  • Login with the admin-account and the password you just set. Done!

If you need to restart after the stack has been stopped, use docker-compose up --no-recreate. This will prevent the containers from being recreated.

Manually

First install and start the database:
docker run -td --name db -e MYSQL_ROOT_PASSWORD=p4ssw0rd -e MYSQL_USER=typo3 -e MYSQL_PASSWORD=p4ssw0rd -e MYSQL_DATABASE=TYPO3 percona:latest

Followed by the webserver on port 80 and linked to the database:
docker run -td --name typo3-cms -p 80:80 --link db:db hbokh/docker-typo3-cms

Next go through the same steps as mentioned in the Quick start.

TYPO3 Introduction Package

I suggest you install the TYPO3 Introduction Package to get started:

Opcache Control Panel

To check and control the Zend OPcache, Opcache Control Panel is installed in the webroot.
Source on Github Gist: ck-on/ocp.php
Connect to OCP:http://<DOCKER_HOST_IP>/ocp.php

Build the container from source

git clone https://github.com/hbokh/docker-typo3-cms.git .
cd docker-typo3-cms
docker build --rm=true -t hbokh/docker-typo3-cms .
docker pull percona:latest
docker run -td -p 80:80 --link db:db hbokh/docker-typo3-cms

RealURL extension

Unless you prefer URLs like http://localhost/index.php?id=34, you might want to install the RealURL extension: "Speaking URLs for TYPO3 / realurl / v2.1.4 (stable)".
Cleaning the caches afterward might be needed.

Issues

  • The issue with the trustedHostsPattern was fixed in start.sh with a suggestion by Giovanni Minniti. (20151227)

  • When running the DB-instance and webserver in seperate containers on separate hosts (e.g. when using Rancher), these environment setting have to be set too: DB_ENV_USER=typo3 and DB_ENV_PASS=p4ssw0rd. If not, an error like this will be shown in the container-log of the DB:

    Access denied for user 'root'@'<IP-address>' (using password: NO)

For some reason this is not needed when running on the same Docker-host.

TODO

  • Mount external data inside the container.
Docker Pull Command
Owner
hbokh
Source Repository

Comments (3)
hbokh
2 years ago

Thank you Giovanni! I included your fix for trustedHostPattern. The env-settings didn't work however.

giminni
2 years ago

Hi hbokh,
I have some givebacks to your valuable work.
Problem:

  • [1] can't enter a different user/pwd than mariadb/p4ssw0rd
  • [2] can't use any other alias than db
  • [3] Installation fails while trustedHostsPattern was not set

Solution: (all changes are located in /start.sh)
[1] & [2]

...
if [[ -e /firstrun ]]; then
echo "Not first run so skipping initialization"
else
# Read any link alias
if [ "$(env | grep ENV_USER | wc -l)" -gt 1 ]; then
        unset DB_ENV_USER
        unset DB_ENV_PASS
fi
ALIAS_PFX="$(env | grep ENV_USER | cut -d'_' -f1)"
VAR_USER="${ALIAS_PFX}_ENV_USER"
VAR_PASS="${ALIAS_PFX}_ENV_PASS"
VAR_ADDR="${ALIAS_PFX}_PORT_3306_TCP_ADDR"
VAR_PORT="${ALIAS_PFX}_PORT_3306_TCP_PORT"
DB_ENV_USER="${!VAR_USER}"
DB_ENV_PASS="${!VAR_PASS}"
DB_PORT_3306_TCP_ADDR="${!VAR_ADDR}"
DB_PORT_3306_TCP_PORT="${!VAR_PORT}"
...

[3]

...
# Insert trustedHostsPattern to allow a successful installation

mkdir -p /var/www/site/htdocs/typo3conf
touch /var/www/site/htdocs/typo3conf/ENABLE_INSTALL_TOOL
cat << EOF > /var/www/site/htdocs/typo3conf/AdditionalConfiguration.php
<?php
\$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = '.*'
?>
EOF
chown -R www-data:www-data /var/www/site/htdocs/typo3conf
chmod 2770 /var/www/site/htdocs/typo3conf
chmod -R 660 /var/www/site/htdocs/typo3conf/

touch /var/www/site/htdocs/FIRST_INSTALL
touch /firstrun
...
giminni
2 years ago

Hi hbokh,
thx for this great docker app. It is my first example to learn how things works together.
Just to contribute what I have learned so far is: If a container is linked together with another container (e.g. mariadb and typo3-cms. The linkalias db in maria:db is the prefix for all imported environment variables in typo3-cms. (e.g. DB_XXXXX). You can avoid this situation if the typo3-cms script (script.sh) would be more intelligent detecting this behavior at init time.
My 2 cent :-)