Skip to content

Instantly share code, notes, and snippets.

@falexandre
Last active March 17, 2019 13:02
Show Gist options
  • Save falexandre/6de8dbe3cae13d98eae29ea42ace98c7 to your computer and use it in GitHub Desktop.
Save falexandre/6de8dbe3cae13d98eae29ea42ace98c7 to your computer and use it in GitHub Desktop.
Docker PHP
#!/usr/bin/env bash
# See https://docs.docker.com/compose/environment-variables/#the-env-file
# Nginx
NGINX_HOST=devmeudominio.com.br
# PHP
PHP_VERSION=5.6.40
# MySQL
MYSQL_HOST=mysql
MYSQL_DATABASE=mylogin
MYSQL_ROOT_USER=myrootuser
MYSQL_ROOT_PASSWORD=123
MYSQL_USER=myuser
MYSQL_PASSWORD=123
# /private/etc/hosts
# 127.0.0.1 devmeudominio.com.br
# Nginx configuration
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name devmfamiliareal.com.br;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html;
client_max_body_size 200M;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
client_max_body_size 200M;
fastcgi_param PHP_VALUE "upload_max_filesize=200M \n post_max_size=200M";
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;
}
}
# server {
# server_name devmfamiliareal.com.br;
# listen 443 ssl;
# fastcgi_param HTTPS on;
# ssl_certificate /etc/ssl/server.pem;
# ssl_certificate_key /etc/ssl/server.key;
# ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
# index index.php index.html;
# error_log /var/log/nginx/error.log;
# access_log /var/log/nginx/access.log;
# root /var/www/html/public;
# 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;
# }
# }
# Nginx configuration
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name ${NGINX_HOST};
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html;
client_max_body_size 200M;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
client_max_body_size 200M;
fastcgi_param PHP_VALUE "upload_max_filesize=200M \n post_max_size=200M";
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;
}
}
# server {
# server_name ${NGINX_HOST};
# listen 443 ssl;
# fastcgi_param HTTPS on;
# ssl_certificate /etc/ssl/server.pem;
# ssl_certificate_key /etc/ssl/server.key;
# ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
# index index.php index.html;
# error_log /var/log/nginx/error.log;
# access_log /var/log/nginx/access.log;
# root /var/www/html/public;
# 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;
# }
# }
version: '3'
services:
web:
image: nginx:alpine
volumes:
- "./etc/nginx/default.conf:/etc/nginx/conf.d/default.conf"
- "./etc/nginx/default.template.conf:/etc/nginx/conf.d/default.template"
- "./etc/ssl:/etc/ssl"
- "./LOJA:/var/www/html"
ports:
- "8000:80"
- "3000:443"
environment:
- NGINX_HOST=${NGINX_HOST}
command: /bin/sh -c "envsubst '$$NGINX_HOST' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
restart: always
depends_on:
- php
- mysqldb
php:
image: nanoninja/php-fpm:${PHP_VERSION}
restart: always
volumes:
# - "./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini"
- "./LOJA:/var/www/html"
myadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
ports:
- "8080:80"
environment:
- PMA_ARBITRARY=1
- PMA_HOST=${MYSQL_HOST}
restart: always
depends_on:
- mysqldb
mysqldb:
image: mysql:5.5
container_name: ${MYSQL_HOST}
restart: always
env_file:
- ".env"
environment:
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
ports:
- "3306:3306"
volumes:
- ./data:/var/lib/mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment