TYPO3 for docker

Docker container bundle for TYPO3

Tested with TYPO3 v8 and v9. Should be compatible with v7 too!

Preamble

This container bundle provides two/three containers to run your TYPO3 websites with docker. It should also be scalable in case of using things like kubernetes e.g. with AWS.

To-do

  • Make a list of available tools and add them to this page (e.g. deployer, surf)
  • Add examples how to use TYPO3 scheduler
  • Label containers by TYPO3 version for long time compatibility with older versions

Feel free to give feedback :)

Source code and issue tickets

Found an issue? Feel free to create an issue ticket and/or a merge request or if you don´t wan´t to register on my GitLab you can send me a mail via contact form.

You can find the source code of all container on my gitlab.

typo3-apachetypo3-phptypo3-utilities

 

Settings for typo3-apache container

The following things can be configured using environment variables e.g. in your docker-compose file

Environment variabledefault valuedescription

DOCUMENT_ROOT

/usr/local/apache2/htdocs/publicThe entrypoint of your website. Default for composer based projects.

SERVER_ADMIN 

pleaseSetTheEnvironment@variable.tldContact mail that will be displayed in some apache error messages. See here

 

Settings for typo3-utilities container

The following things can be configured using environment variables e.g. in your docker-compose file

Environment variabledefault valuedescription

DOCUMENT_ROOT 

same as typo3-apacheIf you customize this setting on the typo3-apache container then you also need to set the same value for typo3-utilities container! See here

START_SSH_SERVER

trueStarts an openssh server on port 22 if set to true. Put your public key into /home/typo3/.ssh/authorized_keys

 

Example docker-compose

version: '3.7'

services:
  web:
    container_name: mywebsite_web
    depends_on:
      - db
    environment:
      - PHP_SERVICE_NAME=mywebsite_utilities
    image: kronova/typo3-apache
    networks:
      - private
      - web
    ports:
      - 80:80
    restart: always
    volumes:
      - htdocs:/usr/local/apache2/htdocs:ro
  utilities:
    container_name: mywebsite_utilities
    depends_on:
      - db
    image: kronova/typo3-utilities
    networks:
      - private
    ports:
      - "2222:22"
    restart: always
    volumes:
      - htdocs:/usr/local/apache2/htdocs
      - ssh:/home/typo3/.ssh
  db:
    container_name: mywebsite_db
    command:
      - --character-set-server=utf8
      - --collation-server=utf8_unicode_ci
    environment:
      - MYSQL_USER=typo3
      - MYSQL_PASSWORD=badPasswordChangeIt
      - MYSQL_DATABASE=typo3
      - MYSQL_ROOT_PASSWORD=veryBadForRoot
    image: mariadb:10.4
    networks:
      - private
    restart: always
    volumes:
      - mysql:/var/lib/mysql

networks:
  private:
  web:
    external: true
volumes:
  htdocs:
  mysql:
  ssh:

 

 

Example docker-compose with traefik labels

Take a look into this example if you´re using traefik as proxy.

 

version: '3.7'

services:
  web:
    container_name: mywebsite_web
    depends_on:
      - db
    environment:
      - PHP_SERVICE_NAME=mywebsite_utilities
    image: kronova/typo3-apache
    labels:
      - "traefik.docker.network=web"
      - "traefik.enable=true"
      - "traefik.basic.frontend.rule=Host:domain.tld"
      - "traefik.basic.port=80"
      - "traefik.basic.protocol=http"
    networks:
      - private
      - web
    restart: always
    volumes:
      - htdocs:/usr/local/apache2/htdocs:ro
  utilities:
    container_name: mywebsite_utilities
    depends_on:
      - db
    image: kronova/typo3-utilities
    networks:
      - private
    ports:
      - "2222:22"
    restart: always
    volumes:
      - htdocs:/usr/local/apache2/htdocs
      - ssh:/home/typo3/.ssh
  db:
    container_name: mywebsite_db
    command:
      - --character-set-server=utf8
      - --collation-server=utf8_unicode_ci
    environment:
      - MYSQL_USER=typo3
      - MYSQL_PASSWORD=badPasswordChangeIt
      - MYSQL_DATABASE=typo3
      - MYSQL_ROOT_PASSWORD=veryBadForRoot
    image: mariadb:10.4
    networks:
      - private
    restart: always
    volumes:
      - mysql:/var/lib/mysql
networks:
  private:
  web:
    external: true
volumes:
  htdocs:
  mysql:
  ssh:

 

 

Use TYPO3 scheduler

Install crontab on your host and add the following lines to your crontab configuration using crontab -e:

Examples:

TYPO3 without composer:

 

*/5 * * * *     docker exec -u typo3 mywebsite_utilities  /usr/local/apache2/htdocs/typo3/sysext/core/bin/typo3 scheduler:run

 

TYPO3 with composer:

 

*/5 * * * *     docker exec -u typo3 mywebsite_utilities  /usr/local/apache2/htdocs/typo3/public/sysext/core/bin/typo3 scheduler:run

 

TYPO3 with composer and surf deployment:

 

*/5 * * * *     docker exec -u typo3 mywebsite_utilities  /usr/local/apache2/htdocs/releases/current/web/typo3/sysext/core/bin/typo3 scheduler:run

 

TYPO3 with composer and deployer deployment:

 

*/5 * * * *     docker exec -u typo3 mywebsite_utilities  /usr/local/apache2/htdocs/current/public/typo3/sysext/core/bin/typo3 scheduler:run