A Docker container for Laravel web apps

Overview

Ubuntu Docker container for Laravel web applications

Docker-laravel is a LEMP image for running Laravel web applications.

It extends docker-base, which contains Supervisor for process supervision, and other basic utilities. It is loosely inspired by phusion/baseimage-docker.

All packages for running a Laravel web app are bundled into a single image, based on Ubuntu 16.04 server.

These services run with process supervision:

  • cron
  • nginx
  • php-fpm (with extensions required for Laravel 5, plus php5-mysqlnd and and php5-curl)
  • mariadb-server
  • beanstalkd
  • artisan queue:listen (optional - uncomment /etc/supervisord/queue.conf)

These packages are preinstalled:

  • nano
  • curl
  • git
  • zip and unzip
  • php-cli
  • php-xdebug (installed, but disabled by default, see below)
  • composer
  • mariadb-client
  • nodejs with npm
  • phantomjs
  • wkhtmltopdf

Running a container

1. Download the public Docker image from Dockerhub:

	docker pull mtmacdonald/docker-laravel:version

2. Run the Docker image as a new Docker container:

	docker run -d \
	-p 80:80 -p 443:443 -p 3306:3306 \
	-v /home/app:/share \
	--restart=always \
	--name=appname \
	mtmacdonald/docker-laravel:version

Replace '/home/app' with the path to the Laravel application's root directory in the host. This directory is a shared volume and so can be used to access the application files in either the host or the container.

Managing the container

See the instructions in docker-base.

Installing Laravel

Laravel is not bundled in the Docker image. Laravel, or your own application, need to be installed manually:

In the container (see docker exec):

	cd /share
	git clone https://github.com/laravel/laravel .
	composer install
	chmod -R guo+w storage
	cp .env.example .env
	php artisan key:generate

XDebug

The XDebug PHP extension is installed but not enabled by default. To enable it:

	phpenmod xdebug
	phpenmod -s cli xdebug
