Skip to content

Commit 7ecb712

Browse files
committed
Revert ports fowarding for MySQL and MariaDB
Include production docker compose file
1 parent 3abb615 commit 7ecb712

3 files changed

Lines changed: 101 additions & 17 deletions

File tree

README.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ It's like Laravel Homestead but for Docker instead of Vagrant.
5858
- [Install xDebug](#Install-xDebug)
5959
- [Start/Stop xDebug](#Controll-xDebug)
6060
- [Production](#Production)
61+
- [Prepare LaraDock for Production](#LaraDock-for-Production)
6162
- [Setup Laravel and Docker on Digital Ocean](#Digital-Ocean)
6263
- [Misc](#Misc)
6364
- [Cron jobs](#CronJobs)
@@ -922,6 +923,26 @@ To controll the behavior of xDebug (in the `php-fpm` Container), you can run the
922923

923924

924925

926+
<br>
927+
<a name="LaraDock-for-Production"></a>
928+
### Prepare LaraDock for Production
929+
930+
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 ...`).
931+
932+
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:
933+
934+
```
935+
ports:
936+
- "3306:3306"
937+
```
938+
939+
To learn more about how Docker publishes ports, please read [this excellent post on the subject](https://fralef.me/docker-and-iptables.html).
940+
941+
942+
943+
944+
945+
925946
<br>
926947
<a name="Digital-Ocean"></a>
927948
### 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
954975
<a name="MySQL-access-from-host"></a>
955976
### MySQL access from host
956977
957-
You can forward the MySQL/MariaDB port to your host by adding the lines
978+
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.
979+
958980
```
959981
ports:
960982
- "3306:3306"
961983
```
962-
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.
963-
964-
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).
965984
966985
<a name="Use-custom-Domain"></a>
967986
### Use custom Domain (instead of the Docker IP)

docker-compose.yml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,22 @@ services:
104104
build: ./mysql
105105
volumes_from:
106106
- volumes_data
107+
ports:
108+
- "3306:3306"
109+
environment:
110+
MYSQL_DATABASE: homestead
111+
MYSQL_USER: homestead
112+
MYSQL_PASSWORD: secret
113+
MYSQL_ROOT_PASSWORD: root
114+
115+
### MariaDB Container #######################################
116+
117+
mariadb:
118+
build: ./mariadb
119+
volumes_from:
120+
- volumes_data
121+
ports:
122+
- "3306:3306"
107123
environment:
108124
MYSQL_DATABASE: homestead
109125
MYSQL_USER: homestead
@@ -123,18 +139,6 @@ services:
123139
POSTGRES_USER: homestead
124140
POSTGRES_PASSWORD: secret
125141

126-
### MariaDB Container #######################################
127-
128-
mariadb:
129-
build: ./mariadb
130-
volumes_from:
131-
- volumes_data
132-
environment:
133-
MYSQL_DATABASE: homestead
134-
MYSQL_USER: homestead
135-
MYSQL_PASSWORD: secret
136-
MYSQL_ROOT_PASSWORD: root
137-
138142
### Neo4j Container #########################################
139143

140144
neo4j:
@@ -177,7 +181,7 @@ services:
177181
- "3001:3001"
178182
- "3002:3002"
179183
- "3003:3003"
180-
184+
181185

182186
### Memcached Container #####################################
183187

production-docker-compose.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
version: '2'
2+
3+
services:
4+
5+
### Workspace Utilities Container ###########################
6+
7+
workspace:
8+
build:
9+
context: ./workspace
10+
args:
11+
- INSTALL_XDEBUG=false
12+
- INSTALL_MONGO=false
13+
- INSTALL_NODE=false
14+
- INSTALL_DRUSH=false
15+
- INSTALL_AEROSPIKE_EXTENSION=false
16+
- COMPOSER_GLOBAL_INSTALL=false
17+
- INSTALL_WORKSPACE_SSH=false
18+
- PUID=1000
19+
- PGID=1000
20+
- NODE_VERSION=stable
21+
volumes_from:
22+
- volumes_source
23+
ports:
24+
- "22:22"
25+
tty: true
26+
27+
### PHP-FPM Container #######################################
28+
29+
php-fpm:
30+
build:
31+
context: ./php-fpm
32+
args:
33+
- INSTALL_XDEBUG=false
34+
- INSTALL_MONGO=false
35+
- INSTALL_ZIP_ARCHIVE=false
36+
- INSTALL_MEMCACHED=false
37+
- INSTALL_OPCACHE=false
38+
- INSTALL_AEROSPIKE_EXTENSION=false
39+
dockerfile: Dockerfile-70
40+
volumes_from:
41+
- volumes_source
42+
expose:
43+
- "9000"
44+
links:
45+
- workspace
46+
47+
### Laravel Application Code Container ######################
48+
49+
volumes_source:
50+
image: tianon/true
51+
volumes:
52+
- ../:/var/www/laravel
53+
54+
### Databases Data Container ################################
55+
56+
volumes_data:
57+
image: tianon/true
58+
volumes:
59+
# - ./data/mysql:/var/lib/mysql
60+
61+
### Add All your Software Containers below ###############################

0 commit comments

Comments
 (0)