File tree 2 files changed +16
-13
lines changed 2 files changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,6 @@ networks:
5
5
6
6
services :
7
7
app :
8
- env_file :
9
- - .env
10
8
build :
11
9
context : .
12
10
dockerfile : Dockerfile
@@ -15,18 +13,19 @@ services:
15
13
- 8000:8000
16
14
volumes :
17
15
- .:/app
18
- # Use a named volume for vendor directory to preserve packages
19
16
- vendor:/app/vendor
20
17
depends_on :
21
18
db :
22
19
condition : service_healthy
20
+ env_file :
21
+ - .env
23
22
environment :
24
23
- DB_HOST=db
25
24
- DB_CONNECTION=mysql
26
25
- DB_PORT=3306
27
26
- DB_DATABASE=test-db
28
- - DB_USERNAME=${DB_USERNAME:-root }
29
- - DB_PASSWORD=${DB_PASSWORD:-secret }
27
+ - DB_USERNAME=${DB_USERNAME}
28
+ - DB_PASSWORD=${DB_PASSWORD}
30
29
networks :
31
30
- application
32
31
@@ -36,8 +35,10 @@ services:
36
35
- " 3307:3306"
37
36
volumes :
38
37
- ./data:/var/lib/mysql
38
+ env_file :
39
+ - .env
39
40
environment :
40
- - MYSQL_ROOT_PASSWORD=${DB_PASSWORD:-secret }
41
+ - MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
41
42
- MYSQL_DATABASE=test-db
42
43
networks :
43
44
- application
@@ -52,7 +53,7 @@ services:
52
53
" localhost" ,
53
54
" -u" ,
54
55
" root" ,
55
- " -p${DB_PASSWORD:-secret }" ,
56
+ " -p${DB_PASSWORD}" ,
56
57
]
57
58
interval : 5s
58
59
timeout : 5s
@@ -63,10 +64,12 @@ services:
63
64
container_name : phpmyadmin
64
65
ports :
65
66
- " 8080:80"
67
+ env_file :
68
+ - .env
66
69
environment :
67
70
- PMA_HOST=db
68
- - PMA_USER=${DB_USERNAME:-root }
69
- - PMA_PASSWORD=${DB_PASSWORD:-secret }
71
+ - PMA_USER=${DB_USERNAME}
72
+ - PMA_PASSWORD=${DB_PASSWORD}
70
73
depends_on :
71
74
- db
72
75
networks :
Original file line number Diff line number Diff line change 16
16
composer install --no-interaction --no-progress
17
17
fi
18
18
19
- # Generate application key if APP_KEY is empty or not set correctly
20
- if ! grep -q " APP_KEY=.*[A-Za-z0-9+/] " .env || grep -q " APP_KEY=$ " .env; then
19
+ # Generate application key if not set
20
+ if grep -q " APP_KEY=base64: " .env && ! grep -q " APP_KEY=base64:.*[^=] " .env; then
21
21
echo " Generating Laravel application key..."
22
22
php artisan key:generate --no-interaction
23
23
fi
24
24
25
25
# Run migrations if needed
26
- if [ " ${RUN_MIGRATIONS:- true } " = " true" ]; then
26
+ if [ " ${RUN_MIGRATIONS:- false } " = " true" ]; then
27
27
echo " Running database migrations..."
28
- php artisan migrate
28
+ php artisan migrate --force
29
29
fi
30
30
31
31
# Cache configurations for production
You can’t perform that action at this time.
0 commit comments