Comments
  • SSH, Connection timed out

    SSH, Connection timed out

    At windows 10, I had downloaded the insecure_key :

    $ chown `whoami` insecure_key
    chown: invalid user: ‘Samir’
    

    And if I try to connect:

    $ docker inspect testing_phpstorm | grep IPA
            "SecondaryIPAddresses": null,
            "IPAddress": "172.17.0.4",
                    "IPAMConfig": null,
                    "IPAddress": "172.17.0.4",
    
    $  ssh -i ./insecure_key [email protected]
    ssh: connect to host 172.17.0.4 port 22: Connection timed out
    

    then I mapped port 20 to 220, and tried again:

    $ ssh -i ./insecure_key [email protected] -p 220
    ssh: connect to host 172.17.0.4 port 220: Connection timed out
    

    Can you please help?

    opened by hopewise 3
  • insecure_key failure

    insecure_key failure

    Hi,

    I am getting an error:

    "Warning: Failed to create the file insecure_key: Operation not supported curl: (23) Failed writing body (0 != 1675)"

    What could be wrong?

    opened by ZigaVukcevicDev 2
  • Did not work on Mac OSX

    Did not work on Mac OSX

    I tried building Dockerfile on windows 10 with no problems.. But when I tried to build in on Mac OS Capitan, I got this error:

    Step 8 : RUN /provision/provision.sh
     ---> Running in e08680f71aa2
    /bin/sh: 1: /provision/provision.sh: Permission denied
    

    I tried to add chmod +x

    RUN chmod +x /provision/provision.sh
    

    I could build the Dockerfile, but actually provision.sh was not executed.. so nothing was provisioned.. What do you advice?

    opened by hopewise 1
  • 5.2 requirements installed?

    5.2 requirements installed?

    I am getting errors when trying to run composer update, Are those requirements all installed?

    https://laravel.com/docs/5.2#server-requirements

    PHP >= 5.5.9 OpenSSL PHP Extension PDO PHP Extension Mbstring PHP Extension Tokenizer PHP Extension

    opened by hopewise 1
  • Replace MySQL with PostgreSQL

    Replace MySQL with PostgreSQL

    I'm trying to build a Laravel application (using Wercker) and when I try to run the unit tests I got this message:

    Doctrine\DBAL\Exception\DriverException: An exception occured in driver: could not find driver
    

    Perhaps this occurs because the image is assuming that I'll always use MySQL and thus didn't install packages like php5-pgsql, but that's not the case. My question is: how could I replace MySQL with PostgreSQL?

    Cheers.

    opened by andrepoleza 1
  • Improvement: Make MySQL optional

    Improvement: Make MySQL optional

    On our setup, we use Postgres instead of MySQL. Additionally, our database runs in its own container.

    It would be nice to add some configuration for disabling MySQL, as it would pretty much just waste server resources on my setup.

    opened by onbjerg 1
  • Add beanstalkd for Laravel queues

    Add beanstalkd for Laravel queues


    BEANSTALKD


    In docker:

    apt-get update

    sudo apt-get install -y beanstalkd

    Start beanstalkd

    sudo service beanstalkd start

    Start listing to queue tasks

    php artisan queue:listen

    Ctrl C - to close


    Composer.json require "pda/pheanstalk": "2.0.*"

    composer update

    app/config/queue.php default => beanstalkd

    Tutorial for Queue http://glenntaylor.co.uk/laravel/laravel-queues-with-beanstalkd#.VE9MuPmG_QE

    enhancement 
    opened by mtmacdonald 1
  • Why https is forced?

    Why https is forced?

    When I start the container, I try to view it in the browser, the https is enforced, and although the with volume mapping, I only see:

    404 Not Found
    
    nginx/1.4.6 (Ubuntu)
    

    I tried different ports, but I got the same result. I am using Docker version 1.10.1, OSX Capitan

    I tried to expose port 8080, and run php artisan --port=8080, but I got the same result above Could it an issue with docker itself? Anyone tried this on Mac Capitan with Docker 1.10?

    Any idea?

    opened by hopewise 0
  • /bin/sh: 1: /provision/provision.sh: not found

    /bin/sh: 1: /provision/provision.sh: not found

    When I build the image, I get this error on Windows 10:

    $ docker build -t samir/laravel .
    Sending build context to Docker daemon 62.49 MB
    Step 1 : FROM sameersbn/postgresql:9.4-12
     ---> d95a00f9aced
    Step 2 : MAINTAINER Mark Macdonald <[email protected]>
     ---> Using cache
     ---> de86df3ac2d7
    Step 3 : ENV HOME /root
     ---> Using cache
     ---> a3ab158f5690
    Step 4 : ENV DEBIAN_FRONTEND noninteractive
     ---> Using cache
     ---> 5ed19edeaec8
    Step 5 : CMD /usr/local/bin/supervisord -c /etc/supervisord.conf
     ---> Using cache
     ---> d325b24e37e5
    Step 6 : RUN mkdir /provision
     ---> Using cache
     ---> 95e3e725b1ed
    Step 7 : ADD provision /provision
     ---> Using cache
     ---> d8fa0e36b6b5
    Step 8 : RUN /provision/provision.sh
     ---> Running in 2f419596a0b5
    /bin/sh: 1: /provision/provision.sh: not found
    SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
    The command '/bin/sh -c /provision/provision.sh' returned a non-zero code: 127
    
    opened by hopewise 1
  • Used postgresql but..

    Used postgresql but..

    Hello,

    To use postgres, I had to start from another ubutnu image:

    FROM sameersbn/postgresql:9.4-12
    

    and at the end of the Dockerfile, I added:

    apt-get update
    apt-get install php5-pgsql
    

    but the resulted container said:

    SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host "postgis" (172.17.0.2) and accepting TCP/IP connections on port 54320?

    in my .env file I used:

    DB_HOST=postgis
    

    Although I am linking to the postgis image as:

    laravel: image: docker-laravel-postgres links: - postgis:postgis

    postgis: image: mdillon/postgis volumes: - C:\Users\Samir Sabri\Documents\postgis-data-folder:/var/lib/postgresql/data10

    env_file: .postgis_env
    
    ports:
        - "9090:9000"
        - "54320:5432"
    container_name: postgis-db
    

    the only way was to use my docker api url 192.168.99.100 as:

    DB_HOST=192.168.99.100

    Any idea?

    opened by hopewise 0
  • Cannot ssh into container

    Cannot ssh into container

    Followed your readme, but when I try to connect via ssh I get a timeout error after a minute of waiting.

    I got the insecure key, got the IP address, but I cannot login via the ssh command. I'm using Mac OS.

    Thanks,

    opened by pbreah 2
