For example, if you want to create a laravel project called ~ / Documents / tmp / laravel-project-via-composer
:
% cd ~/Documents/tmp
% docker run --rm -i -t -v $PWD:/app composer create-project --prefer-dist laravel/laravel laravel-project-via-composer
composer
only this.
(If anything, -i -t
is also unnecessary, but it is included because it makes the output easier to see.)
This will be available in ~ / Documents / tmp / laravel-project-via-composer
.
You don't even need % cd ~ / Documents / tmp
because you can put $ PWD
in any directory and the command issuer directory can be anywhere. (But I'm afraid of accidental mistakes, so I personally want to cd
and then execute the command.)
As a reminder, the right side of $ PWD: / app
is / app
at https://github.com/composer/docker/blob/fbef2df32932859094b4cd3fb072f1e93a7fa1f8/2.0/Dockerfile#L60. Because it is WORKDIR / app
.
--I don't want to worry about PHP or Composer versions in my local environment ――It can be managed with anyenv, but it is troublesome due to the version discrepancy of OpenSSL ... --It's faster to use docker image than to build ――In many cases, the original purpose is not to build, but to have a laravel project. --After preparing the laravel project, you should prepare a Dockerfile for executing WEB App and a file for docker-compose separately.
Maybe if you have some other well-known FW or package manager, you should be able to prepare your web app in a similar way. (Need to communicate with hardware, that's another story.)
It seems foolish considering the cost of maintaining the local environment one by one due to hardware troubles and hardware changes, so it may be convenient to use what you can use? It was a story.
By the way, there is of course the option of installing laravel / installer
and laravel new hoge
, but if you just use docker to prepare the development environment, is it easier to run it using the image of composer? I'm thinking. I don't know.
Recommended Posts