thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.78k stars 2.67k forks source link

Docker Voyager cannot create folder in storage #5450

Closed alibori closed 2 years ago

alibori commented 3 years ago

Laravel version

8.54

PHP version

7.4-fpm-alpine

Voyager version

1.5

Database

mysql:5.7

Description

Hello! I'm developing a Laravel project with Voyager and I want to do it with Docker. When trying to upload a page image if the directory is created there isn't problem but if not it throws an error. Thanks in advance!

Steps to reproduce

I have this project structure: image

My docker-compose.yml looks like this: `version: '3.7'

services: nginx: image: nginx:stable-alpine container_name: nginx restart: always ports:

networks: laravel:`

My Dockerfile looks like this: `FROM php:7.4-fpm-alpine

Install dependencies

RUN apk add --no-cache \ jpegoptim optipng pngquant gifsicle \ curl \ libzip-dev

Setup GD extension

RUN apk add --no-cache \ freetype \ libjpeg-turbo \ libpng \ freetype-dev \ libjpeg-turbo-dev \ libpng-dev \ && docker-php-ext-configure gd \ --with-freetype=/usr/include/ \ --with-jpeg=/usr/include/ \ && docker-php-ext-install -j$(nproc) gd \ && docker-php-ext-enable gd \ && apk del --no-cache \ freetype-dev \ libjpeg-turbo-dev \ libpng-dev \ && rm -rf /tmp/* RUN docker-php-ext-configure zip RUN docker-php-ext-install zip RUN docker-php-ext-install mysqli pdo pdo_mysql exif bcmath`

Everything is working well except create a new directory like 'September2021' when I upload a new image.

Expected behavior

I want that Voyager can create the folder if it not exists.

Screenshots

No response

Additional context

No response

medbedis commented 2 years ago

run 'php artisan storage:link' into your container .

fletch3555 commented 2 years ago

This isn't a Voyager problem, or even a Laravel problem. Voyager (and Laravel) runs under the php-fpm process, which has a specific user ID it runs as. When creating files, effective permissions will be that of the user php-fpm is running as. If your host OS is a *nix variant, the file ownership info from the host will be the same inside the docker container. In your case, these IDs likely don't match.

You can confirm this by opening a shell into the docker container and checking file permissions/ownership on the directory where these images should be written to (likely /path/to/project/storage/app/public). How to do this is not specific to Voyager and therefore left as an exercise for the reader. Solution will depend on specifically what you find, but is also not specific to Voyager

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.