Owner
Mark Macdonald
Mark Macdonald
An enhanced version of the Laravel container.

Laravel Enhanced Container This package provides syntax sugar for the Laravel container calls and bindings, automatic resolution of bound implementati

Michael Rubel 84 Dec 14, 2022
A Laravel Wrapper for the CoinDCX API. Now easily connect and consume the CoinDCX Public API in your Laravel apps without any hassle.

This package provides a Laravel Wrapper for the CoinDCX API and allows you to easily communicate with it. Important Note This package is in early deve

Moinuddin S. Khaja 2 Feb 16, 2022
Ignition: a beautiful error page for Laravel apps

Ignition is a beautiful and customizable error page for Laravel applications running on Laravel 5.5 and newer. It is the default error page for all Laravel 6 applications.

Spatie 260 Dec 29, 2022
Manage self-hosted Google Fonts in Laravel apps

This package makes self-hosting Google Fonts as frictionless as possible for Laravel users. To load fonts in your application, register a Google Fonts embed URL and load it with the @googlefonts Blade directive.

Spatie 386 Dec 19, 2022
Automatically disable Google's FLoC in Laravel apps

Automatically disable Google's FLoC in Laravel apps This package will automatically disable Google's FLoC. Support us We invest a lot of resources int

Spatie 68 Oct 21, 2022
Add Server-Timing header information from within your Laravel apps.

Laravel Server Timings Add Server-Timing header information from within your Laravel apps. Installation You can install the package via composer: comp

Beyond Code 498 Dec 15, 2022
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
Postier is a Laravel API automation platform to transfer data and to sync apps.

Postier is a Laravel API automation platform to transfer data and to sync apps. You can build workflows with data and actions of multiple apps and apply logics to the data!

null 55 Oct 28, 2022
Enhance your laravel apps with WhatsApp's Cloud API

Enhance your laravel apps with WhatsApp's Cloud API Use Whatsapp API in your Laravel app! Support us Investing on this package is defintely a good mov

Ricardo Sawir 10 Dec 1, 2022
Custom Blade components to add sortable/drag-and-drop HTML elements in your apps.

Laravel Blade Sortable Demo Repo Installation You can install the package via composer: composer require asantibanez/laravel-blade-sortable After the

Andrés Santibáñez 370 Dec 23, 2022
Setting up the a docker + building a simple project on Mac-book using laravel sail

Sailing on mac-book Setting up the a docker + building a simple project on Mac-book with Laravel sail Installing Docker Well, installing docker is the

AmirH.Najafizadeh 3 Jul 31, 2022
A web app for detecting backend technologies used in a web app, Based on wappalyzer node module

About Techdetector This a web fingerprinting application, it detects back end technologies of a given domain by using the node module wappalyzer. And

Shobi 17 Dec 30, 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
Laravel Podcast is Laravel 5.5 web app that enables you to manage RSS feeds for your favorite podcasts and listen to the episodes in a seamless UI and User Authentication.

Laravel Podcast is Laravel 5.5 web app that enables you to manage RSS feeds for your favorite podcasts and listen to the episodes in a seamless UI and

Jeremy Kenedy 35 Dec 19, 2022
List of 77 languages for Laravel Framework 4, 5, 6, 7 and 8, Laravel Jetstream , Laravel Fortify, Laravel Breeze, Laravel Cashier, Laravel Nova and Laravel Spark.

Laravel Lang In this repository, you can find the lang files for the Laravel Framework 4/5/6/7/8, Laravel Jetstream , Laravel Fortify, Laravel Cashier

Laravel Lang 6.9k Jan 2, 2023
A web installer for Laravel

Laravel Web Installer | A Web Installer Package About Requirements Installation Routes Usage Contributing Help Screenshots License About Do you want y

Rachid Laasri 1.8k Dec 28, 2022
MediaDB is a web-based media streaming service written in Laravel and Vue.

MediaDB (API) MediaDB is a web-based media streaming service written in Laravel and Vue. The nginx-vod-module is used for on-the-fly repackaging of MP

François M. 53 Sep 3, 2022
Web application with Laravel in Backend and VueJS in Frontend

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Benjdia Saad 1 Oct 12, 2021
this package makes laravel website a progressive web application.

Laravel PWA You can follow this video tutorial as well for installation. Installation Install the package by the following command, composer require l

Shailesh Ladumor 86 Dec 16, 2022