Skip to content

Instantly share code, notes, and snippets.

@anish137i
Last active June 10, 2020 21:18
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 anish137i/884996bd2b1514aedae827f34c9ceffb to your computer and use it in GitHub Desktop.
Save anish137i/884996bd2b1514aedae827f34c9ceffb to your computer and use it in GitHub Desktop.
Docker Nginx MariaDB redis
version: '3'
services:
php:
container_name: ${APP_NAME}_php
build:
context: ./docker/php
volumes:
- ./:/var/www/html
web:
container_name: ${APP_NAME}_web
image: nginx:1.19.0
working_dir: /var/www/html
volumes:
- ./:/var/www/html
- ./docker/nginx/nginx_template_local.conf:/etc/nginx/conf.d/default.conf
ports:
- 9191:80
db:
container_name: ${APP_NAME}_db
image: mariadb:10.5.3
restart: always
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
MYSQL_ROOT_HOST: "%"
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_USER: ${DB_USERNAME}
MYSQL_PASSWORD: ${DB_PASSWORD}
ports:
- 9306:3306
volumes:
- ./sqldata:/var/lib/mysql
cache:
container_name: ${APP_NAME}_cache
image: redis:6.0.5
ports:
- 63790:6379
server {
listen 80;
server_name _;
root /var/www/html/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
access_log /dev/stdout;
error_log /dev/stdout;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass php:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
FROM php:7.4-fpm
WORKDIR /var/www/html
RUN apt-get update -yqq && \
apt-get install -y apt-utils zip unzip && \
apt-get install -y libzip-dev libpq-dev && \
docker-php-ext-install pdo_mysql && \
docker-php-ext-install zip && \
pecl install -o -f redis-6.0.5 && \
docker-php-ext-enable redis && \
rm -rf /var/lib/apt/lists/*
RUN php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer
@anish137i
Copy link
Author

anish137i commented Jun 10, 2020

Docker Details

  • PHP FPM 7.4
  • NGINX 1.19.0
  • MARIADB 10.5.3
  • REDIS 6.0.5

docker-nginx-nginx_template_local.conf is can be used from laravel only changes in fpm socket where we used default php as host and added log function

Database used MariaDB where from Local host i used port 9306 because my XAMPP enviorment use default Port

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment