-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
100 lines (93 loc) · 3.2 KB
/
docker-compose.yml
File metadata and controls
100 lines (93 loc) · 3.2 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
version: '3.3'
# We define volumes here.
# In this case, we define a volume for the database but it's overkill
# because we used this volume only with one container.
volumes:
db-volume:
# We define containers here
services:
# DB container
db:
# We use the image of mariadb (https://hub.docker.com/_/mariadb/).
# Like we don't precise tag, it's the latest version image which is download.
image: mariadb
# We define environment variable like explained in the documentation of the image.
environment:
- MYSQL_ROOT_PASSWORD=root_password
- MYSQL_DATABASE=${DATABASE_NAME}
- MYSQL_USER=drupal
- MYSQL_PASSWORD=drupal
# We used the volume previously defined.
volumes:
- db-volume:/var/lib/mysql
# Container for PhpMyAdmin
php-my-admin:
# We use the image of phpmyadmin version 4.7.
image: phpmyadmin/phpmyadmin:4.7
# We redefine environment variable for the communication with the db container.
environment:
- MYSQL_ROOT_PASSWORD=root_password
- MYSQL_DATABASE=${DATABASE_NAME}
- MYSQL_USER=drupal
- MYSQL_PASSWORD=drupal
# We indicate the port 80 of this container run on the port 8080 of our machine.
ports:
- 8080:80
links:
- db
# Container to run cli applications (composer, drush, drupal-console, etc.)
php-cli:
# Here, we use a Dockerfile and not a Docker Image. The file is Dockerfile-php-cli and is in the same repository
# than the docker-compose.yml
build:
context: .
dockerfile: Dockerfile-php-cli
# Arguments pass to the Dockerfile.
args:
USER_UID: ${USER_UID}
volumes:
# Data of application
- .:/var/www/html:rw
# Share the local user's composer cache and settings
- ~/.composer:/home/php/.composer:rw
# Share the local user's npm cache as a Docker volume
- ~/.npm:/home/php/.npm:rw
# Share the local user's SSH keys and configuration (read-only)
- ~/.ssh:/home/php/.ssh:ro
# Share the local user's known_host
- ~/.ssh/known_hosts:/home/php/.ssh/known_hosts:rw
# Share the local user's gitconfig
- ~/.gitconfig:/home/php/.gitconfig
environment:
# We define the PATH and add the bin directory of vendor.
- PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/www/html/vendor/bin
- MYSQL_DATABASE=${DATABASE_NAME}
- MYSQL_USER=drupal
- MYSQL_PASSWORD=drupal
links:
- db
# php-fpm container used as PHP runtime for the web server
php-fpm:
image: drupaldocker/php-dev:7.0-fpm
volumes:
- .:/var/www/html:rw
environment:
- MYSQL_DATABASE=${DATABASE_NAME}
- MYSQL_USER=drupal
- MYSQL_PASSWORD=drupal
links:
- db
# The web server used to access the developement website
web:
image: drupaldocker/nginx
# We define the root directory for NGinx. Web Directory is the root of Drupal after download with composer.
environment:
DOCROOT: /var/www/html/web
# We define port. The variable PORT is defined in the .env file.
ports:
- ${PORT}:80
volumes:
- .:/var/www/html:rw
# We create a link with the php service of php-fpm.
links:
- php-fpm:php