A premade, easy to use local development setup to be used for authoring Laravel applications

Overview

Laravel Drydock

This project is a premade, easy to use local development setup to be used for authoring Laravel applications.

The deliverables of this project structure are:

Installation

Adding Drydock to Existing Projects

Inside your existing Laravel project, set laravel drydock up as an upstream remote with the following commands:

git remote add drydock [email protected]:atrauzzi/laravel-drydock.git
git config remote.drydock.pushurl "Don't push to drydock from projects!"
git fetch drydock
  • Linux, OSX or any unix, run:
    git checkout drydock/master \*
    
  • Windows
    git checkout drydock/master *
    

Adding Laravel to Drydock

Alternatively, you can go the other way and add Laravel to a checkout of drydock.

git remote add laravel [email protected]:laravel/laravel.git
git config remote.laravel.pushurl "Don't push to laravel from projects!"
git fetch laravel
  • Linux, OSX or any unix, run:
    git checkout laravel/master \*
    
  • Windows
    git checkout laravel/master *
    

Remember, you can always grab a different version other than the latest by substituting master with a valid tag name from laravel/laravel.

Running

Starting your application locally is as simple as:

docker-compose up -d

Be aware that depending on the state of your project, laravel and drydock, some environment configuration may have drifted. That said, I will always try to keep drydock working with the latest version of Laravel. Feel free to open a ticket with any concerns or issues that might be affecting the default configuration.

If you've just installed Laravel, you will also want to install all your dependencies:

./run composer install
./run composer require predis/predis

As you can see, the run shell script simply forwards whatever you pass to it into the running container.

What's in the box?

Most importantly? Everything is standard! That means you shouldn't need to be aware of platform or hosting specific quirks. The default docs for the various projects should always be sufficient.

  • PHP 7.1
  • Laravel 5.2.*
  • Postgres 9.5.*
  • Redis 3.0.*

The following ports are exposed to the host:

  • Laravel, 8080
  • Postgres, 5432
  • Redis, 6379
  • Maildev, 8082

This gives you the convenience of being able to run local GUI tools against the environment - I recommend PhpStorm, DataGrip and Redis Desktop.

Port 8082 is running an email trap that will intercept all outbound emails and show them in a convenient interface.

Meta

After spending time with the various PaaS offerings, it dawned on me that they tend to get in the way. I've had to support a few teams now attempting to use services like Google App Engine, Azure Web Sites and Amazon Elastic Beanstalk. Each platform has a way of saddling devs with cumbersome proprietary environment quirks that swallow hours of productivity. Eventually, you end up forced to make compromises and additions to your project that end up feeling a lot like technical debt.

The core issue is that all PaaS offerings are in some way are restricting the runtime, thus breaking PHP and the ecosystem of libraries we enjoy:

  • Inability to write temporary files to the local filesystem (cached templates and optimizations)
  • Non-standard customizations to the PHP runtime - especially when it comes to CURL
  • Limited database, cache, filesystem or other supporting technology choices
  • Confusing pricing structures
  • Not running on the operating system of your choice
  • Brittle support library requirements
  • Obscure DNS and socket limitations
  • Missing PHP extensions
  • Difficult deployment flows

The good news today is that most vendors have realized this and have started to offer the ability to run your own custom docker containers on top of their PaaS platforms.

Local Development - With Infrastructure

With PHP, it's best to run your project in an environment that is similar to what you will be deploying to. This is what laravel-drydock is all about and it accomplishes this using Docker containers.

Please be sure to have the most current versions of docker (>= 1.10) and docker-compose (>= 1.6). If you're encountering any issues, this would be a good first thing to check. If you're not sure of how best to install them, check out Docker for Windows or Docker for macOS.

If you need to run any commands like composer or artisan, simply prefix them with ./run at the root of this project. They will be run inside the environment.

Once the environment is running, it will output all server requests, database access, queue access and cache messages. Repeated queue messages are normal and are just the queue worker polling.

We know why they do it - it's to offer scalability! But when we unpack the excuses, it tends to be that the PaaS vendors go too far.

Why Laravel?

Due to the high quality and extensive number of abstractions it offers, Laravel is one of the most productive web frameworks out there! Like all frameworks, with care and understanding, you can use it in a wide variety of configurations and environments.

Deploying

When you're done authoring your project locally, you're ready to master a snapshot of your project as two docker images. Use (and adapt) the following commands as needed:

 ./run composer update --no-dev --prefer-dist --optimize-autoloader
 ./run npm install
 ./run jspm install
 ./run gulp
 
