0

I have dockerfile looks like :

RUN set -ex \
    && mkdir /home/app/cache-pool \
    && chown -R app:app /home/app/cache-pool \
    && mkdir /home/app/my-app \
    && chown -R app:app /home/app/my-app;
WORKDIR /home/app/my-app

RUN rm -vfr /home/app/cache-pool/*
RUN ln -s /home/app/cache-pool /home/app/my-app/public/page_cache

Exclude .dockerignore

/public/page_cache

I'm using docker compose to run the containers and mounting source code from host

services:
  app:
    ...
    volumes:
      - ./:/home/app/my-app

based on that all sub-directories under /home/app/my-app will replace by host include /home/app/my-app/public/.. also will break a created symlink on image even I create another volume to ignore it ref : https://stackoverflow.com/a/37898591/1297435

services:
  app:
    ...
    volumes:
      - ./:/home/app/my-app
      - /home/app/my-app/public/page_cache

Do I need to re-symlink on docker compose entry point or any best way not to break symlink even I mount the source from host on volume?

itx
  • 1,327
  • 1
  • 15
  • 38
  • You can't really do this (the linked question suggests a popular hack around the Node `node_modules` directory). I'd delete the `volumes:` entirely: use the code built into the image, not from somewhere else. A previous question you asked put the page cache in a different directory outside of the application source tree (IIRC `/home/app/page-cache`, not under `/home/app/my-app`) and that's also a good choice. – David Maze Oct 19 '22 at 09:50
  • @DavidMaze the problem on my prev question I found it because that replace by host when mounting the volume, so I just need to find another way to don't replace the `page_cache` under `/home/app/my-app/public` – itx Oct 19 '22 at 09:53

0 Answers0