-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Домашнее задание №4 - Броузерное приложение и балансировщик #1169
Open
Anton-Shishak
wants to merge
9
commits into
main
Choose a base branch
from
AShishak/hw4
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
19ad3b5
Домашнее задание №4 - Броузерное приложение и балансировщик
Anton-Shishak 30c8e92
Домашнее задание №4 - Переписал валидатор
Anton-Shishak 7e8f5c2
Домашнее задание №4 - Сделал балансировщик
Anton-Shishak 0bbd5e4
Домашнее задание №4 - приведению к стандарту написания кода в github
Anton-Shishak f345265
Домашнее задание №4 - приведению к стандарту написания кода в github
Anton-Shishak 2c2d70c
Домашнее задание №4 - приведению к стандарту написания кода в github
Anton-Shishak 16dffea
Домашнее задание №4 - приведению к стандарту написания кода в github
Anton-Shishak 0cda2b3
Домашнее задание №4 - приведению к стандарту написания кода в github
Anton-Shishak 31472f2
Домашнее задание №4 - приведению к стандарту написания кода в github
Anton-Shishak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
phpcs.xml | ||
.github | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
version: '3' | ||
|
||
services: | ||
|
||
# Контейнер с Nginx-балансировщиком | ||
nginx-balancer: | ||
# имя будущего образа | ||
image: nginx | ||
build: | ||
context: ./docker/nginx | ||
dockerfile: Dockerfile | ||
# имя контейнера после запуска | ||
container_name: nginx-balancer | ||
# проброс портов | ||
ports: | ||
- "80:80" | ||
volumes: | ||
- ./nginx/balancer.conf:/etc/nginx/conf.d/app.local.conf | ||
networks: | ||
- app-network | ||
|
||
# Контейнеры с Nginx | ||
nginx1: | ||
# имя будущего образа | ||
image: nginx | ||
build: | ||
context: ./docker/nginx | ||
dockerfile: Dockerfile | ||
# имя контейнера после запуска | ||
container_name: nginx1 | ||
# проброс портов, т.к. 80й уже занят балансировщиком, указываем 81 | ||
ports: | ||
- "81:80" | ||
volumes: | ||
- ./src/:/data/app.local | ||
- ./nginx/nginx1.conf:/etc/nginx/conf.d/app.local.conf | ||
networks: | ||
- app-network | ||
|
||
nginx2: | ||
# имя будущего образа | ||
image: nginx | ||
build: | ||
context: ./docker/nginx | ||
dockerfile: Dockerfile | ||
# имя контейнера после запуска | ||
container_name: nginx2 | ||
# проброс портов | ||
ports: | ||
- "82:80" | ||
volumes: | ||
- ./src/:/data/app.local | ||
- ./nginx/nginx2.conf:/etc/nginx/conf.d/app.local.conf | ||
networks: | ||
- app-network | ||
|
||
nginx3: | ||
# имя будущего образа | ||
image: nginx | ||
build: | ||
context: ./docker/nginx | ||
dockerfile: Dockerfile | ||
# имя контейнера после запуска | ||
container_name: nginx3 | ||
# проброс портов | ||
ports: | ||
- "83:80" | ||
volumes: | ||
- ./src/:/data/app.local | ||
- ./nginx/nginx3.conf:/etc/nginx/conf.d/app.local.conf | ||
networks: | ||
- app-network | ||
|
||
app1: | ||
build: | ||
context: ./fpm | ||
dockerfile: Dockerfile | ||
image: balance/php | ||
container_name: app1 | ||
volumes: | ||
- ./src/:/data/app.local | ||
networks: | ||
- app-network | ||
|
||
app2: | ||
build: | ||
context: ./fpm | ||
dockerfile: Dockerfile | ||
image: balance/php | ||
container_name: app2 | ||
volumes: | ||
- ./src/:/data/app.local | ||
networks: | ||
- app-network | ||
|
||
app3: | ||
build: | ||
context: ./fpm | ||
dockerfile: Dockerfile | ||
image: balance/php | ||
container_name: app3 | ||
volumes: | ||
- ./src/:/data/app.local | ||
networks: | ||
- app-network | ||
|
||
memcached01: | ||
image: memcached:latest | ||
container_name: memcached01 | ||
ports: | ||
- "11201:11211" | ||
networks: | ||
- app-network | ||
|
||
memcached02: | ||
image: memcached:latest | ||
container_name: memcached02 | ||
ports: | ||
- "11202:11211" | ||
networks: | ||
- app-network | ||
|
||
networks: | ||
app-network: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
FROM php:8.1.22-fpm-alpine | ||
|
||
#RUN docker-php-ext-install sockets | ||
|
||
#RUN set -x \ | ||
# && addgroup -g 101 -S nginx \ | ||
# && adduser -u 101 -D -S -G nginx nginx | ||
|
||
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ | ||
|
||
RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \ | ||
&& pecl install uploadprogress \ | ||
&& docker-php-ext-enable uploadprogress \ | ||
&& apk del .build-deps $PHPIZE_DEPS \ | ||
&& chmod uga+x /usr/local/bin/install-php-extensions && sync \ | ||
&& install-php-extensions bcmath \ | ||
bz2 \ | ||
calendar \ | ||
# curl \ | ||
exif \ | ||
# fileinfo \ | ||
# ftp \ | ||
gd \ | ||
gettext \ | ||
# imagick \ | ||
imap \ | ||
intl \ | ||
ldap \ | ||
# mbstring \ | ||
mcrypt \ | ||
memcache \ | ||
memcached \ | ||
# mongodb \ | ||
mysqli \ | ||
opcache \ | ||
# openssl \ | ||
# pdo \ | ||
pdo_pgsql \ | ||
pdo_mysql \ | ||
# pgsql \ | ||
redis \ | ||
soap \ | ||
# sodium \ | ||
sysvsem \ | ||
sysvshm \ | ||
xmlrpc \ | ||
xsl \ | ||
zip \ | ||
# && echo -e "\n opcache.enable=1 \n opcache.enable_cli=1 \n opcache.memory_consumption=128 \n opcache.interned_strings_buffer=8 \n opcache.max_accelerated_files=4000 \n opcache.revalidate_freq=60 \n opcache.fast_shutdown=1" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini \ | ||
# && echo -e "\n xdebug.remote_enable=1 \n xdebug.remote_host=localhost \n xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ | ||
# && echo -e "\n xhprof.output_dir='/var/tmp/xhprof'" >> /usr/local/etc/php/conf.d/docker-php-ext-xhprof.ini \ | ||
&& cd ~ \ | ||
&& php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ | ||
&& php -r "copy('https://composer.github.io/installer.sig', 'signature');" \ | ||
&& php -r "if (hash_file('SHA384', 'composer-setup.php') === trim(file_get_contents('signature'))) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \ | ||
&& php composer-setup.php --install-dir=/usr/local/bin --filename=composer \ | ||
&& php -r "unlink('composer-setup.php');" | ||
|
||
COPY ./php.ini /usr/local/etc/php/conf.d/php-custom.ini | ||
|
||
WORKDIR /data/app.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
session.save_handler=memcache | ||
session.save_path="tcp://memcache01:11211, tcp://memcache02:11211" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM ubuntu:latest | ||
|
||
RUN apt-get update | ||
|
||
RUN apt-get install -y nginx | ||
|
||
WORKDIR /data | ||
|
||
VOLUME /data | ||
|
||
EXPOSE 80 | ||
|
||
CMD ["nginx", "-g", "daemon off;"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
upstream php-fpm-backend { | ||
least_conn; | ||
server php-fpm-01:9000 max_fails=3 fail_timeout=30s; | ||
server php-fpm-02:9000 max_fails=3 fail_timeout=30s; | ||
server php-fpm-03:9000 max_fails=3 fail_timeout=30s; | ||
server php-fpm-04:9000 max_fails=3 fail_timeout=30s; | ||
} | ||
|
||
server { | ||
# указали 80 порт для соединения | ||
listen 80; | ||
|
||
# указали домен для нашего приложения | ||
server_name app.local; | ||
|
||
# задаем корневую директорию | ||
root /data/app.local/public; | ||
|
||
# старторый файл | ||
index index.php index.html; | ||
|
||
# при обращении к статическим файлам логи не нужны, равно как и обращение к fpm | ||
location ~* .(jpg|jpeg|gif|css|png|js|ico|html)$ { | ||
access_log off; | ||
expires max; | ||
} | ||
|
||
# помним про единую точку доступа | ||
# все запросы заворачиваются в корневую директорию root на index.php | ||
location / { | ||
try_files $uri $uri/ /index.php; | ||
} | ||
|
||
# и наконец правило обращения к php-fpm | ||
location ~* .php$ { | ||
try_files $uri = 404; | ||
fastcgi_split_path_info ^(.+.php)(/.+)$; | ||
fastcgi_pass php-fpm-backend; | ||
fastcgi_index index.php; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
include fastcgi_params; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
upstream nginx-webservers { | ||
least_conn; | ||
server nginx1:80; | ||
server nginx2:80; | ||
server nginx3:80; | ||
} | ||
|
||
server { | ||
# указываем 80 порт для соединения | ||
listen 80; | ||
# нужно указать, какому доменному имени принадлежит наш конфиг | ||
server_name app.local; | ||
|
||
# перенаправляем на указанный список серверов в блоке upstream | ||
location / { | ||
proxy_pass http://nginx-webservers; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
server { | ||
# указываем 80 порт для соединения | ||
listen 80; | ||
# нужно указать, какому доменному имени принадлежит наш конфиг | ||
server_name app.local; | ||
|
||
# задаем корневую директорию | ||
root /data/app.local/public; | ||
|
||
# стартовый файл | ||
index index.php index.html; | ||
|
||
# при обращении к статическим файлам логи не нужны, равно как и обращение к fpm | ||
location ~* .(jpg|jpeg|gif|css|png|js|ico|html)$ { | ||
access_log off; | ||
expires max; | ||
} | ||
|
||
# помним про единую точку доступа | ||
# все запросы заворачиваются в корневую директорию root на index.php | ||
location / { | ||
try_files $uri $uri/ /index.php?$query_string; | ||
} | ||
|
||
# и наконец правило обращения к php-fpm | ||
location ~* .php$ { | ||
try_files $uri = 404; | ||
fastcgi_split_path_info ^(.+.php)(/.+)$; | ||
fastcgi_pass app1:9000; | ||
fastcgi_index index.php; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
include fastcgi_params; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
server { | ||
# указываем 80 порт для соединения | ||
listen 80; | ||
# нужно указать, какому доменному имени принадлежит наш конфиг | ||
server_name app.local; | ||
|
||
# задаём корневую директорию | ||
root /data/app.local/public; | ||
|
||
# стартовый файл | ||
index index.php index.html; | ||
|
||
# при обращении к статическим файлам логи не нужны, равно как и обращение к fpm | ||
location ~* .(jpg|jpeg|gif|css|png|js|ico|html)$ { | ||
access_log off; | ||
expires max; | ||
} | ||
|
||
# помним про единую точку доступа | ||
# все запросы заворачиваются в корневую директорию root на index.php | ||
location / { | ||
try_files $uri $uri/ /index.php?$query_string; | ||
} | ||
|
||
# и наконец правило обращения к php-fpm | ||
location ~* .php$ { | ||
try_files $uri = 404; | ||
fastcgi_split_path_info ^(.+.php)(/.+)$; | ||
fastcgi_pass app2:9000; | ||
fastcgi_index index.php; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
include fastcgi_params; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
server { | ||
# указываем 80 порт для соединения | ||
listen 80; | ||
# нужно указать, какому доменному имени принадлежит наш конфиг | ||
server_name app.local; | ||
|
||
# задаём корневую директорию | ||
root /data/app.local/public; | ||
|
||
# стартовый файл | ||
index index.php index.html; | ||
|
||
# при обращении к статическим файлам логи не нужны, равно как и обращение к fpm | ||
location ~* .(jpg|jpeg|gif|css|png|js|ico|html)$ { | ||
access_log off; | ||
expires max; | ||
} | ||
|
||
# помним про единую точку доступа | ||
# все запросы заворачиваются в корневую директорию root на index.php | ||
location / { | ||
try_files $uri $uri/ /index.php?$query_string; | ||
} | ||
|
||
# и наконец правило обращения к php-fpm | ||
location ~* .php$ { | ||
try_files $uri = 404; | ||
fastcgi_split_path_info ^(.+.php)(/.+)$; | ||
fastcgi_pass app3:9000; | ||
fastcgi_index index.php; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
include fastcgi_params; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
vendor/ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Есть образ с уже установленым nginx лучше использовать его.
https://hub.docker.com/_/nginx