Wallogit.com
2017 © Pedro Peláez
Environment to develop and run TYPO3 in Docker containers
.docker/env.direct.yml and set WEB_PORT.composer create-project t3easy/typo3-bootcamp awesome-project.tld.env.dev to .env and adjust it to your needs, see below and comments in the file for more information
E.g. VHOST=typo3.localhost.localhost vhost, you can access it with Chrome w/o a host entry.docker-compose up -d
bash
docker-compose exec -u www-data typo3 vendor/bin/typo3cms install:setup
bash
docker-compose exec -u www-data typo3 touch /app/private/FIRST_INSTALL
Open http://typo3.localhost/typo3/install.php and configure TYPO3In this file you define the environment you'd like to setup.
There are two examples, .env.dev to start an development environment and .env.prod as a template to build and deploy your project., (*1)
To check the result, run docker-compose config.
To deploy to a swarm write the result to a file docker-compose config > stack.yml and use it docker stack deploy --compose-file stack.yml myproject, (*2)
A unique project name. It must not contain dots. E.g. project-typo3version like company-typo3v11 See https://docs.docker.com/compose/reference/envvars/#compose_project_name for more details, (*3)
Add all necessary compose files separated with :, always start with the root docker-compose.yml to have a proper project name and relative paths.
The settings of the last config wins.
More at https://docs.docker.com/compose/reference/envvars/#compose_file, (*4)
The FQDN of the TYPO3 project.
It gets prefixed for other services, e.g. if you set VHOST to typo3.localhost,
you can reach Adminer at adminer-typo3.localhost and Mailhog at mailhog-typo3.localhost., (*5)
Adds additional names to the TYPO3 web service. The value must start with a comma (,).
Example ,2nd.domain.tld,3rd.domain.tld, (*6)
The name of the docker network that Traefik can use to connect to the web service., (*7)
Define the restart policy for all services.
Should be always for production and no for development., (*8)
The image of the db service, see, (*9)
Example mariadb:10.2, (*10)
Set the password of the root db user.
You should not set the password in the .env file for production setup.
Set it on CLI, (*11)
MYSQL_ROOT_PASSWORD=MyV3rySecretP4sswd docker-compose up -d
or set it in CI variables., (*12)
Bind the db service to a specified ip and port.
Format IP:Port
Use 127.0.0.1: to publish a dynamic port to localhost only.
Use 127.0.0.1:13306 to publish the port 13306.
Use 13306 to publish 13306 to all available IP. ATTENTION! That allows access from anywhere!
The port is mapped to 3306, the MySQL/MariaDB port, inside the container.
See Access the database during development via tcp, (*13)
Build the TYPO3 image with that PHP extensions., (*14)
The port the web container expose. Only if you use .docker/env.direct.yml., (*15)
Names of the Traefik entrypoints, (*16)
To build a productive environment use docker-compose -f .docker/build.yml from the root with an prepared .env
or by setting REDIS and LDAP in the environment of the builder.
If you build on GitLab CI, you can use .docker/env.gitlab.yml to tag your images.
See .gitlab-ci.example.yml., (*17)
See .gitlab-ci.example.yml for an example how to deploy to docker hosts with GitLab CI.
Consider to set COMPOSE_PROJECT_NAME at the deploy job, to be able to deploy the project multiple times to the same docker-host, e.g. testing, staging and live.
https://docs.docker.com/compose/reference/envvars/#compose_project_name, (*18)
A dynamic port is mapped to the database service port 3306. To get this port run:, (*19)
docker-compose ps db
You'll get something like:, (*20)
Name Command State Ports ------------------------------------------------------------------------------------- project_db_1 docker-entrypoint.sh --cha ... Up 127.0.0.1:32770->3306/tcp
where 32770 is the port on the local docker host to connect to., (*21)
To run a command inside the TYPO3 PHP Container use docker-compose:
E.g. flush the cache, (*22)
docker-compose exec -u www-data typo3 typo3cms cache:flush
docker-compose exec -T db sh -c 'exec mysqldump --opt --single-transaction -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE"' > dump.sql
docker-compose exec -T db sh -c 'exec mysql -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE"' < dump.sql # Setup new/development extensions docker-compose exec -u www-data typo3 typo3cms extension:setupactive --verbose
ssh user@server 'TYPO3_CONTEXT="Production" /path/to/typo3cms database:export' | docker-compose exec -T db sh -c 'exec mysql -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE"' # Setup new/development extensions docker-compose exec -u www-data typo3 typo3cms extension:setupactive --verbose
The TYPO3 PHP image does not include mysql or mysqldump binary which are required by typo3-console., (*23)
Start a demo stack: * TYPO3 12 * TYPO3 11 LTS * TYPO3 10 LTS * TYPO3 9 LTS, (*24)