Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.idea
2 changes: 2 additions & 0 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
UID=3000
NGINX_PHP_USER=nginxphpuser
2 changes: 2 additions & 0 deletions docker/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
UID=3000
NGINX_PHP_USER=nginxphpuser
2 changes: 2 additions & 0 deletions docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
data
12 changes: 12 additions & 0 deletions docker/app/public/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

try {
$mc = new Memcached();
$mc->addServer("memcached", 11211);

$redis = new Redis();
$redis->connect('redis');

} catch (\Throwable $e) {
echo $e->getMessage();
}
52 changes: 52 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
version: '3.8'

services:
nginx:
container_name: nginx
build:
context: ./docker/nginx
args:
UID: $UID
NGINX_PHP_USER: $NGINX_PHP_USER
volumes:
- ./app:/var/www/html
- ./docker/sock:/sock
ports:
- "8787:80"

php-fpm:
container_name: php-fpm
build:
context: ./docker/php-fpm
args:
UID: $UID
NGINX_PHP_USER: $NGINX_PHP_USER
volumes:
- ./app:/var/www/html
- ./docker/sock:/sock

postgres:
image: postgres:9.5.6
restart: always
container_name: postgres
volumes:
- ./data/postgres:/var/lib/postgresql/data
environment:
POSTGRES_DB: user
POSTGRES_USER: user
POSTGRES_PASSWORD: user
ports:
- "5432:5432"

redis:
build:
context: ./docker/redis

memcached:
build:
context: ./docker/memcached
ports:
- '11211:11211'



1 change: 1 addition & 0 deletions docker/docker/memcached/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM memcached:1.6.9
11 changes: 11 additions & 0 deletions docker/docker/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM nginx
WORKDIR /var/www/html

ARG UID
ARG NGINX_PHP_USER

COPY nginx.conf /etc/nginx/nginx.conf
COPY mysite.conf /etc/nginx/conf.d/default.conf
RUN addgroup --gid $UID --system $NGINX_PHP_USER \
&& adduser --uid $UID --system --disabled-login --disabled-password --gid $UID $NGINX_PHP_USER \
&& sed -i -r "s/%REPLACE_USERNAME%/$NGINX_PHP_USER/g" /etc/nginx/nginx.conf
21 changes: 21 additions & 0 deletions docker/docker/nginx/mysite.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
server {
listen 80;
listen [::]:80;

index index.php;
root /var/www/html/public;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
fastcgi_pass unix:/sock/docker.sock;
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
}
40 changes: 40 additions & 0 deletions docker/docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
user %REPLACE_USERNAME%;
worker_processes auto;

pid /var/run/nginx.pid;
error_log /var/log/nginx/error.log crit;

events {
use epoll;
worker_connections 4096;
multi_accept on;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

access_log off;

keepalive_timeout 30;
keepalive_requests 100;

client_max_body_size 1m;
client_body_timeout 10;
reset_timedout_connection on;
send_timeout 2;
sendfile on;
tcp_nodelay on;
tcp_nopush on;

gzip on;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;

open_file_cache max=200000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;

include /etc/nginx/conf.d/*.conf;

}
50 changes: 50 additions & 0 deletions docker/docker/php-fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
FROM php:7.4-fpm

ARG UID
ARG NGINX_PHP_USER
ENV DOCKER_PATH=/usr/local/etc/php-fpm.d/zz-docker.conf

COPY zz-docker.conf $DOCKER_PATH


RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
&& apt-get update \
&& apt-get install -y \
git \
curl \
wget \
grep \
zip \
unzip \
libmemcached-dev \
zlib1g-dev \
libzip-dev \
libcurl4-openssl-dev \
libbrotli-dev \
libevent-dev \
libicu-dev \
libidn11-dev \
libidn2-0-dev \
libssl-dev \
libpq-dev \
libonig-dev \
librabbitmq-dev \
nano \
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
&& pecl install memcached \
&& docker-php-ext-enable memcached \
&& docker-php-ext-install pdo pdo_pgsql pgsql \
&& pecl install xdebug-2.9.8 && docker-php-ext-enable xdebug \
&& pecl install -o redis && docker-php-ext-enable redis \
&& docker-php-ext-install zip sockets bcmath mbstring \
&& pecl install amqp && docker-php-ext-enable amqp \
&& addgroup --gid $UID --system $NGINX_PHP_USER \
&& adduser --uid $UID --system --disabled-login --disabled-password --gid $UID $NGINX_PHP_USER \
&& sed -i -r "s/%REPLACE_USERNAME%/$NGINX_PHP_USER/g" $DOCKER_PATH \
&& rm -rf /tmp/pear

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

WORKDIR /var/www/html

CMD ["php-fpm"]
8 changes: 8 additions & 0 deletions docker/docker/php-fpm/zz-docker.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[global]
daemonize = no

[www]
listen = /sock/docker.sock
listen.owner = %REPLACE_USERNAME%
listen.group = %REPLACE_USERNAME%
listen.mode = 0660
1 change: 1 addition & 0 deletions docker/docker/redis/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM redis:6.2-rc2
1 change: 1 addition & 0 deletions virtual/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
homestead
32 changes: 32 additions & 0 deletions virtual/Homestead.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
- ~/.ssh/id_rsa

folders:
- map: ~/Documents/OTUS_HW/virtual/app
to: /home/vagrant/code

sites:
- map: application.local
to: /home/vagrant/code/public

databases:
- homestead

features:
- mysql: true
- mariadb: false
- postgresql: false
- ohmyzsh: false
- webdriver: false

ports:
- send: 8089
to: 80
2 changes: 2 additions & 0 deletions virtual/app/public/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
echo 'homestead';
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.