Revert ports fowarding for MySQL and MariaDB

Include production docker compose file
This commit is contained in:
Mahmoud Zalt 2016-10-09 16:51:18 -04:00
parent 3abb6152c8
commit 7ecb712e76
3 changed files with 101 additions and 17 deletions

View File

@ -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
<br>
<a name="LaraDock-for-Production"></a>
### 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).
<br>
<a name="Digital-Ocean"></a>
### 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
<a name="MySQL-access-from-host"></a>
### 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).
<a name="Use-custom-Domain"></a>
### Use custom Domain (instead of the Docker IP)

View File

@ -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 #####################################

View File

@ -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 ###############################