I'm developing a PHP application which I want to have running using docker containers. I'm using the composer package manager which pulls in all the dependencies. All code is kept in a git repository except the dependencies.
To get everything running on my local machine I'm using docker-compose (fig). I mount my application code (include vendor folder) to volume on my containers. Here is my docker-compose.yml file.
nginx:
image: nginx:1.9
links:
- php
volumes:
- conf/nginx/default.conf:/etc/nginx/conf.d/default.conf
- src:/var/www/html
ports:
- "80:80"
php:
image: php:5.6.9-fpm
links:
- memcached
volumes:
- conf/php/php.ini /usr/local/etc/php/php.ini
- src:/var/www/html
volumes_from:
- nginx
What I don't really understand is how I would push this into production or staging environment. From what I understand it's best to ship everything in a container without having to run a package manager, because this might fail or the packages might not be identical as the packages on my local machine. So I Came up with the following docker-compose.yml file:
webapp:
image : quay.io/myusername/myrepo
php:
image: php:5.6.9-fpm
volumes:
- config/php/php.ini /usr/local/etc/php/php.ini
volumes_from:
- webapp
nginx:
image: nginx:1.9
links:
- php
volumes:
- config/nginx/default.conf:/etc/nginx/conf.d/default.conf
volumes_from:
- webapp
ports:
- "80:80"
The webapp container is build from the following dockerfile and is hosted on some repository.
FROM busybox
VOLUME /var/www/html
ADD src /var/www/html
I have a git hook that will trigger a build of this dockerfile on quay.io and adds my source code to the image.
Here's the problem: The vendor files / dependencies are not in version control so they won't be added.
I see two solutions which I both don't find ideal.
- Add the dependencies to version control.
- Run command
composer install
to pull in all files. Not preferable as mentioned above.
I'm still very new to docker, so it could be I got things all wrong. Would love to get an answer how to do this properly.