docker --log-level=debug build --force-rm --no-cache --pull --file=resources/dockerfiles/php.Dockerfile --tag=atrauzzi/laravel-drydock:php .
docker --log-level=debug build --force-rm --no-cache --pull --file=resources/dockerfiles/nginx.Dockerfile --tag=atrauzzi/laravel-drydock:nginx .

This will prepare two images in your local docker image cache that contain your entire project, ready to run! Keep in mind that most docker registries require that images follow a specific naming convention. Be sure to substitute atrauzzi/laravel-drydock above with names that correspond to your own registry.

If you're using a registry that supports docker's push command, distributing your images is easy:

docker push atrauzzi/laravel-drydock:webapp
docker push atrauzzi/laravel-drydock:web

Again, please remember to substitute your own registry names above. If you don't have a registry yet, I highly recommend Docker Hub.

Comments
  • /var/www/artisan: Permission denied

    /var/www/artisan: Permission denied

    When starting up the container (using both docker-compose up and sudo docker-compose up) I get an error for the laravel-worker as follows:

    laravel-worker   | /usr/local/bin/artisan: line 3: /var/www/artisan: Permission denied
    laravel-webapp   | [03-Feb-2016 20:30:36] NOTICE: fpm is running, pid 1
    laravel-webapp   | [03-Feb-2016 20:30:36] NOTICE: ready to handle connections
    laravel-webapp   | [03-Feb-2016 20:30:36] NOTICE: systemd monitor interval set to 10000ms
    laravel-worker exited with code 126
    

    I think this is preventing it from running the composer install step, so I don't get anything hosted at localhost:8080, however I do see the access logs showing up in the console window.

    This is running in an xubuntu 15.10 desktop VM on Windows 7 64 bit Virtualbox 5.0.14 host

    opened by chrispappas 3
  • Cannot start worker service

    Cannot start worker service

    After cloning the repo and spinning up the containers the worker container has an error and wlll not load.

    ERROR: for ccdc-worker Cannot start service worker: oci runtime error: container_linux.go:265: starting container process caused "exec: "artisan": exCreating ccdc-cron ... done

    ERROR: for worker Cannot start service worker: oci runtime error: container_linux.go:265: starting container process caused "exec: "artisan": executable file not found in $PATH"

    opened by cdomansky 1
  • Set Laravel default configs to be ./artisan serve-able

    Set Laravel default configs to be ./artisan serve-able

    I was thinking that if someone wanted to use this base project, but not necessarily spin up the environment, it would be nice to have Laravel run in a pure-php mode. That is: Zero dependencies on external servers, etc...

    • Cache
    • DB
    • Sessions
    • Stuff like that...

    Ideally this would be when the project is run without a .env file or any of it's environment variables specified.

    opened by atrauzzi 1
  • Ripcord

    Ripcord

    I would like to create a script that is called ripcord.sh that essentially does all the install steps in one go.

    Reason: New users can run a single command that gets their environment up and running.

    ie:

    #!/bin/bash
    ./run composer install (you will likely encounter github's rate limit)
    ./run artisan migrate (although the demo doesn't rely on any models)
    ./run npm install
    ./run jspm install
    docker-compose up
    
    opened by CMDann 0
  • Add `webapp.Dockerfile`

    Add `webapp.Dockerfile`

    This will be used to produce production-ready containers.

    Be sure to put some kind of comment inside of it indicating that one is better served by not building in their local dev checkout as deps get clobbered.

    opened by atrauzzi 0
  • Add a `./configure` command and/or create a project config file

    Add a `./configure` command and/or create a project config file

    ...to do string substitutions and be used during build commands.

    • Project name
    • Repository and tag (organizational/project:tag)
    • Optional host for non-docker-hub repository hosting
    • Maintainer info
    opened by atrauzzi 0
  • Disable evil PHP functions

    Disable evil PHP functions

    Worth going through and auditing functions that are notorious for bad things.

    Stuff like string-based file functions: http://php.net/manual/en/ref.filesystem.php

    Likely others.

    opened by atrauzzi 1
Releases(5.2.0)
  • 5.2.0(Aug 21, 2016)

    The first release of laravel drydock, started early 2016. Features local development via docker and some advice on supporting queue, database and caching services.

    Source code(tar.gz)
    Source code(zip)
Owner
Alexander Trauzzi
Alexander Trauzzi
A collection of classes to be extended/used in laravel apps for quick development

laraquick A collection of classes to be extended/used in laravel applications for quick development. Introduction The library contains traits with wel

Ezra Obiwale 35 Dec 13, 2022
Jumpstart your web development journey with the HALT Stack Starter Kit, a one-command solution for creating dynamic, scalable, and clean web applications.

Welcome to the HALT Stack Starter Kit! This kit is designed to help you kickstart your web development projects using the HALT Stack, a powerful combi

HALT Stack 6 Jun 7, 2023
Package for Laravel that gives artisan commands to setup and edit environment files.

Setup and work with .env files in Laravel from the command line NOTE: This doesn't work with Laravel 5 since .env files were changed. This is for Lara

Matt Brunt 6 Dec 17, 2022
Easily setup SEO in your laravel project with lara-head :heart: @code4mk

installation composer require code4mk/lara-head usage meta ~ inside controller use Khead; class Test { public function home() { Khead::setMeta

null 173 Dec 23, 2022
Flysystem storage with local metadata storage for speed and manageability.

Laravel Filer This project was started to scratch my itch on our growing Laravel site: Metadata for all files is stored in a local repository - Suppor

Nick Vahalik 16 May 23, 2022
Intranet Home Page is a highly-configurable self-hosted browser homepage with integrations for public and local data feeds.

Intranet-Home-Page Created in response to personal "dashboards" that are little more than pages with a list of frequently accessed links, Intranet Hom

null 56 Aug 27, 2022
If you are beginner in WordPress plugin development or if you want to develop your own store product plugin you use this plugin

hirwa-products-plugin If you are beginner in WordPress plugin development or if you want to develop your own store product plugin you use this plugin

NIYIBIZI HIRWA 1 Aug 23, 2022
Zarinpal is a laravel package to easily use zarinpal.com payment services in your applications

پکیج اتصال به درگاه پرداخت زرین پال zarinpal.com برای اتصال به درگاه پرداخت اینترنتی زرین پال و استفاده از api های آن می توانید از این پکیج استفاده کن

Rahmat Waisi 4 Jan 26, 2022
Navigator is a package to create headless navigation menus for use in Laravel applications

Navigator Navigator is a package to create headless navigation menus for use in Laravel applications: // In a Service Provider Nav::define(fn ($user)

Sam Rowden 36 Oct 30, 2022
Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app

Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app

null 9 Dec 14, 2022
Laravel-FCM is an easy to use package working with both Laravel and Lumen for sending push notification with Firebase Cloud Messaging (FCM).

Laravel-FCM Introduction Laravel-FCM is an easy to use package working with both Laravel and Lumen for sending push notification with Firebase Cloud M

Rahul Thapa 2 Oct 16, 2022
An easy-to-use virtual wallet implementation for Laravel

Laravel Wallet Some apps require a prepayment system like a virtual wallet where customers can recharge credits which they can then use to pay in app

Muath Assawadi 6 Sep 28, 2022
An easy-to-use virtual wallet implementation for Laravel.

Laravel Wallet Some apps require a prepayment system like a virtual wallet where customers can recharge credits which they can then use to pay in app

Muathye 1 Feb 6, 2022
Laravel Setting - Easily save, update and get titles, descriptions, and more. it is very easy to use.

Laravel Setting Easily save, update and get titles, descriptions, and more. it is very easy to use. This is great for storing and receiving general si

Ali Ranjbar 2 Aug 23, 2022
Easy-to-use SDK for implementing Neshan APIs in your Laravel projects.

Neshan Laravel SDK Easy-to-use SDK for implementing Neshan APIs in your Laravel projects. Install The easiest way to install is by using Composer: com

null 1 Oct 22, 2022
A flexible, seamless and easy to use multitenancy solution for Laravel

Main: Develop: Tenanted Laravel A flexible, seamless and easy to use multitenancy solution for Laravel This package is currently under development. Ch

Tenanted Laravel 12 May 29, 2023
Livewire DataTables components for back-end. Modular, easy to use, with tons of features.

Livewire DataTables Livewire DataTables components for back-end. Modular, easy to use, with tons of features. Inspired by Caleb's Livewire Screencasts

Amir Rami 8 Jul 27, 2022
Barcode generator in PHP that is easy to use, non-bloated and framework independent.

PHP Barcode Generator This is an easy to use, non-bloated, framework independent, barcode generator in PHP. It creates SVG, PNG, JPG and HTML images,

Picqer 1.4k Jan 6, 2023
A collection of easy-to-use filters with clause conditions to Filament

Filament Advanced Filter A collection of easy-to-use filters with clause conditions to Filament Installation Install the package via composer (require

Webbing Brasil 45 Jan 2, 2023