-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
194 lines (184 loc) · 7.75 KB
/
docker-compose.yml
File metadata and controls
194 lines (184 loc) · 7.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
version: "3"
services:
###################################################################
# Webserver
###################################################################
# In order to connect to your project via a web browser
# you need to have a webserver.
# In this case, Nginx provides that service. It serves static
# content such as HTML and CSS,
# while linking to the PHP container which compiles and
# servers PHP
#
# It's important to:
# - "Expose" ports so your local machine can connect
# - mount "volumes" for your web app source and nginx config
# Your web app volume MUST be the same as that in PHP
###################################################################
nginx:
image: nginx:stable-alpine
ports:
# OPTIONAL: change the port number before the colon ":" to alter we traffic port
- "8080:80"
volumes:
- ./src:/var/www
- ./.docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
# for this container to run, wait until PHP and MYSQL are running
- php
- mysql
###################################################################
# Database Server
###################################################################
# A common database in LEMP stacks is MySQL. This container runs
# MySQL for you, so you don't need to run it locally. One project
# can have one MySQL instance keeping things isolated and it makes
# it easier to deploy (most of the time!)
#
# It's important to:
# - be careful exposing ports! Only do it locally or if your
# server is firewalled. DO NOT EXPOSE LIVE!
# - set your environment secrets to match your app
# - Be aware that data is persisted using a volume, which I imagine
# most people will want, but maybe you don't.
###################################################################
mysql:
image: mysql:8.0
restart: unless-stopped
tty: true
ports:
# OPTIONAL: Change the port number before the colon ":" to alter where MySQL binds on the host
# Allow connections to MySQL from the host (MySQL Workbench, DataGrip, etc) on port 33060
# WARNING: do not expose in production!
- "3306:3306"
environment:
# OPTIONAL: Change MySQL credentials
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: laravel
MYSQL_USER: root
MYSQL_PASSWORD: secret
volumes:
# Persist MySQL data with
- ./mysql_data:/var/lib/mysql
###################################################################
# PHP (FPM)
###################################################################
# Used to execite PHP and run FPM (process manager), which is
# important for LEMP stacks.
#
# It's important to:
# - set your environment secrets to match your app
# - Read an understand the custom docker file. You'll see a lot
# you can change in there.
###################################################################
php:
build:
context: ./src
dockerfile: ../.docker/Dockerfile.app
args:
# Define the default User ID for the file ownership of these containers.
# to find this out on a unix based system type "id" into a terminal.
UID: 1000
volumes:
- ./src:/var/www
# OPTIONAL: add the xdebug profiler path.
# This requires you to edit the Dockerfile.app and uncomment the profiler options
#- ./xdebug-profiler:/tmp
# OPTIONAL: Load a custom PHP.ini file
# This can be used to increase timeouts, etc
#- ./.docker/php/php.ini:/usr/local/etc/php/php.ini
# You may want to allow the docker container to connect to your host machine (say for local MySQL)
# I'm not sure this currently works on Liunx, but is the best attempt I was able to find.
# Note: it does need iproute2 installed inside the Dockerfile.app
#command: ip -4 route list match 0/0 | awk '{print $$3" host.docker.internal"}' >> /etc/hosts
extra_hosts:
- "host.docker.internal:host-gateway"
###################################################################
# Redis, for caching and queues (Optional)
###################################################################
redis:
image: redis:5-alpine
restart: unless-stopped
# OPTIONAL: change or open up Redis port binding.
# Disabled by default for security. Redis should not be exposed to the world!
# your other containers should still be able to access it without this enabled
#ports:
#- 6379:6379
###################################################################
# Laravel Horizion (Optional)
# NOTE: if you're not running horizon, you should delete this stanza or you'll get errors
###################################################################
# horizon:
# build:
# context: ./src
# dockerfile: ../.docker/Dockerfile.app
# # Define the default User ID for the file ownership of these containers.
# # to find this out on a unix based system type "id" into a terminal.
# args:
# - UID=1000
# restart: unless-stopped
# command: /bin/bash -c 'while [ 0 -lt 1 ] ; do php artisan horizon; sleep 60; done'
# volumes:
# - ./src:/var/www
# # OPTIONAL: add the xdebug profiler path.
# # This requires you to edit the Dockerfile.app and uncomment the profiler options
# #- ./xdebug-profiler:/tmp
###################################################################
# Laravel Scheduler (Optional)
###################################################################
scheduler:
build:
context: ./src
dockerfile: ../.docker/Dockerfile.app
# Define the default User ID for the file ownership of these containers.
# to find this out on a unix based system type "id" into a terminal.
args:
- UID=1000
restart: unless-stopped
command: /bin/bash -c 'while [ 0 -lt 1 ] ; do php artisan schedule:run >> /dev/null 2>&1 ; sleep 60; done'
volumes:
- ./src:/var/www
# OPTIONAL: add the xdebug profiler path.
# This requires you to edit the Dockerfile.app and uncomment the profiler options
#- ./xdebug-profiler:/tmp
###################################################################
# Default Queue Worker (Optional)
###################################################################
worker-default:
build:
context: ./src
dockerfile: ../.docker/Dockerfile.app
# Define the default User ID for the file ownership of these containers.
# to find this out on a unix based system type "id" into a terminal.
args:
- UID=1000
restart: unless-stopped
command: /bin/bash -c 'while [ 0 -lt 1 ] ; do php artisan queue:work --tries=3 --timeout=90 --sleep=10; done'
volumes:
- ./src:/var/www
# OPTIONAL: add the xdebug profiler path.
# This requires you to edit the Dockerfile.app and uncomment the profiler options
#- ./xdebug-profiler:/tmp
###################################################################
# Email Catchers (Pick one!)
###################################################################
# Mailhug (Optional, mail-catcher)
# Comment out or delete this if you don't want to use it
mailhog:
image: mailhog/mailhog
ports:
# Uncomment to allow host access to SMTP (not sure why you'd want to?!)
# your containers on the same network can still access this without the binding
# - 1025:1025 # smtp server
# OPTIONAL: Change the port number before the colon ":" to alter where the Mailhog UI can be accessed
- 8025:8025 # web ui
# # MailDev (Optional, mail-catcher)
# # Comment out or delete this if you don't want to use it
# maildev:
# image: maildev/maildev
# tty: true
# ports:
# #- '1030:1025'
# - '1080:80'
# #restart: always
# restart: on-failure