Skip to content

Instantly share code, notes, and snippets.

@naxmefy
Last active May 15, 2018 13:54
Show Gist options
  • Select an option

  • Save naxmefy/cf8b4be0ac2f9880513a33f17cc8d16b to your computer and use it in GitHub Desktop.

Select an option

Save naxmefy/cf8b4be0ac2f9880513a33f17cc8d16b to your computer and use it in GitHub Desktop.
docker support for laravel projects

Docker support for Laravel Projects

Composer Dependencies

I created a gist to easy install composer deps. Can be found here: https://gist.github.com/naxmefy/a31832574cf56a3841c452ab60489b4d

just execute

# shell
$ docker run --rm -v $(pwd):/app composer/composer install

# windows cmd
$ docker run --rm -v %cd%:/app composer/composer install

Installation

Download this gist into your project folder.

Usage

$ docker-compose up -d

execute artisan commands

$ docker-compose exec app php artisan <artisan_command>

Setup ENV

# copy .env
$ cp .env.example .env

# generate key
$ docker-compose exec app php artisan key:generate

# optimize
$ docker-compose exec app php artisan optimize
FROM php:7.0.4-fpm
RUN apt-get update && apt-get install -y libmcrypt-dev \
mysql-client libmagickwand-dev --no-install-recommends \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& docker-php-ext-install mcrypt pdo_mysql
version: '2'
services:
# The Application
app:
build:
context: ./
dockerfile: app.dockerfile
working_dir: /var/www
volumes:
- ./:/var/www
environment:
- "DB_PORT=3306"
- "DB_HOST=database"
# The Web Server
web:
build:
context: ./
dockerfile: web.dockerfile
working_dir: /var/www
volumes_from:
- app
ports:
- 8080:80
# The Database
database:
image: mysql:5.6
volumes:
- dbdata:/var/lib/mysql
environment:
- "MYSQL_DATABASE=homestead"
- "MYSQL_USER=homestead"
- "MYSQL_PASSWORD=secret"
- "MYSQL_ROOT_PASSWORD=secret"
ports:
- "33061:3306"
volumes:
dbdata:
server {
listen 80;
index index.php index.html;
root /var/www/public;
location / {
try_files $uri /index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
FROM nginx:1.10
ADD vhost.conf /etc/nginx/conf.d/default.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment