A memo to prepare a laravel project in a specified position via composer on docker

Conclusion: how to achieve it

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
  1. Go to the directory where you want to place your laravel project
  2. Prepare a laravel project in that directory using the official image of 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.

Why use this method

--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

A memo to prepare a laravel project in a specified position via composer on docker
Change from SQLite3 to PostgreSQL in a new Ruby on Rails project
I had to lower the PHP version in Docker + Composer + Laravel environment
Just install Laravel8 on docker in PHP8 environment
Docker command to create Rails project with a single blow in environment without Ruby
Memo to build a Servlet environment on AWS EC2
How to create a Spring Boot project in IntelliJ
Command memo to install xeyes in ubuntu docker environment
With podman in docker, everyone wants to get along and use docker on a shared computer
How to select a specified date by code in FSCalendar
How to display a graph in Ruby on Rails (LazyHighChart)
A memo to build Jitsi Meet on Azure with docker-compose
Apply CSS to a specific View in Ruby on Rails