Skip to content

Commit ad68ec6

Browse files
committed
move composer into a separate container
add postgresql add mysql
1 parent c23385d commit ad68ec6

File tree

1 file changed

+37
-12
lines changed

1 file changed

+37
-12
lines changed

docker-compose.yml

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,66 @@
11
version: '3'
22

33
services:
4-
database:
4+
mysql:
55
build:
6-
context: ./database
7-
# environment:
8-
# - MYSQL_DATABASE=${DATABASE_NAME}
9-
# - MYSQL_USER=${DATABASE_USER}
10-
# - MYSQL_PASSWORD=${DATABASE_PASSWORD}
11-
# - MYSQL_ROOT_PASSWORD=${DATABASE_ROOT_PASSWORD}
6+
context: ./mysql
7+
restart: always
8+
environment:
9+
- MYSQL_DATABASE=${MY_DB_NAME}
10+
- MYSQL_USER=${MY_DB_USER}
11+
- MYSQL_PASSWORD=${MY_DB_PASSWORD}
12+
- MYSQL_ROOT_PASSWORD=${MY_DB_ROOT_PASSWORD}
1213
ports:
1314
- "3306:3306"
1415
volumes:
15-
#- ./database/init.sql:/docker-entrypoint-initdb.d/init.sql
16-
- ./database/data:/var/lib/mysql
16+
- ./mysql/init.sql:/docker-entrypoint-initdb.d/init.sql
17+
- ./mysql/data:/var/lib/mysql
18+
19+
postgres:
20+
build:
21+
context: ./postgres
22+
restart: always
23+
environment:
24+
- POSTGRES_DB=${PG_DB_NAME}
25+
- POSTGRES_USER=${PG_DB_USER}
26+
- POSTGRES_PASSWORD=${PG_DB_PASSWORD}
27+
ports:
28+
- "5432:5432"
29+
volumes:
30+
- ./postgres/init.sql:/docker-entrypoint-initdb.d/init.sql
31+
- ./postgres/data/:/var/lib/postgresql/data/
1732

1833
php-fpm:
1934
build:
2035
context: ./php-fpm
21-
depends_on:
22-
- database
36+
restart: always
2337
# environment:
2438
# - APP_ENV=${APP_ENV}
2539
# - APP_SECRET=${APP_SECRET}
2640
# - DATABASE_URL=mysql://${DATABASE_USER}:${DATABASE_PASSWORD}@database:3306/${DATABASE_NAME}?serverVersion=5.7
2741
volumes:
2842
- ./src/:/var/www/
43+
- ./php-fpm/conf.d/php.ini:/usr/local/etc/php/conf.d/php.ini
44+
- ./php-fpm/conf.d/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
45+
46+
composer:
47+
image: composer
48+
volumes:
49+
- ./src/:/app/
50+
command: install
2951

3052
nginx:
3153
build:
3254
context: ./nginx
55+
restart: always
3356
volumes:
3457
- ./src/:/var/www/
3558
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
3659
- ./nginx/conf.d/:/etc/nginx/conf.d/
3760
- ./logs:/var/log
3861
depends_on:
3962
- php-fpm
63+
- mysql
64+
- postgres
4065
ports:
41-
- "80:80"
66+
- "80:80"

0 commit comments

Comments
 (0)