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: build:
context: ./docker/php context: ./docker/php
dockerfile: Dockerfile dockerfile: Dockerfile
container_name: laravel-app container_name: laravel
restart: always restart: always
working_dir: /var/www working_dir: /var/www
volumes: volumes:
@ -15,15 +15,9 @@ services:
db_mysql: db_mysql:
condition: service_healthy condition: service_healthy
command: > command: >
/bin/sh -c ' /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 '
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: healthcheck:
test: ["CMD", "sh", "-c", "pgrep php-fpm"] test: [ "CMD", "sh", "-c", "pgrep php-fpm" ]
interval: 30s interval: 30s
timeout: 10s timeout: 10s
retries: 10 retries: 10
@ -32,8 +26,8 @@ services:
# MySQL # MySQL
db_mysql: db_mysql:
image: mysql:8.0 image: mysql:8.0
container_name: db_mysql container_name: db
restart: always restart: always
environment: environment:
MYSQL_ROOT_PASSWORD: newpassword MYSQL_ROOT_PASSWORD: newpassword
@ -44,7 +38,7 @@ services:
volumes: volumes:
- mysql-data:/var/lib/mysql - mysql-data:/var/lib/mysql
healthcheck: healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-pnewpassword"] test: [ "CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-pnewpassword" ]
interval: 10s interval: 10s
timeout: 5s timeout: 5s
retries: 5 retries: 5
@ -54,10 +48,10 @@ services:
# Nginx # Nginx
web: web:
image: nginx:1.26.3-alpine image: nginx:1.26.3-alpine
container_name: web container_name: web-unioil
restart: always restart: always
ports: ports:
- "8000:80" - "8080:80"
volumes: volumes:
- .:/var/www - .:/var/www
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:rw - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:rw
@ -65,7 +59,7 @@ services:
app: app:
condition: service_healthy condition: service_healthy
healthcheck: healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"] test: [ "CMD", "curl", "-f", "http://localhost" ]
interval: 30s interval: 30s
timeout: 10s timeout: 10s
retries: 5 retries: 5
@ -75,6 +69,7 @@ services:
volumes: volumes:
mysql-data: mysql-data:
networks: networks:
app_network: app_network:
driver: bridge driver: bridge