ruslan-valis / laravel-docker-compose

Template with docker-compose env for Laravel including health check

Repository from Github https://github.comruslan-valis/laravel-docker-composeRepository from Github https://github.comruslan-valis/laravel-docker-compose

laravel-docker-compose

Simple docker-compose environment for Laravel application with health check

Getting Started

Overview

Docker is used for containerisation, docker-compose is used for containers orchestration.

Basic docker configurations are provided in docker/ directory, separated by necessary services for the system running, aka:

  • nginx
  • php-fpm
  • mysql
  • redis

Each directory contains Dockerfile that allows to build specific docker image that then can be orchestrated via docker-compose. Default project services orchestration settings are located at docker-compose.yml.

php-fpm + nginx setup has been chosen over artisan self-serving to provide more flexibilty for future extension, however it can be replaced in case if we need more simplicity for some specific project.

Initial configuration

Environment variables via .env files are used to manage both docker and application environment settings.

Basic list of environment variables is provided in .env.example. However, in order to run project locally, you need to have .env, which can be copied from .env.example and updated with necessary environment variables.

By default, .env.example should contain values to start project out of the box locally.

Building environment

In order to build and run the project using docker-compose, you can use the next command:

docker-compose up -d --build

Run environment

If you'd like to run project without rebuild you can just run:

docker-compose up -d

Shell environment

All commands should be executed from php-fpm container, in order to do that you can use following command to login to php-fpm container shell:

docker exec -it php-fpm /bin/bash

Alternatively, you can setup default php interpreter in your IDE to use docker php version, then you can just run commands directly from the IDE.

Setup app key

Please pay attention, that you need to set up app key on the first app setup. To do that please run:

php artisan key:generate

Development

All commands listed in this section should be executed from php-fpm docker container shell.

Dependencies

In order to install packages execute command:

composer install

Migrations

In order to run migrations execute command:

php artisan migrate

Cache

In order to clean cache execute command:

php artisan cache:clear

Licensing

The code in this project is licensed under Apache License license.

About

Template with docker-compose env for Laravel including health check

License:Apache License 2.0


Languages

Language:PHP 79.6%Language:Blade 15.7%Language:Dockerfile 3.8%Language:JavaScript 0.5%Language:Shell 0.4%