Skip to content

Instantly share code, notes, and snippets.

@CristoferPortela
Forked from michaelneu/Dockerfile
Created November 26, 2020 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CristoferPortela/7d0ebaadb0ba3dc7aba79b3dc6c243f7 to your computer and use it in GitHub Desktop.
Save CristoferPortela/7d0ebaadb0ba3dc7aba79b3dc6c243f7 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