I'm trying to containerize a Yii2 web app using a fresh installation of Phundament 4.3.0-beta6, Docker 1.11.0 and Docker Compose 1.7.0. The host is an Ubuntu based Linux Mint 17.3.
Everything is working great in dev environment, but I don't find the way to correctly build the production image.
I have already used older versions of Phundament and Docker, running in the same issues, so I'm pretty sure I'm not facing a bug: I just misunderstood something.
Problem is, the docker-compose file for local development (docker-compose.override.yml, that overrides docker-compose.yml) is mounting the root project folder on both php and nginx containers:
volumes:
- .:/app
After some customization I rebuild the php container, the app code is successfully added to the container (as instructed in the Dockerfile) so I can edit the docker-compose.override.yml file removing the volume
instruction from the php container and everything is OK.
But when I do the same with the nginx container and run docker-compose up -d
nginx give me back a 404. That means that it is not finding the landing page into the php container. It just finds it when I mount the project folder volume.
I guess that it is not the expected behavior... what I am doing wrong?
Basically, nginx
needs just the web
folder of the PHP image for index.php
and assets/
.
So you can use volumes
and volumes_from
, like so:
php:
volumes:
- /app/web
nginx:
volumes_from:
- php
Another option would be to configure nginx
in a way, that it forwards all requests to the PHP container, but that's not really needed for static files.
Note! When you redeploy your application you may need to kill
and rm -v
your PHP and nginx containers to apply changes on the volume.
Feel free to create an issue or if you have thoughts about improvements etc...
Full disclosure: I am a core developer of Phundament.