cms-frontend/docker-compose.yml

67 lines
1.8 KiB
YAML

version: '3.8'
services:
# Laravel App
app:
build:
context: ./docker/php
dockerfile: Dockerfile
container_name: frontend-app
restart: always
working_dir: /var/www
volumes:
- .:/var/www
command: >
/bin/sh -c 'until nc -z db_mysql 3306; do echo "Waiting for database..."; sleep 2; done &&
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" ]
interval: 30s
timeout: 10s
retries: 10
networks:
- frontend-network
- backend-network # Ensure this is included to access db_mysql
environment:
- DB_HOST=db_mysql
- DB_PORT=3306
- DB_DATABASE=unioil-database
- DB_USERNAME=rootuser
- DB_PASSWORD=password
- CACHE_DRIVER=file
# Nginx
web-frontend:
image: nginx:1.26.3-alpine
container_name: web-frontend
restart: always
ports:
- "8000:80"
expose:
- "80"
volumes:
- .:/var/www
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:rw
depends_on:
app:
condition: service_healthy
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost" ]
interval: 30s
timeout: 10s
retries: 5
networks:
- frontend-network
networks:
frontend-network:
external: true
driver: bridge
backend-network:
external: true # Declare as external since it's created by backend