Skip to content

Instantly share code, notes, and snippets.

@IsmailShurrab
Forked from michaelneu/Dockerfile
Created April 15, 2018 22:37
Show Gist options
  • Save IsmailShurrab/3392892a8bfd1291e4897e74bff257d9 to your computer and use it in GitHub Desktop.
Save IsmailShurrab/3392892a8bfd1291e4897e74bff257d9 to your computer and use it in GitHub Desktop.
docker-compose configuration for PHP with NGINX and MySQL, including sendmail, MailDev and phpmyadmin

docker-compose configuration

This configuration basically resembles a mix of cmaessen's docker-php-sendmail project and mikechernev's NGINX configuration.

It includes the following:

  • NGINX
  • PHP
    • FPM configured for NGINX
    • place .php files into a directory named "code" for them to be executable
  • sendmail
  • MailDev
    • you might want to adjust the root mail address in Dockerfile:10
    • port 8081
  • MySQL
    • you also might want to adjust the default password (which is "password") in docker-compose.yml
    • port 3306
  • phpmyadmin
    • defaults see docker-compose.yml, also consider changing the password here too
    • port 8082
web:
image: nginx:latest
ports:
- "8080:80"
volumes:
- ./code:/code
- ./nginx.conf:/etc/nginx/conf.d/default.conf
links:
- php
php:
build: .
volumes:
- ./code:/code
links:
- mysql
- maildev
mysql:
image: mysql:latest
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=password
phpmyadmin:
image: phpmyadmin/phpmyadmin
links:
- mysql:db
ports:
- "8082:80"
environment:
- PMA_USER=root
- PMA_PASSWORD=password
- PHP_UPLOAD_MAX_FILESIZE=100MB
maildev:
image: djfarrelly/maildev
ports:
- "8081:80"
# see https://github.com/cmaessen/docker-php-sendmail for more information
FROM php:fpm
RUN apt-get update && apt-get install -q -y ssmtp mailutils && rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-install mysql mysqli
RUN echo "hostname=localhost.localdomain" > /etc/ssmtp/ssmtp.conf
RUN echo "root=root@example.com" >> /etc/ssmtp/ssmtp.conf
RUN echo "mailhub=maildev" >> /etc/ssmtp/ssmtp.conf
RUN echo "sendmail_path=sendmail -i -t" >> /usr/local/etc/php/conf.d/php-sendmail.ini
RUN echo "localhost localhost.localdomain" >> /etc/hosts
# see https://github.com/mikechernev/dockerised-php for more information
server {
index index.php index.html;
server_name php-docker.local;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /code;
location ~ \.php$ {
try_files $uri =404;
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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment