简体   繁体   中英

Docker Laravel Nginx, storage goes to 404 page

I'm facing an issue when opening files uploaded from my web app build with Laravel 7. The files are well stored in my app. I've also tried to run the project locally without using docker and everything is working fine, I can check the files without any issue.

In docker, I have three containers ( app, web, db ) I've created the symlink using php artisan storage:link My static assets are accessible.

Here is my docker-compose.yml

version: '2'

services:

  #  The Application
  app:
    container_name: app
    build:
      context: ./
      dockerfile: development/app.dockerfile
    volumes:
      - ./:/var/www
    env_file: '.env.dev'
    environment:
      - "DB_HOST=database"

  # The Web Server
  web:
    container_name: web
    build:
      context: ./
      dockerfile: development/web.dockerfile
    volumes:
      - ./storage/logs/:/var/log/nginx
    ports:
      - 8990:80

  # The Database
  database:
    container_name: db
    image: mariadb:10.4
    volumes:
      - dbdata:/var/lib/mysql
    environment:
      - "MYSQL_DATABASE=database"
      - "MYSQL_USER=...
      - "MYSQL_PASSWORD=...
    ports:
      - 8991:3306

Grateful if someone could help me with this issue.

Try putting this line of code inside composer.json

"post-install-cmd": [
"ln -sr storage/app/public public/storage" ],

NB: For full article try out this link

https://github.com/laravel/ideas/issues/34#issuecomment-208895323

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM