Skip to content

Instantly share code, notes, and snippets.

@msuryaprakash
Forked from michaelneu/Dockerfile
Created December 4, 2020 21:39
Show Gist options
  • Save msuryaprakash/f7f0123d21fd5f2358d28699f2bca601 to your computer and use it in GitHub Desktop.
Save msuryaprakash/f7f0123d21fd5f2358d28699f2bca601 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
    • XDebug connecting to the docker host
    • 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:17
    • 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
environment:
XDEBUG_CONFIG: remote_host=host.docker.internal
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:5-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 sysvsem
RUN pecl install xdebug-2.5.5 \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "[XDebug]" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_log=/tmp/xdebug.log" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=on" >> /usr/local/etc/php/conf.d/xdebug.ini
RUN echo "hostname=localhost.localdomain" > /etc/ssmtp/ssmtp.conf \
&& echo "root=root@localhost" >> /etc/ssmtp/ssmtp.conf \
&& echo "mailhub=maildev" >> /etc/ssmtp/ssmtp.conf \
&& echo "sendmail_path=sendmail -i -t" >> /usr/local/etc/php/conf.d/php-sendmail.ini
RUN echo "[Date]" >> /usr/local/etc/php/conf.d/php-sendmail.ini \
&& echo "date.timezone = Europe/Amsterdam" >> /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