From 7ecb712e764e5450c48eadcda3031d02a0176005 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Sun, 9 Oct 2016 16:51:18 -0400 Subject: [PATCH] Revert ports fowarding for MySQL and MariaDB Include production docker compose file --- README.md | 27 +++++++++++++--- docker-compose.yml | 30 +++++++++-------- production-docker-compose.yml | 61 +++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 17 deletions(-) create mode 100644 production-docker-compose.yml diff --git a/README.md b/README.md index 1df27d40..91a35a25 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ It's like Laravel Homestead but for Docker instead of Vagrant. - [Install xDebug](#Install-xDebug) - [Start/Stop xDebug](#Controll-xDebug) - [Production](#Production) + - [Prepare LaraDock for Production](#LaraDock-for-Production) - [Setup Laravel and Docker on Digital Ocean](#Digital-Ocean) - [Misc](#Misc) - [Cron jobs](#CronJobs) @@ -922,6 +923,26 @@ To controll the behavior of xDebug (in the `php-fpm` Container), you can run the +
+ +### Prepare LaraDock for Production + +It's recommended for production to create a custom `docker-compose.yml` file. For that reason LaraDock is shipped with `production-docker-compose.yml` which should contain only the containers you are planning to run on production (usage exampe: `docker-compose -f production-docker-compose.yml up -d nginx mysql redis ...`). + +Note: The Database (MySQL/MariaDB/...) ports should not be forwarded on production, because Docker will automatically publish the port on the host, which is quite insecure, unless specifically told not to. So make sure to remove these lines: + +``` +ports: + - "3306:3306" +``` + +To learn more about how Docker publishes ports, please read [this excellent post on the subject](https://fralef.me/docker-and-iptables.html). + + + + + +
### Setup Laravel and Docker on Digital Ocean @@ -954,14 +975,12 @@ You can add your cron jobs to `workspace/crontab/root` after the `php artisan` l ### MySQL access from host -You can forward the MySQL/MariaDB port to your host by adding the lines +You can forward the MySQL/MariaDB port to your host by making sure these lines are added to the `mysql` or `mariadb` section of the `docker-compose.yml` or in your [environment specific Compose](https://docs.docker.com/compose/extends/) file. + ``` ports: - "3306:3306" ``` -To the `mysql` or `mariadb` section of the LaraDock `docker-compose.yml` or in your [environment specific Compose](https://docs.docker.com/compose/extends/) file. - -The MySQL port is not forwarded by default because Docker will automatically publish the port on the host, which is quite insecure, unless specifically told not to. To learn more about how Docker publishes ports, please read [this excellent post on the subject](https://fralef.me/docker-and-iptables.html). ### Use custom Domain (instead of the Docker IP) diff --git a/docker-compose.yml b/docker-compose.yml index 8b81cd05..aa26e5cd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -104,6 +104,22 @@ services: build: ./mysql volumes_from: - volumes_data + ports: + - "3306:3306" + environment: + MYSQL_DATABASE: homestead + MYSQL_USER: homestead + MYSQL_PASSWORD: secret + MYSQL_ROOT_PASSWORD: root + +### MariaDB Container ####################################### + + mariadb: + build: ./mariadb + volumes_from: + - volumes_data + ports: + - "3306:3306" environment: MYSQL_DATABASE: homestead MYSQL_USER: homestead @@ -123,18 +139,6 @@ services: POSTGRES_USER: homestead POSTGRES_PASSWORD: secret -### MariaDB Container ####################################### - - mariadb: - build: ./mariadb - volumes_from: - - volumes_data - environment: - MYSQL_DATABASE: homestead - MYSQL_USER: homestead - MYSQL_PASSWORD: secret - MYSQL_ROOT_PASSWORD: root - ### Neo4j Container ######################################### neo4j: @@ -177,7 +181,7 @@ services: - "3001:3001" - "3002:3002" - "3003:3003" - + ### Memcached Container ##################################### diff --git a/production-docker-compose.yml b/production-docker-compose.yml new file mode 100644 index 00000000..15781f16 --- /dev/null +++ b/production-docker-compose.yml @@ -0,0 +1,61 @@ +version: '2' + +services: + +### Workspace Utilities Container ########################### + + workspace: + build: + context: ./workspace + args: + - INSTALL_XDEBUG=false + - INSTALL_MONGO=false + - INSTALL_NODE=false + - INSTALL_DRUSH=false + - INSTALL_AEROSPIKE_EXTENSION=false + - COMPOSER_GLOBAL_INSTALL=false + - INSTALL_WORKSPACE_SSH=false + - PUID=1000 + - PGID=1000 + - NODE_VERSION=stable + volumes_from: + - volumes_source + ports: + - "22:22" + tty: true + +### PHP-FPM Container ####################################### + + php-fpm: + build: + context: ./php-fpm + args: + - INSTALL_XDEBUG=false + - INSTALL_MONGO=false + - INSTALL_ZIP_ARCHIVE=false + - INSTALL_MEMCACHED=false + - INSTALL_OPCACHE=false + - INSTALL_AEROSPIKE_EXTENSION=false + dockerfile: Dockerfile-70 + volumes_from: + - volumes_source + expose: + - "9000" + links: + - workspace + +### Laravel Application Code Container ###################### + + volumes_source: + image: tianon/true + volumes: + - ../:/var/www/laravel + +### Databases Data Container ################################ + + volumes_data: + image: tianon/true + volumes: +# - ./data/mysql:/var/lib/mysql + +### Add All your Software Containers below ###############################