php - Docker and package managers in production -
i'm developing php application want have running using docker containers. i'm using composer package manager pulls in dependencies. code kept in git repository except dependencies.
to running on local machine i'm using docker-compose (fig). mount application code (include vendor folder) volume on containers. here 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 don't understand how push production or staging environment. understand it's best ship in container without having run package manager, because might fail or packages might not identical packages on local machine. came 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 build following dockerfile , hosted on repository.
from busybox volume /var/www/html add src /var/www/html
i have git hook trigger build of dockerfile on quay.io , adds source code image.
here's problem: vendor files / dependencies not in version control won't added.
i see 2 solutions both don't find ideal.
- add dependencies version control.
- run command
composer install
pull in files. not preferable mentioned above.
i'm still new docker, got things wrong. love answer how properly.
your dockerfile
should build container image if there no volumes mounted. clone or copy code in container, run composer install dependencies. running container without volumes should work.
volumes in production environments persisting data , logs primarily. code should not in mounted volume.
for development purposes, can mount volume code location , container still work.
to speed build process, copy composer.json
, composer.lock
files first , install dependencies location outside source tree. ensure dependencies updated when json file changes, not on every code change, speeding process immensely.
Comments
Post a Comment