Update Dockerfile, docker-compose.yml, and nginx/default.conf on VM

This commit is contained in:
m.marjorie 2025-03-24 08:29:58 +00:00
parent 5dc4c707ee
commit 849b9bd753
3 changed files with 30 additions and 36 deletions

0
Dockerfile Normal file → Executable file
View File

66
docker-compose.yml Normal file → Executable file
View File

@ -1,70 +1,64 @@
version: '3.8'
services:
# MySQL Database
db:
mysql:
image: mysql:8.0
container_name: laravel-mysql
restart: unless-stopped
container_name: mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: laravel
MYSQL_ROOT_PASSWORD: root_password
MYSQL_USER: laravel_user
MYSQL_PASSWORD: laravel_password
MYSQL_USER: laravel
MYSQL_PASSWORD: secret
volumes:
- mysql_data:/var/lib/mysql
ports:
- "3306:3306"
- mysql-data:/var/lib/mysql
networks:
- laravel-network
- app-network
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
restart: unless-stopped
# Laravel Application
app:
laravel:
build:
context: .
dockerfile: Dockerfile
container_name: laravel-app
restart: unless-stopped
volumes:
- ./src:/var/www/html
container_name: laravel
user: "1000:1000" # Match the host user's UID:GID
depends_on:
db:
mysql:
condition: service_healthy
volumes:
- .:/var/www/html
networks:
- laravel-network
- app-network
healthcheck:
test: ["CMD", "php", "-v"]
test: ["CMD", "php", "--version"]
interval: 10s
timeout: 5s
retries: 5
command: >
sh -c "php-fpm"
# Nginx Web Server
web:
image: nginx:alpine
container_name: laravel-nginx
command: ["/var/www/html/start.sh"]
restart: unless-stopped
nginx:
image: nginx:alpine
container_name: nginx
depends_on:
laravel:
condition: service_healthy
ports:
- "80:80"
volumes:
- ./src:/var/www/html
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
app:
condition: service_healthy
- ./nginx.conf:/etc/nginx/conf.d/default.conf
- .:/var/www/html
networks:
- laravel-network
- app-network
restart: unless-stopped
networks:
laravel-network:
app-network:
driver: bridge
volumes:
mysql_data:
mysql-data:

0
nginx/default.conf Normal file → Executable file
View File