Skip to content
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

hw_11 #1194

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

hw_11 #1194

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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/
/app/.env
Empty file added .idea/.gitignore
Empty file.
8 changes: 8 additions & 0 deletions .idea/PHP_2023.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

965 changes: 965 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions app/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ELASTIC_USERNAME = elastic
ELASTIC_PASSWORD = elastic123
ES_PORT = https://elasticsearch:9200

WORK_DIR = /var/www
33 changes: 33 additions & 0 deletions app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Используем официальный образ PHP с FPM
FROM php:8.2-fpm

# Установка необходимых расширений PHP
RUN apt-get update && apt-get install -y \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
libonig-dev \
libzip-dev \
git \
curl \
libpq-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd pdo_mysql zip

# Установка Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Устанавливаем рабочую директорию приложения
WORKDIR /var/www

# Копируем файлы приложения в рабочую директорию
COPY ./www /var/www

# Устанавливаем зависимости Composer
RUN composer install --no-plugins --no-interaction

# Указываем порт, на котором будет работать приложение (если необходимо)
EXPOSE 9000

# Опционально: команда по умолчанию, которая будет выполнена при запуске контейнера
CMD ["php-fpm"]
14 changes: 14 additions & 0 deletions app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# PHP_2023

разворачиваем проект docker-compose up --build -d
docker compose exec -it php bash
cd /var/www
запускаем composer install

docker compose exec -it php bash для выполнения команд внутри контейнера

- Очистить эластик : php index.php "command=cleanup"
- Загружаем индексы и данные : php index.php "command=createIndex"
https://localhost:9200/otus-shop/_search проверяем данные
- Посмотреть все данные : php index.php "command=allData"
- Поиск по названию, категории и цене : php index.php "command=search" "title=Кто подставил поручика Ржевского на Луне" "category=Исторический роман" "minPrice=0" "maxPrice=2000"
31 changes: 31 additions & 0 deletions app/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '3.8'

services:
php:
build:
context: .
dockerfile: Dockerfile
container_name: php
volumes:
- ./www:/var/www
ports:
- "9000:9000"
networks:
- hw11-network

elasticsearch:
image: elasticsearch:8.12.2
container_name: elasticsearch
environment:
discovery.type: single-node
ELASTIC_USERNAME: ${ELASTIC_USERNAME}
ELASTIC_PASSWORD: ${ELASTIC_PASSWORD}
ES_PORT: ${ES_PORT}
ports:
- "9200:9200"
networks:
- hw11-network

networks:
hw11-network:
driver: bridge
1 change: 1 addition & 0 deletions app/www/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor
20,002 changes: 20,002 additions & 0 deletions app/www/books.json

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions app/www/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "alisa/hw11",
"type": "project",
"require": {
"elasticsearch/elasticsearch": "^8.12",
"shasoft/console": "^2.0"
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"config": {
"allow-plugins": {
"php-http/discovery": true
}
}
}
Loading
Loading