diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e7c65d..a06048e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Makefile b/Makefile index 1c3b3e2..83c2a6b 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ ARGS = $(filter-out $@,$(MAKECMDGOALS)) -all: deploy +all: build ############################# # Create new project @@ -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/*; } diff --git a/README.md b/README.md index 2ae660f..e984e16 100644 --- a/README.md +++ b/README.md @@ -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") @@ -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) -
| -make backup | General backup (run all backup tasks) -make restore | General restore (run all restore tasks) -
| -make mysql-backup | Backup MySQL databases -make mysql-restore | Restore MySQL databases -
| -make solr-backup | Backup Solr cores -make solr-restore | Restore Solr cores -
| -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) -
| -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) -
| -TYPO3_CONTEXT | Context for TYPO3, can be used for TypoScript conditions and AdditionalConfiguration -FLOW_CONTEXT | Context for FLOW and NEOS -
| -MAIL_GATEWAY | Upstream server for sending mails (ssmtp) -DNS_DOMAIN | List of wildcard domains pointing to webserver (eg. for local content fetching) -
| -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 -
| -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! diff --git a/bin/.config.sh b/bin/.config.sh old mode 100644 new mode 100755 diff --git a/bin/backup.sh b/bin/backup.sh old mode 100644 new mode 100755 diff --git a/bin/deploy.sh b/bin/build.sh old mode 100644 new mode 100755 similarity index 100% rename from bin/deploy.sh rename to bin/build.sh diff --git a/bin/create-project.sh b/bin/create-project.sh old mode 100644 new mode 100755 diff --git a/bin/restore.sh b/bin/restore.sh old mode 100644 new mode 100755 diff --git a/docker-compose.yml b/docker-compose.yml index b50dfb8..9b08b2a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,8 +26,8 @@ main: # Webserver ####################################### web: - #build: docker/httpd/ - build: docker/nginx/ + build: docker/httpd/ + #build: docker/nginx/ ports: - 8000:80 - 8443:443 diff --git a/docker-env.yml b/docker-env.yml index b66f36c..ac9f0e3 100644 --- a/docker-env.yml +++ b/docker-env.yml @@ -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 diff --git a/docker/httpd/conf/vhost.conf b/docker/httpd/conf/vhost.conf index a9a406a..03ce65c 100644 --- a/docker/httpd/conf/vhost.conf +++ b/docker/httpd/conf/vhost.conf @@ -29,6 +29,12 @@ SetEnv TYPO3_CONTEXT "" SetEnv FLOW_CONTEXT "" SetEnv FLOW_REWRITEURLS "" +SetEnv MYSQL_USER "" +SetEnv MYSQL_PASSWORD "" +SetEnv MYSQL_ROOT_USER "root" +SetEnv MYSQL_ROOT_PASSWORD "" +SetEnv MYSQL_DATABASE "" + DirectoryIndex index.html index.htm DocumentRoot "" diff --git a/docker/httpd/entrypoint.sh b/docker/httpd/entrypoint.sh index b13a607..2f910a0 100755 --- a/docker/httpd/entrypoint.sh +++ b/docker/httpd/entrypoint.sh @@ -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 ################### @@ -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}@" /usr/local/apache2/conf/docker-vhost.conf -/bin/sed -i "s@@${DOCUMENT_INDEX}@" /usr/local/apache2/conf/docker-vhost.conf -/bin/sed -i "s@@${TYPO3_CONTEXT}@" /usr/local/apache2/conf/docker-vhost.conf -/bin/sed -i "s@@${FLOW_CONTEXT}@" /usr/local/apache2/conf/docker-vhost.conf -/bin/sed -i "s@@${FLOW_REWRITEURLS}@" /usr/local/apache2/conf/docker-vhost.conf -/bin/sed -i "s@@${MAIN_PORT_9000_TCP_ADDR}@" /usr/local/apache2/conf/docker-vhost.conf -/bin/sed -i "s@@${MAIN_PORT_9000_TCP_PORT}@" /usr/local/apache2/conf/docker-vhost.conf -/bin/sed -i "s@@${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}@" /usr/local/apache2/conf/docker-vhost.conf +/bin/sed -i "s@@${DOCUMENT_INDEX}@" /usr/local/apache2/conf/docker-vhost.conf +/bin/sed -i "s@@${ALIAS_DOMAIN}@" /usr/local/apache2/conf/docker-vhost.conf + +/bin/sed -i "s@@${TYPO3_CONTEXT}@" /usr/local/apache2/conf/docker-vhost.conf +/bin/sed -i "s@@${FLOW_CONTEXT}@" /usr/local/apache2/conf/docker-vhost.conf +/bin/sed -i "s@@${FLOW_REWRITEURLS}@" /usr/local/apache2/conf/docker-vhost.conf + +/bin/sed -i "s@@${MAIN_PORT_9000_TCP_ADDR}@" /usr/local/apache2/conf/docker-vhost.conf +/bin/sed -i "s@@${MAIN_PORT_9000_TCP_PORT}@" /usr/local/apache2/conf/docker-vhost.conf + +/bin/sed -i "s@@${MYSQL_USER}@" /usr/local/apache2/conf/docker-vhost.conf +/bin/sed -i "s@@${MYSQL_PASSWORD}@" /usr/local/apache2/conf/docker-vhost.conf +/bin/sed -i "s@@${MYSQL_ROOT_PASSWORD}@" /usr/local/apache2/conf/docker-vhost.conf +/bin/sed -i "s@@${MYSQL_DATABASE}@" /usr/local/apache2/conf/docker-vhost.conf ############################# ## COMMAND diff --git a/docker/main/Dockerfile b/docker/main/Dockerfile index d13284d..c09328f 100644 --- a/docker/main/Dockerfile +++ b/docker/main/Dockerfile @@ -5,7 +5,6 @@ RUN locale-gen en_US.UTF-8 ENV LANG en_US.UTF-8 ENV LC_ALL en_US.UTF-8 -COPY conf/php.ini /etc/php5/mods-available/docker-boilerplate.ini COPY conf/supervisord.conf /etc/supervisor/conf.d/supervisord.conf COPY conf/locale.conf /opt/docker/locale.conf COPY bin/* /opt/docker/ @@ -14,6 +13,8 @@ ADD entrypoint.sh /entrypoint.sh RUN bash /opt/docker/install.sh RUN bash /opt/docker/customization.sh +COPY conf/php.ini /etc/php5/mods-available/docker-boilerplate.ini + EXPOSE 9000 VOLUME /docker/ diff --git a/docker/main/bin/init-system.sh b/docker/main/bin/init-system.sh index 10ed8d4..fb98e9c 100644 --- a/docker/main/bin/init-system.sh +++ b/docker/main/bin/init-system.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash ## Set uid/gid for www-data user -usermod --uid "${PHP_UID}" --shell /bin/bash --home /home www-data > /dev/null -groupmod --gid "${PHP_GID}" www-data > /dev/null +usermod --uid "${EFFECTIVE_UID}" --shell /bin/bash --home /home www-data > /dev/null +groupmod --gid "${EFFECTIVE_GID}" www-data > /dev/null diff --git a/docker/main/bin/install.sh b/docker/main/bin/install.sh index 396908a..29932a8 100644 --- a/docker/main/bin/install.sh +++ b/docker/main/bin/install.sh @@ -49,7 +49,9 @@ apt-get install -y \ php5-xmlrpc \ php5-xsl \ php5-geoip \ - php5-ldap + php5-ldap \ + php5-memcache \ + php5-memcached apt-get install -y \ graphicsmagick \ @@ -72,6 +74,7 @@ locale-gen # Enable php modules ############################# ## custom config +touch /etc/php5/mods-available/docker-boilerplate.ini php5enmod docker-boilerplate ############################# diff --git a/docker/mysql/conf/mysql-docker.cnf b/docker/mysql/conf/mysql-docker.cnf index 75b2cdd..7da9a8d 100644 --- a/docker/mysql/conf/mysql-docker.cnf +++ b/docker/mysql/conf/mysql-docker.cnf @@ -1,5 +1,11 @@ [mysqld] +################################################# +## Charset + +character-set-server=utf8 +collation-server=utf8_general_ci + ################################################# ## Buffers diff --git a/docker/nginx/conf/vhost.conf b/docker/nginx/conf/vhost.conf index 8fbff37..7a953cb 100644 --- a/docker/nginx/conf/vhost.conf +++ b/docker/nginx/conf/vhost.conf @@ -20,10 +20,18 @@ server { fastcgi_pass main:; include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $request_filename; - fastcgi_param TYPO3_CONTEXT ""; - fastcgi_param FLOW_CONTEXT ""; - fastcgi_param FLOW_REWRITEURLS ""; + fastcgi_param SCRIPT_FILENAME $request_filename; + + fastcgi_param TYPO3_CONTEXT ""; + fastcgi_param FLOW_CONTEXT ""; + fastcgi_param FLOW_REWRITEURLS ""; + + fastcgi_param MYSQL_USER ""; + fastcgi_param MYSQL_PASSWORD ""; + fastcgi_param MYSQL_ROOT_USER "root"; + fastcgi_param MYSQL_ROOT_PASSWORD ""; + fastcgi_param MYSQL_DATABASE ""; + fastcgi_read_timeout 1000; } } @@ -58,10 +66,18 @@ server { fastcgi_pass main:; include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $request_filename; - fastcgi_param TYPO3_CONTEXT ""; - fastcgi_param FLOW_CONTEXT ""; - fastcgi_param FLOW_REWRITEURLS ""; + fastcgi_param SCRIPT_FILENAME $request_filename; + + fastcgi_param TYPO3_CONTEXT ""; + fastcgi_param FLOW_CONTEXT ""; + fastcgi_param FLOW_REWRITEURLS ""; + + fastcgi_param MYSQL_USER ""; + fastcgi_param MYSQL_PASSWORD ""; + fastcgi_param MYSQL_ROOT_USER "root"; + fastcgi_param MYSQL_ROOT_PASSWORD ""; + fastcgi_param MYSQL_DATABASE ""; + fastcgi_read_timeout 1000; } } diff --git a/docker/nginx/entrypoint.sh b/docker/nginx/entrypoint.sh index 67b40ad..3b45f44 100755 --- a/docker/nginx/entrypoint.sh +++ b/docker/nginx/entrypoint.sh @@ -1,5 +1,13 @@ #!/bin/bash +################### +# UID/GID +################### + +## Set uid/gid for www-data user +usermod --uid "${EFFECTIVE_UID}" --shell /bin/bash --home /home nginx > /dev/null +groupmod --gid "${EFFECTIVE_GID}" nginx > /dev/null + ################### # vhost ################### @@ -14,14 +22,21 @@ done rm -f -- /etc/nginx/conf.d/*.conf cp /opt/docker/vhost.conf /etc/nginx/conf.d/vhost.conf -/bin/sed -i "s@@${DOCUMENT_ROOT}@" /etc/nginx/conf.d/vhost.conf -/bin/sed -i "s@@${DOCUMENT_INDEX}@" /etc/nginx/conf.d/vhost.conf -/bin/sed -i "s@@${TYPO3_CONTEXT}@" /etc/nginx/conf.d/vhost.conf -/bin/sed -i "s@@${FLOW_CONTEXT}@" /etc/nginx/conf.d/vhost.conf -/bin/sed -i "s@@${FLOW_REWRITEURLS}@" /etc/nginx/conf.d/vhost.conf -/bin/sed -i "s@@${MAIN_PORT_9000_TCP_ADDR}@" /etc/nginx/conf.d/vhost.conf -/bin/sed -i "s@@${MAIN_PORT_9000_TCP_PORT}@" /etc/nginx/conf.d/vhost.conf -/bin/sed -i "s@@${ALIAS_DOMAIN}@" /etc/nginx/conf.d/vhost.conf +/bin/sed -i "s@@${DOCUMENT_ROOT}@" /etc/nginx/conf.d/vhost.conf +/bin/sed -i "s@@${DOCUMENT_INDEX}@" /etc/nginx/conf.d/vhost.conf +/bin/sed -i "s@@${ALIAS_DOMAIN}@" /etc/nginx/conf.d/vhost.conf + +/bin/sed -i "s@@${TYPO3_CONTEXT}@" /etc/nginx/conf.d/vhost.conf +/bin/sed -i "s@@${FLOW_CONTEXT}@" /etc/nginx/conf.d/vhost.conf +/bin/sed -i "s@@${FLOW_REWRITEURLS}@" /etc/nginx/conf.d/vhost.conf + +/bin/sed -i "s@@${MAIN_PORT_9000_TCP_ADDR}@" /etc/nginx/conf.d/vhost.conf +/bin/sed -i "s@@${MAIN_PORT_9000_TCP_PORT}@" /etc/nginx/conf.d/vhost.conf + +/bin/sed -i "s@@${MYSQL_USER}@" /etc/nginx/conf.d/vhost.conf +/bin/sed -i "s@@${MYSQL_PASSWORD}@" /etc/nginx/conf.d/vhost.conf +/bin/sed -i "s@@${MYSQL_ROOT_PASSWORD}@" /etc/nginx/conf.d/vhost.conf +/bin/sed -i "s@@${MYSQL_DATABASE}@" /etc/nginx/conf.d/vhost.conf ############################# ## COMMAND diff --git a/documentation/DOCKER-INFO.md b/documentation/DOCKER-INFO.md new file mode 100644 index 0000000..e0e0349 --- /dev/null +++ b/documentation/DOCKER-INFO.md @@ -0,0 +1,155 @@ +[<-- Back to main section](../README.md) + +# Docker container 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) +
| +make backup | General backup (run all backup tasks) +make restore | General restore (run all restore tasks) +
| +make mysql-backup | Backup MySQL databases +make mysql-restore | Restore MySQL databases +
| +make solr-backup | Backup Solr cores +make solr-restore | Restore Solr cores +
| +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) +
| +make build | Run building (composer, gulp, bower) +make scheduler | Run TYPO3 scheduler +make clean | Clear TYPO3 configuration cache + +## Docker containers + +### 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) +
| +TYPO3_CONTEXT | Context for TYPO3, can be used for TypoScript conditions and AdditionalConfiguration +FLOW_CONTEXT | Context for FLOW and NEOS +
| +MAIL_GATEWAY | Upstream server for sending mails (ssmtp) +DNS_DOMAIN | List of wildcard domains pointing to webserver (eg. for local content fetching) +
| +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 +
| +PHP_TIMEZONE | Timezone (date.timezone) setting for PHP (cli and fpm) +EFFECTIVE_UID | Effective UID for php, fpm und webserver +EFFECTIVE_GID | Effective GID for php, fpm und webserver + +## 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). diff --git a/documentation/DOCKER-QUICKSTART.md b/documentation/DOCKER-QUICKSTART.md new file mode 100644 index 0000000..f14b967 --- /dev/null +++ b/documentation/DOCKER-QUICKSTART.md @@ -0,0 +1,63 @@ +[<-- Back to main section](../README.md) + +# Docker Quickstart + +## Docker short introduction + +Create and start containers (eg. first start): + +```bash +docker-compose up -d +``` + +Stop containers + +```bash +docker-compose stop +``` + +Start containers (only stopped containers) + +```bash +docker-compose start +``` + +Build (but not create and start) containers + +```bash +docker-compose build --no-cache +``` + +Delete container content + +```bash +docker-compose rm --force +``` + +Recreate containers (if there is any issue or just to start from a clean build) + +```bash + docker-compose stop + docker-compose rm --force + docker-compose build --no-cache + docker-compose up -d +``` + +Logs (eg. for debugging) + +```bash +# show all logs +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) + +```bash +docker-compose run --rm main cli help +``` \ No newline at end of file diff --git a/documentation/DOCKER-STARTUP.md b/documentation/DOCKER-STARTUP.md new file mode 100644 index 0000000..896f38d --- /dev/null +++ b/documentation/DOCKER-STARTUP.md @@ -0,0 +1,34 @@ +[<-- Back to main section](../README.md) + +# First startup + +## Create project + +Checkout this project and create and run the Docker containers using [docker-compose](https://github.com/docker/compose): + +```bash +git clone https://github.com/mblaschke/TYPO3-docker-boilerplate.git projectname +cd projectname +docker-compose up -d +``` + +Now create your project inside the docker boilerplate: + +- [Create new TYPO3 project](PROJECT-TYPO3.md) +- [Create new Symfony project](PROJECT-SYMFONY.md) +- [Create new NEOS project](PROJECT-NEOS.md) +- [Running any other php based project](PROJECT-OTHER.md) +- [Running existing project](PROJECT-EXISTING.md) + +For an existing project just put your files into `code/` folder or use git to clone your project into `code/`. + +## 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. diff --git a/documentation/INSTALL.md b/documentation/INSTALL.md new file mode 100644 index 0000000..a2a0a19 --- /dev/null +++ b/documentation/INSTALL.md @@ -0,0 +1,28 @@ +[<-- Back to main section](../README.md) + +# Installation + +## Reqirements + +- 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. + +There is also a [Vagrant VM for VirtualBox, VMware and Parallels](https://github.com/mblaschke/vagrant-development) +with a mailcatcher (Postfix with Dovecot, catches all outgoing mails). + +For more convenience use [CliTools.phar](https://github.com/mblaschke/clitools) (will also run on native Linux, not only inside a Vagrant box) + +## First startup + +```bash +git clone https://github.com/mblaschke/TYPO3-docker-boilerplate.git projectname + +cd projectname + +docker-compose up -d +``` diff --git a/doc/README-EXISTING.md b/documentation/PROJECT-EXISTING.md similarity index 58% rename from doc/README-EXISTING.md rename to documentation/PROJECT-EXISTING.md index d2c9a03..70513b4 100644 --- a/doc/README-EXISTING.md +++ b/documentation/PROJECT-EXISTING.md @@ -6,11 +6,14 @@ Checkout your git repository - $ make create-project git https://github..../ +```bash +make create-project git https://github..../ +``` or manually - - $ git clone --recursive https://github..../ code/ +```bash +git clone --recursive https://github..../ code/ +``` Check `DOCUMENT_ROOT` and `DOCUMENT_INDEX` in `docker-env.yml` @@ -18,8 +21,9 @@ Check `DOCUMENT_ROOT` and `DOCUMENT_INDEX` in `docker-env.yml` You can run one-shot command inside the `main` service container: - $ docker-compose run --rm main any-php-file.php argument1 argument2 - - $ docker-compose run --rm main bash +```bash +docker-compose run --rm main any-php-file.php argument1 argument2 +docker-compose run --rm main bash +``` Webserver is available at Port 8000 diff --git a/doc/README-NEOS.md b/documentation/PROJECT-NEOS.md similarity index 54% rename from doc/README-NEOS.md rename to documentation/PROJECT-NEOS.md index 3cc9755..cafc31d 100644 --- a/doc/README-NEOS.md +++ b/documentation/PROJECT-NEOS.md @@ -1,4 +1,4 @@ -[<-- Back to main section](../README.md) +[<-- Back to main section](DOCKER-STARTUP.md) # Running NEOS @@ -6,14 +6,17 @@ For the first NEOS setup (make sure [composer](https://getcomposer.org/) is installed): - $ make create-project neos +```bash +make create-project neos +``` or - $ rm -f code/.gitkeep - $ composer create-project typo3/neos-base-distribution code/ - $ touch code/.gitkeep - +```bash +rm -f code/.gitkeep +composer create-project typo3/neos-base-distribution code/ +touch code/.gitkeep +``` And change `DOCUMENT_ROOT` in `docker-env.yml`: @@ -26,12 +29,15 @@ most of the time there is no need to enter any Docker container. You can run one-shot command inside the `main` service container: - # commands with root rights - $ docker-compose run --rm main root ./flow core:setfilepermissions +```bash +# commands with root rights +docker-compose run --rm main root ./flow core:setfilepermissions + +# normal commands +docker-compose run --rm main ./flow core:anyothercommand - # normal commands - $ docker-compose run --rm main ./flow core:anyothercommand +docker-compose run --rm main bash +``` - $ docker-compose run --rm main bash Webserver is available at Port 8000 diff --git a/doc/README-OTHER.md b/documentation/PROJECT-OTHER.md similarity index 66% rename from doc/README-OTHER.md rename to documentation/PROJECT-OTHER.md index a49e8ec..4e49c81 100644 --- a/doc/README-OTHER.md +++ b/documentation/PROJECT-OTHER.md @@ -1,4 +1,4 @@ -[<-- Back to main section](../README.md) +[<-- Back to main section](DOCKER-STARTUP.md) # Running any php based project @@ -12,8 +12,9 @@ You can run one-shot command inside the `main` service container: - $ docker-compose run --rm main any-php-file.php argument1 argument2 - - $ docker-compose run --rm main bash +```bash +docker-compose run --rm main any-php-file.php argument1 argument2 +docker-compose run --rm main bash +``` Webserver is available at Port 8000 diff --git a/doc/README-SYMFONY.md b/documentation/PROJECT-SYMFONY.md similarity index 71% rename from doc/README-SYMFONY.md rename to documentation/PROJECT-SYMFONY.md index af94472..4d8e7c3 100644 --- a/doc/README-SYMFONY.md +++ b/documentation/PROJECT-SYMFONY.md @@ -4,7 +4,9 @@ ## Create SYMFONY project - $ make create-project symfony +```bash +make create-project symfony +``` And change `DOCUMENT_ROOT` and `DOCUMENT_ROOT` in `docker-env.yml`: @@ -15,8 +17,9 @@ And change `DOCUMENT_ROOT` and `DOCUMENT_ROOT` in `docker-env.yml`: You can run one-shot command inside the `main` service container: - $ docker-compose run --rm main php code/app/console - - $ docker-compose run --rm main bash +```bash +docker-compose run --rm main php code/app/console +docker-compose run --rm main bash +``` Webserver is available at Port 8000 diff --git a/doc/README-TYPO3.md b/documentation/PROJECT-TYPO3.md similarity index 70% rename from doc/README-TYPO3.md rename to documentation/PROJECT-TYPO3.md index b3e5c8f..a75b0bb 100644 --- a/doc/README-TYPO3.md +++ b/documentation/PROJECT-TYPO3.md @@ -6,14 +6,17 @@ For the first TYPO3 setup (make sure [composer](https://getcomposer.org/) is installed): - $ make create-project typo3 +```bash +make create-project typo3 +``` or - $ rm -f code/.gitkeep - $ composer create-project typo3/cms-base-distribution code/ - $ touch code/FIRST_INSTALL code/.gitkeep - +```bash +rm -f code/.gitkeep +composer create-project typo3/cms-base-distribution code/ +touch code/FIRST_INSTALL code/.gitkeep +``` Feel free to modify your TYPO3 installation in your `code` (a shared folder of Docker), most of the time there is no need to enter any Docker container. @@ -23,9 +26,10 @@ most of the time there is no need to enter any Docker container. You can run one-shot command inside the `main` service container: - $ docker-compose run --rm main typo3/cli_dispatch.phpsh scheduler - - $ docker-compose run --rm main bash +```bash +docker-compose run --rm main typo3/cli_dispatch.phpsh scheduler +docker-compose run --rm main bash +``` Webserver is available at Port 8000 diff --git a/documentation/TROUBLESHOOTING.md b/documentation/TROUBLESHOOTING.md new file mode 100644 index 0000000..0dd8e4b --- /dev/null +++ b/documentation/TROUBLESHOOTING.md @@ -0,0 +1,27 @@ +[<-- Back to main section](../README.md) + +# Troubleshooting + +## Startup or (docker) linking errors (safe reset) + +If you got any startup issues you can try to rebuild `main` and `web` containers. +You won't lose any data with this way - it's a safe reset. + +```bash +docker-compose stop +docker-compose rm --force main web +docker-compose build --no-cache main web +docker-compose up -d +``` + +## Complete reset + +Reset all containers, delete all data (`mysql`, `solr` ..) but not your project files in `code/`! + +```bash +docker-compose stop +docker-compose rm --force +docker-compose build --no-cache +docker-compose up -d +``` + diff --git a/documentation/UPDATE.md b/documentation/UPDATE.md new file mode 100644 index 0000000..a766686 --- /dev/null +++ b/documentation/UPDATE.md @@ -0,0 +1,23 @@ +[<-- Back to main section](../README.md) + +# Update + +## Preparation + +If you have cloned the git repository it's safe to pull the new version. + +If you have used a zip file make sure to replace the `docker/` directory and also +update `docker-compose.yml` and `docker-env.yml`. + +For [changes see CHANGELOG.md](/CHANGELOG.md) + +## Update to 3.4.x +As `PHP_UID` was replaced with `EFFECTIVE_UID` and `PHP_GID` was replaced with `EFFECTIVE_GID` you +have to rebuild all containers with this variables: `main` and `web` + +```bash +docker-compose stop +docker-compose rm --force main web +docker-compose build --no-cache main web +docker-compose up +```