GithubHelp home page GithubHelp logo

laravel-docker-compose's Introduction

Laravel Docker Compose

This repository aims to bring a light yet powerful and configurable Docker compose configuration to run a Laravel application locally. It is not intended for production.

Out of the box, 6 containers are installed:

  • MySQL
  • PHP
  • Nginx
  • Artisan
  • Composer
  • NPM

Installation Instructions

First, make sure Docker Compose is installed on your machine.

To install a Laravel application from scratch, proceed as follows:

Copy this repository's files:

Copy .env.example to .env or modify your existing .env after checking .env.example modifications

  • The DB_HOST is set to mysql
  • A new Docker section at the bottom is added

Replace your webpack.mix.js by this one, or add the new Docker sections.

Replace your .gitignore by this one, or add the new Docker sections.

If you need to import a database dump, place it in the docker/mysql folder. It will be imported automatically when the MySQL container boots.

Build the containers

sudo docker-compose build

Install Composer dependencies

sudo docker-compose run --rm composer install

Install NPM dependencies

sudo docker-compose run --rm --entrypoint npm npm install

Generate application key

sudo docker-compose run --rm artisan key:generate

Set storage permissions on the host

chmod -R 755 storage

Usage

Run the project

sudo docker-compose run -d

By default, your application will be available at

Check a container's logs:

sudo docker-compose logs container-name

For example, check Nginx's logs:

sudo docker-compose logs nginx

Run artisan commands

sudo docker-compose run --rm artisan my-command

For example, migrate your database:

sudo docker-compose run --rm artisan migrate

Remove the database (needed if you want to reimport)

sudo docker-compose down -v

Restart a container:

sudo docker-compose restart container-name

For example, to restart PHP:

sudo docker-compose restart php

Adding additional containers

In addition to the 6 base containers, additional containers are offered:

  • Redis
  • Laravel Horizon
  • Laravel Echo Server
  • PHPMyAdmin

To add an additional container, modify your .env's COMPOSE_FILE variable to add the path to the additional docker-compose.override.yml file.

For example, to add Redis, do:

COMPOSE_FILE=docker-compose.yml:docker/redis/docker-compose.override.yml

laravel-docker-compose's People

Contributors

adrienpoupa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.