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

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