Just testing out composer+laravel+docker-compose
Go to file
Alex Wright 1002ede0c3 Adding readme with some basic bring-up instructions 2019-01-23 18:58:53 +01:00
src Adding laravel project template 2019-01-22 11:06:49 +01:00
.dockerignore Ignore rules for git and docker-build 2019-01-22 15:29:37 +01:00
.editorconfig Attr and editor config 2019-01-22 11:00:24 +01:00
.gitattributes Attr and editor config 2019-01-22 11:00:24 +01:00
.gitignore Ignore rules for git and docker-build 2019-01-22 15:29:37 +01:00
Dockerfile pgsql and pdo are needed in the second stage 2019-01-22 12:42:41 +01:00
docker-compose.yaml docker-compose config for brining up the demo 2019-01-22 15:33:29 +01:00
readme.md Adding readme with some basic bring-up instructions 2019-01-23 18:58:53 +01:00

readme.md

Demo Laravel app under docker / docker-compose

This is just an example of brining up a composer based project under docker-compose. Not yet adapted for AWS/RDS/EBS/etc, pulls the postgres image and hosts it's own DB just to demo.

Procedure for running

Environment Variables

Docker-compose will look for and copy any values found for the following ENV variables:

  • DB_CONNECTION
  • DB_HOST
  • DB_PORT
  • DB_DATABASE
  • DB_USERNAME
  • DB_PASSWORD
  • POSTGRES_USER

For development environments I usually use direnv which will publish values found in a .envrc file in the same dir. These could be set by Jenkins as part of a CI/CD deploy.

Prepare storage

The current docker-compose.yml mounts the laravel storage dir from the project working dir. You'll need to create the directory structure Laravel expects or it won't be able to write session files, logs, compiled view templates etc. Run something like: mkdir -pv ./storage/laravel/framework/{cache,sessions,views}. This would probably be better as a named volume, but that'd less straightforward to get up and running.

Actually Running

  • Create the DB instance
    docker-compose up -d db

  • Check that worked
    docker-compose ps db this should report something like:

         Name                       Command              State    Ports  
    -------------------------------------------------------------------------  
    laravel_demo_db_1   docker-entrypoint.sh postgres   Up      5432/tcp  
    
  • Run migrations
    docker-compose run app ./artisan migrate

  • Start the app
    docker-compose up -d