Skip to content

Instantly share code, notes, and snippets.

@andrewwoods
Created July 2, 2019 02:20
Show Gist options
  • Save andrewwoods/6b8e335a1346e0a91c90764c4e2dbae8 to your computer and use it in GitHub Desktop.
Save andrewwoods/6b8e335a1346e0a91c90764c4e2dbae8 to your computer and use it in GitHub Desktop.
Laravel Docker Configuration
# building app and required component for running the app
version: '3'
services:
database:
build: docker/mysql
ports:
- "3306:3306"
environment:
- MYSQL_USER=laravel
- MYSQL_PASSWORD=laravel
web:
build: docker/nginx
ports:
- "80:80"
# we have configured our nginx container to have its webroot /var/www/public
# so we have to mount our project "example-proj" folder to /var/www
# we already have "public" folder in our project
volumes:
- .:/var/www
depends_on:
- php
- database
php:
build: docker/php
volumes:
- .:/var/www
working_dir: /var/www
expose:
- "9000"
# docker/mysql/Dockerfile
# MYSQL
FROM mysql:5.7
MAINTAINER Andrew Woods <atwoods1@@gmail.com>
ENV MYSQL_ROOT_PASSWORD laravel
ENV MYSQL_DATABASE laravel
# docker/nginx/Dockerfile
#nginx
FROM nginx:1.10
MAINTAINER Andrew Woods <[email protected]>
ADD vhost.conf /etc/nginx/conf.d/default.conf
# docker/nginx/vhost.conf
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 php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
#php-fpm
FROM php:7-fpm
MAINTAINER Andrew Woods <[email protected]>
RUN docker-php-ext-install pdo pdo_mysql
RUN docker-php-ext-enable pdo_mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment