PHP docker best way. Build application inside or outside docker? -


i have php application manu dependencies framework, libraries, etc. of dependencies resolved composer. have seen 2 ways dockerize apllication

the 1st way (building outsude docker) make composer install on host machine , after copy full project directory container.

the 2nd way (building inside continer) add dockerfile run composer install , make resolving dependencies docker

i think 1st closer docker way. 2nd way has pros:

  • it more independent hosts machine. host machine don't need php, composer.
  • i can add dockerfile git clone <my project> , container all-sufficient. can build on host machine docker. means project building highly portable

how think way more preferable?

if have run composer install in dockerfile, means have composer installed in docker image. not want in production state.

so yes, i'd have build application outside , build image. keep in mind not put secrets in image if plan on making available on hub.docker.com.

good article here: http://www.dylanlindgren.com/docker-for-the-laravel-framework/


Comments