Skip to content

Instantly share code, notes, and snippets.

@thiagobraga
Last active November 20, 2018 13:19
Show Gist options
  • Save thiagobraga/cef2fb8afcc0b69376268d060d8abf72 to your computer and use it in GitHub Desktop.
Save thiagobraga/cef2fb8afcc0b69376268d060d8abf72 to your computer and use it in GitHub Desktop.
Laravel | Creating projects with Docker

Laravel | Creating projects with Docker

A minimal setup for creating Laravel projects with Docker. The containers use Alpine Linux as base image.

Technologies used

  • Nginx 1.15
  • PHP-FPM 7.2
  • Composer 1.7.2
  • Node 8.12

Files

version: '3'
services:
nginx:
build: docker/nginx
volumes:
- ./:/var/www
ports:
- 80:80
- 443:443
php-fpm:
build: docker/php-fpm
volumes:
- ./:/var/www
expose:
- 9000
node:
build: docker/node
volumes:
- ./:/var/www
ports:
- 3000:3000
workspace:
build: docker/workspace
volumes:
- ./:/var/www
user www-data;
worker_processes 4;
pid /run/nginx.pid;
daemon off;
events {
worker_connections 2048;
multi_accept on;
use epoll;
}
http {
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 15;
types_hash_max_size 2048;
client_max_body_size 20M;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /dev/stdout;
error_log /dev/stderr;
gzip on;
gzip_disable "msie6";
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-available/*.conf;
open_file_cache off; # Disabled for issue 619
charset UTF-8;
}
upstream php-upstream {
server php-fpm:9000;
}
server {
listen 80;
server_name localhost;
root /var/www/public;
index index.php index.html index.htm;
error_log /var/log/nginx/local.redis_error.log;
access_log /var/log/nginx/local.redis_access.log;
gzip on;
gzip_disable "MSIE [1-6]\\.(?!.*SV1)";
gzip_proxied any;
gzip_comp_level 5;
gzip_types text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp image/svg+xml;
gzip_vary on;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 600;
include fastcgi_params;
}
location /.well-known/acme-challenge/ {
root /var/www/letsencrypt/;
log_not_found off;
}
}
FROM nginx:1.15-alpine
RUN adduser -D -u 1000 www-data \
&& rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/
COPY default.conf /etc/nginx/conf.d/
EXPOSE 80 443
CMD nginx
FROM node:8.12.0-alpine
USER node
RUN mkdir ~/.npm-global \
&& npm config set prefix '~/.npm-global' \
&& export PATH=~/.npm-global/bin:$PATH \
&& npm i -g yarn
WORKDIR /var/www
EXPOSE 3000
CMD tail -f /dev/null
FROM php:7.2-fpm-alpine
RUN mkdir -p /var/www
WORKDIR /var/www
EXPOSE 9000
CMD php-fpm
FROM postgres:9.6-alpine
EXPOSE 5432
CMD postgres
FROM composer:1.7.2
WORKDIR /var/www
CMD tail -f /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment