Sergey Orlov
Sergey Orlov

Reputation: 279

Laravel storage with Docker

I'm setting up Docker for a Laravel app which is an internal CDN with vast amount of images and other static files living in ./storage/app, both private and public. I want the Docker image to be built with GitLab CI and my question is what is the right way of building it without overriding the contents of the storage? Those contents aren't present in the repo.

I have two thoughts about that:

Is either of the thoughts correct/good/even achievable? Or is there any other way of solving the problem?

Upvotes: 9

Views: 11506

Answers (2)

Try this:

docker exec -it my_container bash -c "cd public && ln -s ../storage/app/public storage"

Upvotes: -1

jkreimei
jkreimei

Reputation: 121

I know the question is by far not the most recent on, but since i had the same problem and did quite some research myself until i got an idea:

I've started the php container using two bind mounts that work like the link created by artisan would:

version: '3.7'

services:
  laravel:
    image: php
      volumes:
        - type: bind
          source: /path/to/laravel/project/
          target: /var/www/html/
        - type: bind
          source: /path/to/laravel/project/storage/app/public/
          target: /var/www/html/public/storage/

Upvotes: 12

Related Questions