Giter Club home page Giter Club logo

laravel-fast-docker's Introduction

Laravel for Docker with fast builds

This Dockerfile makes optimal use of your Docker build cache. So you can deploy your projects faster without compromising your build.

The build is split in 4 parts:

  1. Copy NPM files & download dependencies
  2. Fetch PHP dependencies and build:
    • Copy composer files & download dependencies
    • Copy rest of project files & create composer autoload
  3. Run NPM build
  4. Build final container based on PHP + Apache

Basically what this setup does is leveraging Docker cache during build time by reusing previously built dependencies when there are no changes made to composer or npm. Usually when you're at a certain stage in development you make less changes to composer and npm, so it would be a waste of time and resources if you need to wait for the same dependencies each single build.

How to use

  1. Download this project
  2. Put the files in the root of your Laravel project

Notes

  • You can change your desired PHP version by changing 7.3-apache to 7.x-apache
  • You can change your desired NodeJS version by changing both node-12 to node-x
  • Change the PHP extensions for composer build and and the webserver to your project requirements. These can sometime differ however. So for optimal build times and build size you should only include what's necessary.
  • This setup is compatible with Laravel 5 and 6, but is not limited to Laravel. With minor changes you can use this for Symfony projects and other PHP projects as well.
  • If your build is slow it might be because:
    • Your cache has been cleared by docker system prune or something similar.
    • You made changes to your package.json or package-lock.json which results in a rebuild.
    • You made changes to your composer.json or composer.lock which results in a rebuild after npm.

laravel-fast-docker's People

Contributors

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