docker-compose.yml

This commit is contained in:
armiejean 2025-04-30 10:28:58 +08:00
parent 5bc891763a
commit 1a89d73886
1 changed files with 10 additions and 15 deletions

View File

@ -6,7 +6,7 @@ services:
build:
context: ./docker/php
dockerfile: Dockerfile
container_name: laravel-app
container_name: laravel
restart: always
working_dir: /var/www
volumes:
@ -15,15 +15,9 @@ services:
db_mysql:
condition: service_healthy
command: >
/bin/sh -c '
mkdir -p /var/www/storage /var/www/bootstrap/cache &&
chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache &&
chmod -R 775 /var/www/storage /var/www/bootstrap/cache &&
composer install --no-dev --optimize-autoloader &&
php artisan migrate --force &&
php-fpm '
/bin/sh -c ' mkdir -p /var/www/storage /var/www/bootstrap/cache && chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache && chmod -R 775 /var/www/storage /var/www/bootstrap/cache && composer install --no-dev --optimize-autoloader && php artisan migrate --force && php-fpm '
healthcheck:
test: ["CMD", "sh", "-c", "pgrep php-fpm"]
test: [ "CMD", "sh", "-c", "pgrep php-fpm" ]
interval: 30s
timeout: 10s
retries: 10
@ -33,7 +27,7 @@ services:
# MySQL
db_mysql:
image: mysql:8.0
container_name: db_mysql
container_name: db
restart: always
environment:
MYSQL_ROOT_PASSWORD: newpassword
@ -44,7 +38,7 @@ services:
volumes:
- mysql-data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-pnewpassword"]
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-pnewpassword" ]
interval: 10s
timeout: 5s
retries: 5
@ -54,10 +48,10 @@ services:
# Nginx
web:
image: nginx:1.26.3-alpine
container_name: web
container_name: web-unioil
restart: always
ports:
- "8000:80"
- "8080:80"
volumes:
- .:/var/www
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:rw
@ -65,7 +59,7 @@ services:
app:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]
test: [ "CMD", "curl", "-f", "http://localhost" ]
interval: 30s
timeout: 10s
retries: 5
@ -75,6 +69,7 @@ services:
volumes:
mysql-data:
networks:
app_network:
driver: bridge