services:
# Web Server Service
# Servicio de Nginx
nginx:
image: nginx:alpine
container_name: nginx-laravel11
ports:
- '80:80' # Mapea el puerto 80 del contenedor al puerto 8080 del host
volumes:
- ./src:/var/www # Mapea el código fuente al contenedor
- ./nginx/conf.d/:/etc/nginx/conf.d/ # Mapea la configuración de Nginx
depends_on:
- php
- db
networks:
- laravel
environment:
- NGINX_HOST=laravel.test
# - NGINX_PORT=80 NO LE GUSTA ESTA VARIABLE DE ENTORNO
# Database Service
db:
# If you're using Mac with ARM architecture processor uncomment the below code
# platform: linux/x86_64
image: mysql:5.7
container_name: mysql
restart: unless-stopped
tty: true
volumes:
- ./mysql/data:/var/lib/mysql
ports:
- '3306:3306'
environment:
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
SERVICE_TAGS: ${SERVICE_TAGS}
SERVICE_NAME: ${SERVICE_NAME}
networks:
- laravel
#phpMyAdmin Service
phpmyadmin:
image: phpmyadmin/phpmyadmin
restart: unless-stopped
ports:
- '3400:80'
depends_on:
- db
networks:
- laravel
# PHP Service
php:
build:
context: ./php
dockerfile: Dockerfile
volumes:
- ./src:/var/www
ports:
- '9000:9000'
networks:
- laravel
networks:
laravel:
driver: bridge
MYSQL_DATABASE=db_name
MYSQL_USER=db_user
MYSQL_PASSWORD=db_pass
MYSQL_ROOT_PASSWORD=db_rootpass
SERVICE_TAGS=dev
SERVICE_NAME=mysql
server {
listen 80;
index index.php index.htm index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
server_name $NGINX_HOST;
root /var/www/public;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location /index.php {
try_files $uri = 404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
FROM php:8.2.11-fpm
RUN docker-php-ext-install pdo pdo_mysql
docker-compose build
docker-compose up -d
composer create-project laravel/laravel src
NOTE: add in windows/system32/drivers/etc/host this line -> 127.0.0.1 laravel.test
localhost
o
laravel.test
http://127.0.0.1:3400
docker-compose exec php bash
cd ..
php artisan migrate
exit
Add custom url