Skip to content

Instantly share code, notes, and snippets.

@jmsfwk
Created January 31, 2019 16:11
Show Gist options
  • Save jmsfwk/f2c39eb8da03be99253cef6dcd3b1c57 to your computer and use it in GitHub Desktop.
Save jmsfwk/f2c39eb8da03be99253cef6dcd3b1c57 to your computer and use it in GitHub Desktop.
Laravel docker compose configuration
server {
listen 80;
root /usr/share/nginx/html;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# pass the PHP scripts to FastCGI server listening on php:9000
location ~ \.php$ {
root /app;
fastcgi_pass php:9000;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
version: "3"
services:
web:
image: nginx:alpine
ports:
- "80:80"
volumes:
- ./public:/usr/share/nginx/html:ro
- .docker/web/default.conf:/etc/nginx/conf.d/default.conf:ro
php:
image: php:7.1-fpm-alpine
volumes:
- .:/app
database:
env_file:
- .env
image: mysql
ports:
- "3306:3306"
volumes:
- database:/var/lib/mysql
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_USER: ${DB_USERNAME}
MYSQL_PASSWORD: ${DB_PASSWORD}
volumes:
database:
@jmsfwk
Copy link
Author

jmsfwk commented Jan 31, 2019

This will read the settings from the Laravel .env file to set up the database automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment