Skip to content

Commit

Permalink
Merge branch 'release/3.4.0'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
  • Loading branch information
mblaschke committed Jun 15, 2015
2 parents 3a8448a + ed4c157 commit a87e7c6
Show file tree
Hide file tree
Showing 29 changed files with 513 additions and 307 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
TYPO3 Docker Boilerplate Changelog
==================================

3.4.0 - 2015-06-15
-------------------------------------
- Renamed `PHP_UID` and `PHP_GID` to `EFFECTIVE_UID` and `EFFECTIVE_GID`
- Set Apache HTTPd and Nginx UID to `EFFECTIVE_UID` and `EFFECTIVE_GID`
- Renamed `make deploy` to `make build` (was confusing)
- Fixed MySQL default charset (set to utf8)
- Added `MYSQL_USER`, `MYSQL_PASSWORD`, `MYSQL_ROOT_USER`, `MYSQL_ROOT_PASSWORD` and `MYSQL_DATABASE` for nginx/apache/php-fpm
- Improved customization of `php.ini`
- Improved documentation
- Added php memcache and memcached

3.3.1 - 2015-05-11
-------------------------------------
- Fixed ssl certificate
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARGS = $(filter-out $@,$(MAKECMDGOALS))

all: deploy
all: build

#############################
# Create new project
Expand Down Expand Up @@ -40,8 +40,8 @@ solr-restore:
backup: mysql-backup solr-backup
restore: mysql-restore solr-restore

deploy:
bash bin/deploy.sh
build:
bash bin/build.sh

clean:
test -d code/typo3temp && { rm -rf code/typo3temp/*; }
Expand Down
259 changes: 21 additions & 238 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Dockerized PHP web project boilerplate

![latest v3.3.1](https://img.shields.io/badge/latest-v3.3.1-green.svg?style=flat)
![latest v3.4.0](https://img.shields.io/badge/latest-v3.4.0-green.svg?style=flat)
![License MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/mblaschke/typo3-docker-boilerplate.svg)](http://isitmaintained.com/project/mblaschke/typo3-docker-boilerplate "Average time to resolve an issue")
[![Percentage of issues still open](http://isitmaintained.com/badge/open/mblaschke/typo3-docker-boilerplate.svg)](http://isitmaintained.com/project/mblaschke/typo3-docker-boilerplate "Percentage of issues still open")
Expand All @@ -26,249 +26,32 @@ Configuration of each docker container is available in the `docker/` directory -
This boilerplate can also be used for any other web project eg. Symfony, Magento and more.
Just customize the makefile for your needs

Warning: Don't use this Docker containers for production - they are only for development. If you find it usefull for production please contact me.
Warning: There may be issues when using it in production - if you have any success stories please contact me.

Use can use my [Vagrant Development VM](https://github.com/mblaschke/vagrant-development) for this Docker boilerplate, eg. for easy creating new boilerplate installations with an easy shell command: `ct docker:create directory`

## Requirements
## Table of contents

- GNU/Linux with Docker (recommendation: Vagrant VM with Docker or native Linux with Docker)
- make
- [composer](https://getcomposer.org/)
- [docker-compose](https://github.com/docker/compose)

If you want to run a Docker VM make sure you're using VMware or Parallels Desktop because of
the much faster virtualisation (networking, disk access, shared folders) compared to VirtualBox.

For more convenience use [CliTools.phar](https://github.com/mblaschke/vagrant-clitools) (will also run on native Linux, not only inside a Vagrant box)

## Docker short introduction

Create and start containers (eg. first start):

$ docker-compose up -d

Stop containers

$ docker-compose stop

Start containers (only stopped containers)

$ docker-compose start

Build (but not create and start) containers

$ docker-compose build --no-cache

Delete container content

$ docker-compose rm --force

Recreate containers (if there is any issue or just to start from a clean build)

$ docker-compose stop
$ docker-compose rm --force
$ docker-compose build --no-cache
$ docker-compose up -d

Logs (eg. for debugging)

$ docker-compose logs

# or only php
$ docker-compose logs main

# or only php and webserver
$ docker-compose logs main web

CLI script (defined in docker-env.yml)

$ docker-compose run --rm main cli help


## Create project

First create and run the Docker containers using [docker-compose](https://github.com/docker/compose):

$ docker-compose up -d

Now create the project:

- [Create new TYPO3 project](doc/README-TYPO3.md)
- [Create new NEOS project](doc/README-NEOS.md)
- [Create new Symfony project](doc/README-SYMFONY.md)
- [Running any other php based project](doc/README-OTHER.md)
- [Running existing project](doc/README-EXISTING.md)

For an existing project just put your files into `code/` folder or use git to clone your project into `code/`.


## Informations

### Docker layout

Container | Description
------------------------- | -------------------------------
main | Main container with PHP-FPM and tools (your entrypoint for bash, php and other stuff)
storage | Storage container, eg. for Solr data
web | Apache HTTPD or Nginx webserver
mysql | MySQL database
solr (optional) | Apache Solr server
elasticsearch (optional) | Elasticsearch server
memcached (optional) | Memcached server
redis (optional) | Redis server

This directory will be mounted under `/docker` in `main` and `web` container.

### Makefile

Customize the [Makefile](Makefile) for your needs.

Command | Description
------------------------- | -------------------------------
make bash | Enter main container with bash (user www-data)
make root | Enter main container with bash (user root)
<br> |
make backup | General backup (run all backup tasks)
make restore | General restore (run all restore tasks)
<br> |
make mysql-backup | Backup MySQL databases
make mysql-restore | Restore MySQL databases
<br> |
make solr-backup | Backup Solr cores
make solr-restore | Restore Solr cores
<br> |
make create-cms-project | Create new TYPO3 project (based on typo3/cms-base-distribution)
make create-neos-project | Create new NEOS project (based on typo3/neos-base-distribution)
<br> |
make deploy | Run deployment (composer, gulp, bower)
make scheduler | Run TYPO3 scheduler
make clean | Clear TYPO3 configuration cache

### Web (Nginx or Apache HTTPd)

Setting | Value
------------- | -------------
Host | web:80 and web:443 (ssl)
External Port | 8000 and 8443 (ssl)

### MySQL

You can choose between [MySQL](https://www.mysql.com/) (default), [MariaDB](https://www.mariadb.org/)
and [PerconaDB](http://www.percona.com/software) in `docker/mysql/Dockerfile`

Setting | Value
------------- | -------------
User | dev (if not changed in env)
Password | dev (if not changed in env)
Database | typo3 (if not changed in env)
Host | mysql:3306
External Port | 13306

Access fo MySQL user "root" and "dev" will be allowed from external hosts (eg. for debugging, dumps and other stuff).


### Solr

Setting | Value
------------- | -------------
Host | solr:8983
External Port | 18983
Cores | docker/solr/conf/solr.xml (data dirs are created automatically)

### Elasticsearch (disabled by default)

Setting | Value
------------- | -------------
Host | elasticsearch:9200 and :9300
External Port | 19200 and 19300

### Redis

Setting | Value
------------- | -------------
Host | redis
Port | 6379

### Memcached

Setting | Value
------------- | -------------
Host | memcached
Port | 11211

### Mailcatcher

Setting | Value
------------- | -------------
Host | mail
SMTP port | 1025
Web port | 1080

### Environment settings

Environment | Description
--------------------- | -------------
DOCUMENT_ROOT | Document root for Nginx and Apache HTTPD, can be absolute or relative (to /docker inside the container).
DOCUMENT_INDEX | Default document index file for Nginx and Apache HTTPd
CLI_SCRIPT | Target for "cli" command of main container
CLI_USER | User which should be used to run CLI scripts (normally www-data, equals php-fpm user)
<br> |
TYPO3_CONTEXT | Context for TYPO3, can be used for TypoScript conditions and AdditionalConfiguration
FLOW_CONTEXT | Context for FLOW and NEOS
<br> |
MAIL_GATEWAY | Upstream server for sending mails (ssmtp)
DNS_DOMAIN | List of wildcard domains pointing to webserver (eg. for local content fetching)
<br> |
MYSQL_ROOT_PASSWORD | Password for MySQL user "root"
MYSQL_USER | Initial created MySQL user
MYSQL_PASSWORD | Password for initial MySQL user
MYSQL_DATABASE | Initial created MySQL database
<br> |
PHP_TIMEZONE | Timezone (date.timezone) setting for PHP (cli and fpm)
PHP_UID | Effective UID for www-data (cli and fpm)
PHP_GID | Effective GID for www-data (cli and fpm)

### Xdebug Remote debugger (PhpStorm)

Add a server (Preferences -> PHP -> Servers):

Setting | Value
----------------------- | -------------
Hostname | IP or Hostname of VM
Port | 8000
Use path mappings | Check
Path mapping of code | /docker/code/

Add a debug connection (Run -> Edit -> Connections) and create a new connection.

Setting | Value
--------------------- | -------------
Server | Server you created before
Start URL | /
Browser | Choose one

Save, set a break point and test the debugger.

## Application cache

Symlink your application cache (eg. typo3temp/) to `/data/cache/` and it will be stored inside the `storage` container
so it will be accessable within all containers (eg. web or main).

## Advanced usage (git)

Use this boilerplate as template and customize it for each project. Put this Docker
configuration for each project into seperate git repositories.

Now set your existing project repository to be a git submodule in `code/`.
Every developer now needs only to clone the Docker repository with `--recursive` option
to get both, the Docker configuration and the TYPO3 installation.

For better useability track a whole branch (eg. develop or master) as submodule and not just a single commit.
- [Installation and requirements](/documentation/INSTALL.md)
- [Updating docker boilerplate](/documentation/UPDATE.md)
- [Docker Quickstart](/documentation/DOCKER-QUICKSTART.md)
- [Run your project](/documentation/DOCKER-STARTUP.md)
- [Container detail info](/documentation/DOCKER-INFO.md)
- [Troubleshooting](/documentation/TROUBLESHOOTING.md)
- [Changelog](/CHANGELOG.md)

## Credits

This Docker layout is based on https://github.com/denderello/symfony-docker-example/

Thanks to [cron IT GmbH](http://www.cron.eu/) for the inspiration for this Docker boilerplate.
Also thanks to [Ingo Pfennigstorf](https://twitter.com/krautsock) and [Florian Tatzel](https://twitter.com/PanadeEdu) for testing and some usefull ideas.
Thanks for support, ideas and issues ...
- [Ingo Pfennigstorf](https://github.com/ipf)
- [Florian Tatzel](https://github.com/PanadeEdu)
- [Josef Florian Glatz](https://github.com/jousch)
- [Ingo Müller](https://github.com/IngoMueller)
- [Benjamin Rau](https://twitter.com/benjamin_rau)
- [Philipp Kitzberger](https://github.com/Kitzberger)

Thanks to [cron IT GmbH](http://www.cron.eu/) for inspiration.

Did I forget anyone? Send me a tweet or create pull request!
Empty file modified bin/.config.sh
100644 → 100755
Empty file.
Empty file modified bin/backup.sh
100644 → 100755
Empty file.
0 bin/deploy.sh → bin/build.sh
100644 → 100755
File renamed without changes.
Empty file modified bin/create-project.sh
100644 → 100755
Empty file.
Empty file modified bin/restore.sh
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ main:
# Webserver
#######################################
web:
#build: docker/httpd/
build: docker/nginx/
build: docker/httpd/
#build: docker/nginx/
ports:
- 8000:80
- 8443:443
Expand Down
6 changes: 4 additions & 2 deletions docker-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ MYSQL_DATABASE=typo3

# PHP Settings
PHP_TIMEZONE=UTC
PHP_UID=1000
PHP_GID=1000

# Permission settings
EFFECTIVE_UID=1000
EFFECTIVE_GID=1000

# Default cli user (should be www-data)
CLI_USER=www-data
6 changes: 6 additions & 0 deletions docker/httpd/conf/vhost.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ SetEnv TYPO3_CONTEXT "<TYPO3_CONTEXT>"
SetEnv FLOW_CONTEXT "<FLOW_CONTEXT>"
SetEnv FLOW_REWRITEURLS "<FLOW_REWRITEURLS>"

SetEnv MYSQL_USER "<MYSQL_USER>"
SetEnv MYSQL_PASSWORD "<MYSQL_PASSWORD>"
SetEnv MYSQL_ROOT_USER "root"
SetEnv MYSQL_ROOT_PASSWORD "<MYSQL_ROOT_PASSWORD>"
SetEnv MYSQL_DATABASE "<MYSQL_DATABASE>"

DirectoryIndex <DOCUMENT_INDEX> index.html index.htm

DocumentRoot "<DOCUMENT_ROOT>"
Expand Down
33 changes: 24 additions & 9 deletions docker/httpd/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/bin/bash

###################
# UID/GID
###################

## Set uid/gid for www-data user
usermod --uid "${EFFECTIVE_UID}" --shell /bin/bash --home /home daemon > /dev/null
groupmod --gid "${EFFECTIVE_GID}" daemon > /dev/null

###################
# httpd.conf
###################
Expand Down Expand Up @@ -29,15 +37,22 @@ for DOMAIN in $DNS_DOMAIN; do
ALIAS_DOMAIN="${ALIAS_DOMAIN} *.${DOMAIN}"
done

cp /usr/local/apache2/conf/.docker-vhost.conf.original /usr/local/apache2/conf/docker-vhost.conf
/bin/sed -i "s@<DOCUMENT_ROOT>@${DOCUMENT_ROOT}@" /usr/local/apache2/conf/docker-vhost.conf
/bin/sed -i "s@<DOCUMENT_INDEX>@${DOCUMENT_INDEX}@" /usr/local/apache2/conf/docker-vhost.conf
/bin/sed -i "s@<TYPO3_CONTEXT>@${TYPO3_CONTEXT}@" /usr/local/apache2/conf/docker-vhost.conf
/bin/sed -i "s@<FLOW_CONTEXT>@${FLOW_CONTEXT}@" /usr/local/apache2/conf/docker-vhost.conf
/bin/sed -i "s@<FLOW_REWRITEURLS>@${FLOW_REWRITEURLS}@" /usr/local/apache2/conf/docker-vhost.conf
/bin/sed -i "s@<FPM_HOST>@${MAIN_PORT_9000_TCP_ADDR}@" /usr/local/apache2/conf/docker-vhost.conf
/bin/sed -i "s@<FPM_PORT>@${MAIN_PORT_9000_TCP_PORT}@" /usr/local/apache2/conf/docker-vhost.conf
/bin/sed -i "s@<ALIAS_DOMAIN>@${ALIAS_DOMAIN}@" /usr/local/apache2/conf/docker-vhost.conf
cp /usr/local/apache2/conf/.docker-vhost.conf.original /usr/local/apache2/conf/docker-vhost.conf
/bin/sed -i "s@<DOCUMENT_ROOT>@${DOCUMENT_ROOT}@" /usr/local/apache2/conf/docker-vhost.conf
/bin/sed -i "s@<DOCUMENT_INDEX>@${DOCUMENT_INDEX}@" /usr/local/apache2/conf/docker-vhost.conf
/bin/sed -i "s@<ALIAS_DOMAIN>@${ALIAS_DOMAIN}@" /usr/local/apache2/conf/docker-vhost.conf

/bin/sed -i "s@<TYPO3_CONTEXT>@${TYPO3_CONTEXT}@" /usr/local/apache2/conf/docker-vhost.conf
/bin/sed -i "s@<FLOW_CONTEXT>@${FLOW_CONTEXT}@" /usr/local/apache2/conf/docker-vhost.conf
/bin/sed -i "s@<FLOW_REWRITEURLS>@${FLOW_REWRITEURLS}@" /usr/local/apache2/conf/docker-vhost.conf

/bin/sed -i "s@<FPM_HOST>@${MAIN_PORT_9000_TCP_ADDR}@" /usr/local/apache2/conf/docker-vhost.conf
/bin/sed -i "s@<FPM_PORT>@${MAIN_PORT_9000_TCP_PORT}@" /usr/local/apache2/conf/docker-vhost.conf

/bin/sed -i "s@<MYSQL_USER>@${MYSQL_USER}@" /usr/local/apache2/conf/docker-vhost.conf
/bin/sed -i "s@<MYSQL_PASSWORD>@${MYSQL_PASSWORD}@" /usr/local/apache2/conf/docker-vhost.conf
/bin/sed -i "s@<MYSQL_ROOT_PASSWORD>@${MYSQL_ROOT_PASSWORD}@" /usr/local/apache2/conf/docker-vhost.conf
/bin/sed -i "s@<MYSQL_DATABASE>@${MYSQL_DATABASE}@" /usr/local/apache2/conf/docker-vhost.conf

#############################
## COMMAND
Expand Down
Loading

0 comments on commit a87e7c6

Please sign in to comment.