Skip to content

Instantly share code, notes, and snippets.

@jeremykendall
Created December 16, 2016 02:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremykendall/48c657373445d2c0e27e57f8a4ff1289 to your computer and use it in GitHub Desktop.
Save jeremykendall/48c657373445d2c0e27e57f8a4ff1289 to your computer and use it in GitHub Desktop.
My jankie, but functional, PHP/MySQL/nginx docker env
version: '2'
services:
nginx:
build:
context: ./
dockerfile: ./resources/nginx/nginx.dockerfile
volumes:
- ./:/var/www/html
- ./resources/nginx/default.conf:/etc/nginx/conf.d/default.conf
links:
- phpserver
ports:
- "80:80"
- "443:443"
phpserver:
build:
context: ./
dockerfile: ./resources/php/phpserver.dockerfile
volumes:
- ./:/var/www/html
environment:
TERM: xterm
db:
image: mysql
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: dbname
MYSQL_USER: user
MYSQL_PASSWORD: password
volumes:
- /var/lib/mysql
# sql and dump files placed here will be executed when the container starts (or is built?)
- ./resources/mysql/sql:/docker-entrypoint-initdb.d
server {
server_name server.local;
root /var/www/html/web;
location / {
# try to serve file directly, fallback to front controller
try_files $uri /index.php$is_args$args;
}
# If you have 2 front controllers for dev|prod use the following line instead
location ~ ^/(index|index_dev)\.php(/|$) {
# location ~ ^/index\.php(/|$) {
fastcgi_pass phpserver:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
# Prevents URIs that include the front controller. This will 404:
# http://domain.tld/index.php/some-path
# Enable the internal directive to disable URIs like this
# internal;
}
#return 404 for all php files as we do have a front controller
location ~ \.php$ {
return 404;
}
}
FROM nginx
COPY ./resources/nginx/default.conf /etc/nginx/conf.d/default.conf
FROM php:fpm
RUN docker-php-ext-install bcmath mbstring
RUN pecl install xdebug && \
docker-php-ext-enable xdebug
COPY ./resources/php/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment