docker-compose.yaml
version: "3.8"
services:
nginx:
image: "nginx:stable-alpine"
ports:
- "8000:80"
volumes:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
- ./src:/var/www/laravel
depends_on:
- php
- mysql
php:
build:
context: dockerfiles
dockerfile: php.Dockerfile
volumes:
- ./src:/var/www/laravel
mysql:
image: mysql:8.0
ports:
- "3316:3306"
env_file:
- ./env/mysql.env
composer:
build:
context: dockerfiles
dockerfile: composer.Dockerfile
volumes:
- ./src:/var/www/laravel
artisan:
build:
context: dockerfiles
dockerfile: php.Dockerfile
volumes:
- ./src:/var/www/laravel
entrypoint: ["php", "/var/www/laravel/artisan"]
php.Dockerfile
FROM php:8.2-fpm-alpine
WORKDIR /var/www/laravel
RUN docker-php-ext-install pdo pdo_mysql
nginx.conf
server {
listen 80;
index index.php index.html;
server_name localhost;
root /var/www/laravel/public;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ .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;
}
}
Error
in the php.dockerfile file I tried to add a line to change access
FROM php:8.2-fpm-alpine
WORKDIR /var/www/laravel
RUN docker-php-ext-install pdo pdo_mysql
RUN chmod -R 777 /var/www/laravel/storage /* <------ new line */
I also tried to change access to the storage folder through WSL
@DESKTOP-VIGTBDU:/src/storage$ sudo chmod -R 777 .