ctsmedia / docker-contao

Setup Contao Projects with docker
MIT License
19 stars 6 forks source link
contao docker

Contao Docker container using managed edition

Run a fresh Contao installation or contao demo within a minute.

Run clean Contao installation

  1. Download or copy the contents of the docker-compose.yml file. No need to checkout the repository unless you want to build your own specific versions.
  2. Set the contao version you want to run in the docker-compose.yml. Otherwise the latest version will be used. You can find all pre build versions here
  3. Startup docker with docker-compose up -d
  4. Load http://localhost/contao/install in you browser
  5. Proceed with the default installation process

Run Contao demo*

  1. Download or copy the contents of the docker-compose.yml file. No need to checkout the repository unless you want to build your own specific versions.
  2. Startup docker with docker-compose up -d in your terminal and the current folder
  3. Run docker exec --user www-data contao_php bash -c "php ../install-demo.php"
  4. The demo is now running at http://localhost/

Contao Manager

This setup also provides the Contao Manager. You can access it via calling http://localhost/contao-manager.php

Troubleshooting

Versions

You can use minor versions like 4.4 or 4.3 or full versions incl. bugfix releases. Minor version are built against the latest bugfix release. if you choose for example 4.3 it was built using 4.3.11.

See all pre built versions here

Stop containers

  1. Run either docker-compose down or docker-compose down -v. The latter one will also delete the data volume which was used. Good if you want a fresh start.

The demo data prepared for contao 4 is taken from the forums Thanks to Andreas.

Develop Contao Extensions / Bundles

This setup is also perfectly suited for easily develop contao bundles. If you for example develop a bundle named "ctsmedia/test-bundle".

  1. Copy the docker-compose.yml into your bundle folder
  2. Add a bind entry to load your bundle into the container
    
    php:
    image: ctsmedia/contao:latest
    environment:
      DEFAULT_PASSWORD: *password
      PROJECT_NAME: *project
    ports:
      - "9000"
    volumes:
      - /var/www/share/project
      - ./test-bundle:/var/www/share/test-bundle:ro

3. Connect to the container: `docker exec -it contao_php bash`
4. Add the bundle to the contao installation  
4.1 `docker exec --user www-data contao_php bash -c "composer config repositories.test-bundle path ../test-bundle"`   
4.2 `docker exec --user www-data contao_php bash -c "composer require cts/test-bundle:*"` (Make sure the composer.json in test-bundle folder has a version entry. otherwise it can not recognized, we use www-data so we don't get any problems with written files by postcripts) 

## Building 
if you want to build a specific version which is not remotely available you can do so by running:
```bash
docker build -t ctsmedia/contao:4.4.1  --build-arg CONTAO_VERSION=4.4.1  .

Full composer version constraints are allowed. You could for example to the following

docker build -t ctsmedia/contao:4-latest  --build-arg CONTAO_VERSION=^4.4  .

or

docker build -t ctsmedia/contao:4.4-latest  --build-arg CONTAO_VERSION=4.4.*  .