Kind of lightweight setup using alpine when available (I'm looking at you MySQL).
Using jwilder/nginx-proxy
to have cool vhosts names.
Sadly We could not use ENVIRONMENT VARIABLES in nginx configuration, so it's not really DRY.
version: '2' | |
services: | |
nginx-proxy: | |
image: jwilder/nginx-proxy | |
container_name: nginx-proxy | |
ports: | |
- "80:80" | |
volumes: | |
- /var/run/docker.sock:/tmp/docker.sock:ro | |
web: | |
image: nginx:alpine | |
links: | |
- php | |
ports: | |
- 80 | |
volumes: | |
- ./config/docker/vhost.conf:/etc/nginx/conf.d/vhost.conf | |
- ./:/var/www/vhost | |
environment: | |
VIRTUAL_HOST: web.vhost.test | |
php: | |
ports: | |
- "9000:9000" | |
build: ./config/docker/images/fpm | |
links: | |
- db | |
volumes: | |
- ./:/var/www/vhost | |
db: | |
image: mysql:latest | |
volumes: | |
- ./.data/db:/var/lib/mysql | |
environment: | |
MYSQL_ROOT_PASSWORD: "password" | |
MYSQL_DATABASE: whatever | |
mail: | |
image: occitech/alpine-mailhog | |
ports: | |
- 8025 | |
environment: | |
VIRTUAL_HOST: mail.vhost.test | |
VIRTUAL_PORT: 8025 | |
phpmyadmin: | |
image: phpmyadmin/phpmyadmin | |
links: | |
- db | |
environment: | |
VIRTUAL_HOST: db.vhost.test | |
FROM php:fpm-alpine | |
RUN apk add --no-cache --update icu-libs icu icu-dev | |
RUN docker-php-ext-install intl pdo pdo_mysql |
server { | |
listen 80; | |
rewrite ^(.*) http://web.vhost.test$1 permanent; | |
} | |
server { | |
listen 80; | |
server_name web.vhost.test; | |
# root directive should be global | |
root /var/www/vhost/webroot; | |
index index.php; | |
access_log /var/www/vhost/logs/nginx-access.log; | |
error_log /var/www/vhost/logs/nginx-error.log; | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
include /etc/nginx/fastcgi_params; | |
fastcgi_pass php:9000; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
} | |
} |