I have the following containers:
nginx:latest
myapp
container (derived from php-fpm:alpine)
Currently I have a dummy project with CI pipeline in place which, build-time, compiles production variant of resources (images/js/css,...). Build files end up in (/public/build). At the very end of CI pipeline, I package everything into Docker images and upload it to Hub.
Both nginx
and myapp
do have volume (not bind mount) set up and pointing to /opt/ci-test/public/build
.
This works, for the first time.
But let's say that I add a new file new.css
- my new version of docker image will contain a build variant of new.css
.
Running a new container with pre-existing volume does not reveal new files and I understand that it should not.. I can create a new volume my_app_v2
.
At this point nginx
does not see this new volume and it must be removed and re-run (with new volume) for it to take effect.
Is there an easy way to overcome this?
My intention is to use nginx
container for multiple PHP apps and I need to refrain from killing it whenever I update one of the apps being served. Is this a bad decision?
EDIT:
One workaround I have managed to dig out is to remove all files from attached volume and start new myapp
container. This mirrors all the latest files to the volume. But this feels dirty...
EDIT2:
Related issue (case 3): https://github.com/moby/moby/issues/18670#issuecomment-165059630
EDIT3:
Dockerfile
FROM php:7.2.30-fpm-alpine3.11
COPY . /opt/ci-test
WORKDIR /opt/ci-test
VOLUME /opt/ci-test/public/build
So far, I do not have docker-composer
and I run the containers manually via commands:
docker run -it -d --name php71alp -v shr_test:/opt/ci-test/public/build -p 9000:9000 <myaccount>/citest
docker run -it -d --name nginx -v shr_test:/var/www/citest -p 80:80 nginx:latest