forked from Alexey/DAS_2024_1
Compare commits
61 Commits
dozorova_a
...
bazunov_an
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eeac04be49 | ||
| 8a96320fd5 | |||
| bd25930973 | |||
| 37996c249a | |||
| 9456d4fe01 | |||
| c14e105db5 | |||
| 4d1e900721 | |||
| 7184d6d728 | |||
|
|
6e7055efa4 | ||
|
|
9e40adc53c | ||
|
|
4a36528cc7 | ||
| ad3988e5fc | |||
| 780b4b2924 | |||
| 5047b16cde | |||
| 2b87427299 | |||
|
|
21cdd4971d | ||
| 6b55b7b0fc | |||
| 47193155d9 | |||
| bc8c4c887e | |||
| 4a2adcc35a | |||
| d7cb666a0d | |||
| 6c642384c1 | |||
| bdb5cc07ed | |||
| e761e33201 | |||
|
|
ceee500b95 | ||
| 2be2c71b69 | |||
|
|
aa8180ba49 | ||
| c509e74465 | |||
| 314751f25c | |||
| 48f7f3a215 | |||
| f112d2a44b | |||
| 477afb824d | |||
| e7b9938278 | |||
|
|
ba7480cb4f | ||
| 520337f92d | |||
| 06d1d8cdd4 | |||
| 4c76a9dea6 | |||
| e5d0aa0b3d | |||
| d326e64f24 | |||
| 1a118ae71f | |||
| e9b06b1f27 | |||
|
|
1adaac9281 | ||
|
|
5e9e2600f3 | ||
| b6e311755e | |||
|
|
0c3e973307 | ||
| c474c13c4a | |||
| 8eedde24a1 | |||
| 829a04a913 | |||
| 57970b3333 | |||
| 1c77ba3272 | |||
| ce9527b1c9 | |||
| a1419f21ec | |||
| aac01e9f48 | |||
| 221f3e248b | |||
| 3d98388a13 | |||
| 4922e9075e | |||
| 891eae4211 | |||
| 0590f7b532 | |||
| 0eec58a347 | |||
|
|
c8dbd5fb37 | ||
| 253ad80e31 |
59
balakhonov_danila_lab_1/README.md
Normal file
59
balakhonov_danila_lab_1/README.md
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
# Лабораторная работа номер 1
|
||||||
|
|
||||||
|
> Здравствуйте меня зовут Балахонов Данила группа ПИбд-42
|
||||||
|
>
|
||||||
|
> *— Балахонов Данила ПИбд-42*
|
||||||
|
|
||||||
|
Видео лабораторной работы номер 1 доступно по этой [ссылке](https://drive.google.com/file/d/1Up_JzDcK_TjYLixpfYXN7PhJmOeg_Uck/view?usp=sharing).
|
||||||
|
|
||||||
|
## Как запустить лабораторную работу номер 1?
|
||||||
|
### Необходимые компоненты для запуска лабораторной работы номер 1
|
||||||
|
> Здесь рассказана установка необходимых компонентов для запуска лабораторной работы номер 1 под дистрибутив GNU/Linux **Ubuntu**.
|
||||||
|
|
||||||
|
Для запуска лабораторной работы номер 1 необходимы такие компоненты:
|
||||||
|
- Git
|
||||||
|
- Docker
|
||||||
|
- Docker compose
|
||||||
|
|
||||||
|
Чтобы установить **Git**, необходимо ввести данные команды в командную строку:
|
||||||
|
``` bash
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install git
|
||||||
|
```
|
||||||
|
|
||||||
|
Чтобы установить **Docker** и **Docker compose**, стоит ввести такие команды:
|
||||||
|
``` bash
|
||||||
|
# Настройка репозитория Docker
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install ca-certificates curl
|
||||||
|
sudo install -m 0755 -d /etc/apt/keyrings
|
||||||
|
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
|
||||||
|
sudo chmod a+r /etc/apt/keyrings/docker.asc
|
||||||
|
|
||||||
|
echo \
|
||||||
|
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
|
||||||
|
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
|
||||||
|
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||||
|
sudo apt-get update
|
||||||
|
|
||||||
|
# Установка Docker и его компонентов
|
||||||
|
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||||
|
```
|
||||||
|
### Запуск лабораторной работы номер 1
|
||||||
|
Для запуска лабораторной работы номер 1 необходимо **склонировать** репозиторий в любую папку и **перейти на ветку** balakhonov_danila_lab_1.
|
||||||
|
Далее в папке с `docker-compose.yaml` нужно вызвать такую команду:
|
||||||
|
``` bash
|
||||||
|
sudo docker-compose up -d
|
||||||
|
```
|
||||||
|
Таким образом будут запущены контейнеры в фоновом режиме.
|
||||||
|
## Какие технологии были использованы?
|
||||||
|
Для выполнения лабораторной работы номер 1 использовались такие технологии, как: *git*, *docker*, *docker compose*.
|
||||||
|
|
||||||
|
Сервисы, выбранные для запуска в docker-compose файле:
|
||||||
|
- *Gitea* - удобный сервис отслеживания версий разрабатываемого ПО
|
||||||
|
- *MediaWiki* - сервис создания и ведения электронной энциклопедии
|
||||||
|
- *PostgreSQL* - база данных, используемая сервисами выше
|
||||||
|
|
||||||
|
Системой, на которую были установлены указанные технологии, является Ubuntu 22.
|
||||||
|
## Что делает лабораторная работа номер 1?
|
||||||
|
Лабораторная работа номер 1 заключается в написании docker-compose файла для удобного запуска и администрирования сразу нескольких сервисов в docker-контейнерах.
|
||||||
58
balakhonov_danila_lab_1/docker-compose.yaml
Normal file
58
balakhonov_danila_lab_1/docker-compose.yaml
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
services:
|
||||||
|
# PostgreSQL
|
||||||
|
db:
|
||||||
|
# Образ контейнера PostgreSQL последней версии
|
||||||
|
image: postgres
|
||||||
|
# Название контейнера
|
||||||
|
container_name: db
|
||||||
|
# Переменные окружения для настройки базы данных
|
||||||
|
environment:
|
||||||
|
- POSTGRES_USER=gitea
|
||||||
|
- POSTGRES_PASSWORD=gitea
|
||||||
|
- POSTGRES_DB=gitea
|
||||||
|
# Настройка корневого каталога, где хранятся данные
|
||||||
|
# Слева указан каталог компьютера, справа - каталог контейнера
|
||||||
|
# Нужно для сохранения данных на сервере после отключения контейнера
|
||||||
|
volumes:
|
||||||
|
- ./postgres:/var/lib/postgresql/data
|
||||||
|
# Порт, через который можно будет подключиться к базе данных
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
# После перезапуска докера всегда запускать этот контейнер
|
||||||
|
restart: always
|
||||||
|
# Gitea
|
||||||
|
gitea:
|
||||||
|
# Используется Gitea последней версии
|
||||||
|
image: gitea/gitea
|
||||||
|
container_name: gitea
|
||||||
|
# После перезапуска докера всегда запускать этот контейнер
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- ./data:/var/lib/gitea
|
||||||
|
- ./config:/etc/gitea
|
||||||
|
- /etc/timezone:/etc/timezone:ro
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
ports:
|
||||||
|
- 3000:3000
|
||||||
|
- 2222:2222
|
||||||
|
environment:
|
||||||
|
- GITEA__database__DB_TYPE=postgres
|
||||||
|
- GITEA__database__HOST=db:5432
|
||||||
|
- GITEA__database__NAME=gitea
|
||||||
|
- GITEA__database__USER=gitea
|
||||||
|
- GITEA__database__PASSWD=gitea
|
||||||
|
# Указывается, что этот контейнер запускается только после запуска контейнера db
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
# MediaWiki
|
||||||
|
mediawiki:
|
||||||
|
# Образ контейнера MediaWiki последней версии
|
||||||
|
image: mediawiki
|
||||||
|
container_name: mediawiki
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 8080:80
|
||||||
|
links:
|
||||||
|
- db
|
||||||
|
volumes:
|
||||||
|
- ./images:/var/www/html/images
|
||||||
2
bazunov_andrew_lab_1/.gitignore
vendored
Normal file
2
bazunov_andrew_lab_1/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
ollama
|
||||||
|
./ollama
|
||||||
33
bazunov_andrew_lab_1/README.md
Normal file
33
bazunov_andrew_lab_1/README.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Распределенные вычисления и приложения Л1
|
||||||
|
## _Автор Базунов Андрей Игревич ПИбд-42_
|
||||||
|
|
||||||
|
В качестве сервисов были выбраны:
|
||||||
|
- 1.Ollama (_Сервис для использования LLMs моделей_)
|
||||||
|
- 2.Open Web Ui (_Сервис для удобного общения с моделью из сервиса Ollama_)
|
||||||
|
- 3.Gitea (_Гит сервис_)
|
||||||
|
|
||||||
|
# Docker
|
||||||
|
|
||||||
|
>Перед исполнением вполняем установку docker и проверяем версию
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker-compose --version
|
||||||
|
```
|
||||||
|
|
||||||
|
>Далее производим настройку файла docker-compose.yaml и запускаем контейнер
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
>Для завершения работы контейнера используем команду
|
||||||
|
```sh
|
||||||
|
docker-compose down
|
||||||
|
```
|
||||||
|
---
|
||||||
|
> Замечание: после запуска контейнера, необходимо перейти в контейнер **ollamа** и выполнить установку модели [gemma2](https://ollama.com/library/gemma2:2b)
|
||||||
|
> ```sh
|
||||||
|
> docker-compose exec ollama ollama run ollama run gemma2:2b
|
||||||
|
> ```
|
||||||
|
---
|
||||||
|
Далее можно использовать веб сервис Open Web Ui по адресу **localhost:8080** для общения с моделью и Gitea по адресу **localhost:3000** - [демонстрация работы](https://vk.com/video/@viltskaa?z=video236673313_456239574%2Fpl_236673313_-2)
|
||||||
61
bazunov_andrew_lab_1/docker-compose.yml
Normal file
61
bazunov_andrew_lab_1/docker-compose.yml
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
services:
|
||||||
|
gitea: # Имя сервиса
|
||||||
|
image: gitea/gitea:latest # Имя образа
|
||||||
|
container_name: gitea # Имя контейнера, может быть произовольным
|
||||||
|
ports:
|
||||||
|
- "3000:3000" # Проброс порта Gitea на хост
|
||||||
|
volumes: # хранилище
|
||||||
|
- data:/data
|
||||||
|
environment: # переменные окружения
|
||||||
|
USER_UID: 1000
|
||||||
|
USER_GID: 1000
|
||||||
|
|
||||||
|
ollama:
|
||||||
|
image: ollama/ollama:latest
|
||||||
|
container_name: ollama
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 7869:11434
|
||||||
|
pull_policy: always
|
||||||
|
tty: true
|
||||||
|
volumes:
|
||||||
|
- .:/code
|
||||||
|
- ./ollama/ollama:/root/.ollama # Директория для данных Ollama
|
||||||
|
environment:
|
||||||
|
- OLLAMA_KEEP_ALIVE=24h
|
||||||
|
- OLLAMA_HOST=0.0.0.0 # Указываем хост для API Ollama
|
||||||
|
networks:
|
||||||
|
- ollama-docker
|
||||||
|
command: ["serve"] # Запускаем Ollama в режиме сервера
|
||||||
|
|
||||||
|
ollama-webui:
|
||||||
|
image: ghcr.io/open-webui/open-webui:main # Образ Open Web UI
|
||||||
|
container_name: ollama-webui
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- ./ollama/ollama-webui:/app/backend/data
|
||||||
|
ports:
|
||||||
|
- 8080:8080 # Порт для веб-интерфейса
|
||||||
|
environment: # https://docs.openwebui.com/getting-started/env-configuration#default_models
|
||||||
|
- OLLAMA_BASE_URLS=http://host.docker.internal:7869
|
||||||
|
- ENV=dev
|
||||||
|
- WEBUI_AUTH=False
|
||||||
|
- WEBUI_NAME=Viltskaa AI
|
||||||
|
- WEBUI_URL=http://localhost:8080
|
||||||
|
- WEBUI_SECRET_KEY=t0p-s3cr3t
|
||||||
|
depends_on:
|
||||||
|
- ollama
|
||||||
|
extra_hosts:
|
||||||
|
- host.docker.internal:host-gateway
|
||||||
|
networks:
|
||||||
|
- ollama-docker
|
||||||
|
|
||||||
|
networks:
|
||||||
|
ollama-docker:
|
||||||
|
external: false
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
ollama:
|
||||||
|
driver: local
|
||||||
|
data:
|
||||||
|
driver: local
|
||||||
14
bazunov_andrew_lab_2/FileCreator/Dockerfile
Normal file
14
bazunov_andrew_lab_2/FileCreator/Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Используем официальный образ Go в качестве базового
|
||||||
|
FROM golang:1.23
|
||||||
|
|
||||||
|
# Устанавливаем рабочую директорию
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Копируем файлы модуля
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Сборка модуля
|
||||||
|
RUN go build -o /bin/FileCreator
|
||||||
|
|
||||||
|
# Запуск модуля
|
||||||
|
CMD ["/bin/FileCreator"]
|
||||||
1
bazunov_andrew_lab_2/FileCreator/go.mod
Normal file
1
bazunov_andrew_lab_2/FileCreator/go.mod
Normal file
@@ -0,0 +1 @@
|
|||||||
|
module FileCreator
|
||||||
92
bazunov_andrew_lab_2/FileCreator/main.go
Normal file
92
bazunov_andrew_lab_2/FileCreator/main.go
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/md5"
|
||||||
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
)
|
||||||
|
|
||||||
|
const DIR = "/var/data"
|
||||||
|
|
||||||
|
func Exists(name string) (bool, error) {
|
||||||
|
_, err := os.Stat(name)
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
return err != nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateDirectory(dirs string) error {
|
||||||
|
if _, err := os.Stat(dirs); os.IsNotExist(err) {
|
||||||
|
err := os.MkdirAll(dirs, 0664)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateFileOrOpenIfExist(name string) (*os.File, error) {
|
||||||
|
err := CreateDirectory(filepath.Dir(name))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
exists, err := Exists(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if exists {
|
||||||
|
return os.OpenFile(name, os.O_WRONLY|os.O_CREATE, 0664)
|
||||||
|
}
|
||||||
|
return os.Create(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateFileAndWriteData(filename string) error {
|
||||||
|
file, err := CreateFileOrOpenIfExist(filename)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
lines := rand.Intn(1000) + 100
|
||||||
|
|
||||||
|
for i := 0; i < lines; i++ {
|
||||||
|
randomValueForLine := rand.Intn(1_000_000)
|
||||||
|
_, err = fmt.Fprintf(file, "%d\r\n", randomValueForLine)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = file.Close()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetMD5Hash(text string) string {
|
||||||
|
hash := md5.Sum([]byte(text))
|
||||||
|
return hex.EncodeToString(hash[:])
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
for i := 0; i < 10; i++ {
|
||||||
|
filename := fmt.Sprintf("%s/%s.txt", DIR, GetMD5Hash(fmt.Sprintf("%d", i)))
|
||||||
|
err := CreateFileAndWriteData(filename)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("Created file %s\n", filename)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err := CreateFileAndWriteData(DIR + "/data.txt")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("Created file %s\n", DIR+"/data.txt")
|
||||||
|
}
|
||||||
|
}
|
||||||
14
bazunov_andrew_lab_2/FirstService/Dockerfile
Normal file
14
bazunov_andrew_lab_2/FirstService/Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Используем официальный образ Go в качестве базового
|
||||||
|
FROM golang:1.23
|
||||||
|
|
||||||
|
# Устанавливаем рабочую директорию
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Копируем файлы модуля
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Сборка модуля
|
||||||
|
RUN go build -o /bin/FirstService
|
||||||
|
|
||||||
|
# Запуск модуля
|
||||||
|
CMD ["/bin/FirstService"]
|
||||||
1
bazunov_andrew_lab_2/FirstService/go.mod
Normal file
1
bazunov_andrew_lab_2/FirstService/go.mod
Normal file
@@ -0,0 +1 @@
|
|||||||
|
module RVIP2
|
||||||
94
bazunov_andrew_lab_2/FirstService/main.go
Normal file
94
bazunov_andrew_lab_2/FirstService/main.go
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Формирует файл /var/result/data.txt так,
|
||||||
|
// что каждая строка файла - количество символов в именах файлов из каталога /var/data.
|
||||||
|
|
||||||
|
const INPUT = "/var/data"
|
||||||
|
const OUTPUT = "/data/result"
|
||||||
|
|
||||||
|
func GetListFilesInDirectory(directory string) ([]string, error) {
|
||||||
|
f, err := os.Open(directory)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
files, err := f.Readdir(0)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var fileNames []string
|
||||||
|
for _, file := range files {
|
||||||
|
fileName := file.Name()
|
||||||
|
fileNames = append(fileNames, fileName)
|
||||||
|
}
|
||||||
|
return fileNames, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Exists(name string) (bool, error) {
|
||||||
|
_, err := os.Stat(name)
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
return err != nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateFileOrOpenIfExist(name string) (*os.File, error) {
|
||||||
|
exists, err := Exists(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if exists {
|
||||||
|
return os.OpenFile(name, os.O_WRONLY|os.O_CREATE, 0664)
|
||||||
|
}
|
||||||
|
return os.Create(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateFileAndWriteData(filename string, lines []string) error {
|
||||||
|
file, err := CreateFileOrOpenIfExist(filename)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, line := range lines {
|
||||||
|
_, err = fmt.Fprintf(file, line)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = file.Close()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
filenames, err := GetListFilesInDirectory(INPUT)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var lenghtOfFilenames []string
|
||||||
|
for _, filename := range filenames {
|
||||||
|
fmt.Println(filename)
|
||||||
|
lenghtOfFilenames = append(lenghtOfFilenames, fmt.Sprintf("%d", len(filename)))
|
||||||
|
}
|
||||||
|
|
||||||
|
err = CreateFileAndWriteData(OUTPUT+"/data.txt", filenames)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("First Service is end.")
|
||||||
|
}
|
||||||
30
bazunov_andrew_lab_2/README.md
Normal file
30
bazunov_andrew_lab_2/README.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Распределенные вычисления и приложения Л2
|
||||||
|
## _Автор Базунов Андрей Игревич ПИбд-42_
|
||||||
|
|
||||||
|
Сервисы ( _порядок исполнения сервисов соблюден_ ):
|
||||||
|
- 1.FileCreator - (_Создание тестовых данных_)
|
||||||
|
- 2.FirstService - (_Выполнение 1.4 варианта задания_)
|
||||||
|
- 3.SecondService - (_Выполнение 2.2 варианта задания_)
|
||||||
|
|
||||||
|
В качестве основного языка был выбран GoLang. Для каждого сервиса был создан DOCKERFILE где были прописаны условия и действия для сборки каждого из модулей
|
||||||
|
|
||||||
|
# Docker
|
||||||
|
|
||||||
|
>Перед исполнением вполняем установку docker и проверяем версию
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker-compose --version
|
||||||
|
```
|
||||||
|
|
||||||
|
>Далее производим настройку файла docker-compose.yaml и запускаем контейнер с сборкой образов
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker-compose up -d --build
|
||||||
|
```
|
||||||
|
|
||||||
|
>Для завершения работы контейнера используем команду
|
||||||
|
```sh
|
||||||
|
docker-compose down
|
||||||
|
```
|
||||||
|
|
||||||
|
[Демонстрация работы](https://vk.com/video236673313_456239575)
|
||||||
14
bazunov_andrew_lab_2/SecondService/Dockerfile
Normal file
14
bazunov_andrew_lab_2/SecondService/Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Используем официальный образ Go в качестве базового
|
||||||
|
FROM golang:1.23
|
||||||
|
|
||||||
|
# Устанавливаем рабочую директорию
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Копируем файлы модуля
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Сборка модуля
|
||||||
|
RUN go build -o /bin/SecondService
|
||||||
|
|
||||||
|
# Запуск модуля
|
||||||
|
CMD ["/bin/SecondService"]
|
||||||
1
bazunov_andrew_lab_2/SecondService/go.mod
Normal file
1
bazunov_andrew_lab_2/SecondService/go.mod
Normal file
@@ -0,0 +1 @@
|
|||||||
|
module SecondService
|
||||||
79
bazunov_andrew_lab_2/SecondService/main.go
Normal file
79
bazunov_andrew_lab_2/SecondService/main.go
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
//Ищет наименьшее число из файла /var/data/data.txt и сохраняет его третью степень в /var/result/result.txt.
|
||||||
|
|
||||||
|
const INPUT = "/var/data/data.txt"
|
||||||
|
const OUTPUT = "/var/result/result.txt"
|
||||||
|
|
||||||
|
func ReadlinesFromFile(filename string) ([]string, error) {
|
||||||
|
file, err := os.Open(filename)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var output []string
|
||||||
|
scanner := bufio.NewScanner(file)
|
||||||
|
for scanner.Scan() {
|
||||||
|
output = append(output, scanner.Text())
|
||||||
|
}
|
||||||
|
|
||||||
|
err = file.Close()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return output, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func WriteIntToFile(filename string, i int) error {
|
||||||
|
file, err := os.Create(filename)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer func(file *os.File) {
|
||||||
|
err := file.Close()
|
||||||
|
if err != nil {
|
||||||
|
|
||||||
|
}
|
||||||
|
}(file)
|
||||||
|
|
||||||
|
_, err = file.WriteString(fmt.Sprintf("%d\n", i))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
lines, err := ReadlinesFromFile(INPUT)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
minValue := 0
|
||||||
|
|
||||||
|
for _, line := range lines {
|
||||||
|
if intValue, err := fmt.Sscanf(line, "%d", &minValue); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
} else {
|
||||||
|
if minValue >= intValue {
|
||||||
|
minValue = intValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = WriteIntToFile(OUTPUT, minValue); err != nil {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
fmt.Printf("Write %d to %s\n", minValue, OUTPUT)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("Second Service is end.")
|
||||||
|
}
|
||||||
27
bazunov_andrew_lab_2/docker-compose.yaml
Normal file
27
bazunov_andrew_lab_2/docker-compose.yaml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
services:
|
||||||
|
file_generate:
|
||||||
|
build:
|
||||||
|
context: ./FileCreator
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
volumes:
|
||||||
|
- ./data:/var/data # Монтирование локальной папки data в /var/data в контейнере
|
||||||
|
|
||||||
|
first_service:
|
||||||
|
build:
|
||||||
|
context: ./FirstService
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
volumes:
|
||||||
|
- ./data:/var/data
|
||||||
|
- ./data:/var/result
|
||||||
|
depends_on:
|
||||||
|
- file_generate
|
||||||
|
|
||||||
|
second_service:
|
||||||
|
build:
|
||||||
|
context: ./SecondService
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
volumes:
|
||||||
|
- ./data:/var/data
|
||||||
|
- ./data:/var/result
|
||||||
|
depends_on:
|
||||||
|
- first_service
|
||||||
38
borschevskaya_anna_lab_2/.gitignore
vendored
Normal file
38
borschevskaya_anna_lab_2/.gitignore
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
||||||
43
borschevskaya_anna_lab_2/README.md
Normal file
43
borschevskaya_anna_lab_2/README.md
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# Отчет. Лабораторная работа 2
|
||||||
|
|
||||||
|
В рамках лабораторной работы №2 были написаны два сервиса, работающих с текстовыми файлами.
|
||||||
|
Для первого сервиса был выбран вариант задания №5:
|
||||||
|
```
|
||||||
|
Ищет в каталоге /var/data файл с самым коротким названием и перекладывает его в /var/result/data.txt.
|
||||||
|
```
|
||||||
|
А для второго - №2:
|
||||||
|
```
|
||||||
|
Ищет наименьшее число из файла /var/data/data.txt и сохраняет его третью степень в /var/result/result.txt.
|
||||||
|
```
|
||||||
|
## Описание
|
||||||
|
Сначала сервис first перемещает данные из файла с самым коротким названием, находящегося в указанной примонтированной директории, в выходную папку.
|
||||||
|
Доступ к выходной папке имеет второй сервис, который выводит наименьшее число из помещенного первым сервисом файла
|
||||||
|
в третьей степени в выходной файл.
|
||||||
|
Выходной файл расположен в примонтированной директории и доступен на машине, где запускаются сервисы.
|
||||||
|
|
||||||
|
В Dockerfile используется многоэтапная сборка с использованием нескольких базовых образов на каждом этапе.
|
||||||
|
Описание значения каждой строки есть в Dockerfile в сервисе first.
|
||||||
|
|
||||||
|
В файле docker-compose.yml приведено описание новых строк, связанных с подключением примонтированных томов.
|
||||||
|
Стоит отметить, что для "общения" сервисов используется общий том common, который монтируется в контейнер по пути /var/result. Это позволяет сохранять результаты
|
||||||
|
работы первого сервиса для использования вторым сервисом.
|
||||||
|
## Как запустить
|
||||||
|
Для того, чтобы запустить сервисы, необходимо выполнить следующие действия:
|
||||||
|
1. Установить и запустить Docker Engine или Docker Desktop
|
||||||
|
2. Через консоль перейти в папку, в которой расположен файл docker-compose.yml
|
||||||
|
3. Выполнить команду:
|
||||||
|
```
|
||||||
|
docker compose up --build
|
||||||
|
```
|
||||||
|
В случае успешного запуска всех контейнеров в консоли будет выведено следующее сообщение:
|
||||||
|
```
|
||||||
|
✔ Network borschevskaya_anna_lab_2_default Created 0.1s
|
||||||
|
✔ Container borschevskaya_anna_lab_2-first-1 Created 0.1s
|
||||||
|
✔ Container borschevskaya_anna_lab_2-second-1 Created 0.1s
|
||||||
|
Attaching to borschevskaya_anna_lab_2-first-1, borschevskaya_anna_lab_2-second-1
|
||||||
|
```
|
||||||
|
Далее, в консоль каждого сервиса будут выведены сообщения о том, как прошла обработка файлов.
|
||||||
|
В случае отсутствия заданных значений переменных окружения INPUT_PATH и OUTPUT_PATH и
|
||||||
|
в иных исключительных ситуация будет выведена информация об этом.
|
||||||
|
## Видео-отчет
|
||||||
|
Работоспособность лабораторной работы можно оценить в следующем [видео](https://disk.yandex.ru/i/LFxdyRUFQDwXEQ).
|
||||||
22
borschevskaya_anna_lab_2/docker-compose.yml
Normal file
22
borschevskaya_anna_lab_2/docker-compose.yml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
services:
|
||||||
|
first:
|
||||||
|
build: ./first # директория, в которой нужно искать Dockerfile для сборки первого сервиса
|
||||||
|
environment:
|
||||||
|
INPUT_PATH: /var/data/ # директория с входными данными для обработки файлов
|
||||||
|
OUTPUT_PATH: /var/result/ # директория с выходными данными обработки
|
||||||
|
volumes:
|
||||||
|
- ./volumes/input:/var/data # монтируется локальная папка с входными данными в папку внутри контейнера
|
||||||
|
- common:/var/result # монтируется общий для двух сервисов том, в который first сложит результаты обработки по варианту
|
||||||
|
second:
|
||||||
|
build: ./second # директория, в которой нужно искать Dockerfile для сборки второго сервиса
|
||||||
|
depends_on: # сервис second зависит от сервиса first и будет запущен после него
|
||||||
|
- first
|
||||||
|
environment:
|
||||||
|
INPUT_PATH: /var/result/
|
||||||
|
OUTPUT_PATH: /var/data/
|
||||||
|
volumes:
|
||||||
|
- ./volumes/output:/var/data
|
||||||
|
- common:/var/result # монтируется общий для двух сервисов том, из которого second получит результаты обработки first сервиса и выполнит свою логику
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
common:
|
||||||
25
borschevskaya_anna_lab_2/first/Dockerfile
Normal file
25
borschevskaya_anna_lab_2/first/Dockerfile
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Используем образ Maven для сборки
|
||||||
|
FROM maven:3.8-eclipse-temurin-21-alpine AS build
|
||||||
|
|
||||||
|
# Устанавливаем рабочую директорию
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Копируем только pom.xml и загружаем зависимости
|
||||||
|
# Так зависимости закэшируются в Docker при изменении кода закэшированные слои с зависимостями будут подгружаться быстрее
|
||||||
|
COPY pom.xml .
|
||||||
|
RUN mvn dependency:go-offline
|
||||||
|
|
||||||
|
# Копируем остальные исходные файлы
|
||||||
|
COPY src ./src
|
||||||
|
|
||||||
|
# Собираем весь проект
|
||||||
|
RUN mvn clean package -DskipTests
|
||||||
|
|
||||||
|
# Используем официальный образ JDK для запуска собранного jar-файла
|
||||||
|
FROM eclipse-temurin:21-jdk-alpine
|
||||||
|
|
||||||
|
# Копируем jar-файл из предыдущего этапа
|
||||||
|
COPY --from=build /app/target/*.jar /app.jar
|
||||||
|
|
||||||
|
# Указываем команду для запуска приложения
|
||||||
|
CMD ["java", "-jar", "app.jar"]
|
||||||
37
borschevskaya_anna_lab_2/first/pom.xml
Normal file
37
borschevskaya_anna_lab_2/first/pom.xml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>ru.first</groupId>
|
||||||
|
<artifactId>first</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
|
<maven.compiler.target>21</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<!-- Build an executable JAR -->
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<addClasspath>true</addClasspath>
|
||||||
|
<classpathPrefix>lib/</classpathPrefix>
|
||||||
|
<mainClass>ru.first.Main</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package ru.first;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
||||||
|
import static java.util.Objects.isNull;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
public static final String INPUT_PATH = System.getenv("INPUT_PATH");
|
||||||
|
public static final String OUTPUT_PATH = System.getenv("OUTPUT_PATH");
|
||||||
|
public static final String RESULT_FILE_NAME = "data.txt";
|
||||||
|
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
if (isNull(INPUT_PATH) || INPUT_PATH.isEmpty() || isNull(OUTPUT_PATH) || OUTPUT_PATH.isEmpty()) {
|
||||||
|
System.out.printf("Отсутствуют переменные окружения INPUT_PATH = '%s' или OUTPUT_PATH = '%s'%n",
|
||||||
|
INPUT_PATH, OUTPUT_PATH);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var inputPathDir = Path.of(INPUT_PATH);
|
||||||
|
if (!Files.exists(inputPathDir)) {
|
||||||
|
Files.createDirectory(inputPathDir);
|
||||||
|
}
|
||||||
|
var inputDirectory = new File(INPUT_PATH);
|
||||||
|
var allDirFiles = inputDirectory.listFiles();
|
||||||
|
if (isNull(allDirFiles) || allDirFiles.length == 0) {
|
||||||
|
System.out.println("Директория пуста");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var dirFiles = Arrays.stream(allDirFiles).filter(File::isFile).toList();
|
||||||
|
if (dirFiles.isEmpty()) {
|
||||||
|
System.out.println("В указанной директории нет подходящих для обработки файлов");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var shortestName = dirFiles.stream().min(Comparator.comparing(file -> file.getName().length())).get();
|
||||||
|
|
||||||
|
var outputPathDir = Path.of(OUTPUT_PATH);
|
||||||
|
if (!Files.exists(outputPathDir)) {
|
||||||
|
Files.createDirectory(outputPathDir);
|
||||||
|
}
|
||||||
|
var resultFilePath = Path.of(OUTPUT_PATH + File.separator + RESULT_FILE_NAME);
|
||||||
|
Files.move(Path.of(INPUT_PATH + File.separator + shortestName.getName()), resultFilePath, REPLACE_EXISTING);
|
||||||
|
}
|
||||||
|
}
|
||||||
16
borschevskaya_anna_lab_2/second/Dockerfile
Normal file
16
borschevskaya_anna_lab_2/second/Dockerfile
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
FROM maven:3.8-eclipse-temurin-21-alpine AS build
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY pom.xml .
|
||||||
|
RUN mvn dependency:go-offline
|
||||||
|
|
||||||
|
COPY src ./src
|
||||||
|
|
||||||
|
RUN mvn clean package -DskipTests
|
||||||
|
|
||||||
|
FROM eclipse-temurin:21-jdk-alpine
|
||||||
|
|
||||||
|
COPY --from=build /app/target/*.jar /app.jar
|
||||||
|
|
||||||
|
CMD ["java", "-jar", "app.jar"]
|
||||||
36
borschevskaya_anna_lab_2/second/pom.xml
Normal file
36
borschevskaya_anna_lab_2/second/pom.xml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>ru.second</groupId>
|
||||||
|
<artifactId>second</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
|
<maven.compiler.target>21</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<addClasspath>true</addClasspath>
|
||||||
|
<classpathPrefix>lib/</classpathPrefix>
|
||||||
|
<mainClass>ru.second.Main</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package ru.second;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
|
||||||
|
import static java.util.Objects.isNull;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
public static final String INPUT_PATH = System.getenv("INPUT_PATH");
|
||||||
|
public static final String INPUT_FILE_NAME = "data.txt";
|
||||||
|
|
||||||
|
public static final String OUTPUT_PATH = System.getenv("OUTPUT_PATH");
|
||||||
|
public static final String RESULT_FILE_NAME = "result.txt";
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
if (isNull(INPUT_PATH) || INPUT_PATH.isEmpty() || isNull(OUTPUT_PATH) || OUTPUT_PATH.isEmpty()) {
|
||||||
|
System.out.printf("Отсутствуют переменные окружения INPUT_PATH = '%s' или OUTPUT_PATH = '%s'%n",
|
||||||
|
INPUT_PATH, OUTPUT_PATH);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var inputFile = new File(INPUT_PATH + File.separator + INPUT_FILE_NAME);
|
||||||
|
if (!inputFile.exists()) {
|
||||||
|
System.out.println("Входной файл не существует");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try (var stream = Files.lines(inputFile.toPath());
|
||||||
|
var writer = new FileWriter(OUTPUT_PATH + File.separator + RESULT_FILE_NAME);
|
||||||
|
) {
|
||||||
|
var min = stream.map(Main::parseInt).reduce(Integer::min);
|
||||||
|
if (min.isEmpty()) {
|
||||||
|
System.out.println("Не найдено минимальное значение среди строк файла");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var minValue = Math.pow(min.get(), 3);
|
||||||
|
System.out.printf("Get min value = '%d'%n", min.get());
|
||||||
|
writer.append(Double.toString(minValue));
|
||||||
|
System.out.printf("To file %s was written value %f%n", RESULT_FILE_NAME, minValue);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
System.out.println(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Integer parseInt(String line) {
|
||||||
|
line = line.replace("\\n", "");
|
||||||
|
return Integer.parseInt(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
4
dolgov_dmitriy_lab_1/.gitignore
vendored
Normal file
4
dolgov_dmitriy_lab_1/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
data/
|
||||||
|
log/
|
||||||
|
wordpress/
|
||||||
|
custom/
|
||||||
34
dolgov_dmitriy_lab_1/README.md
Normal file
34
dolgov_dmitriy_lab_1/README.md
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# Лабораторная работа №1
|
||||||
|
|
||||||
|
## Выполнил: Долгов Дмитрий, группа ПИбд-42
|
||||||
|
|
||||||
|
### Были развёрнуты следующие сервисы:
|
||||||
|
|
||||||
|
* mediawiki (движок вики)
|
||||||
|
* wordpress (популярная система управления контентом)
|
||||||
|
* gitea (сервис для хранения репозиториев git)
|
||||||
|
* mariaDB
|
||||||
|
### Были использованы следующие технологии:
|
||||||
|
|
||||||
|
* git
|
||||||
|
* docker
|
||||||
|
* docker-compose
|
||||||
|
|
||||||
|
|
||||||
|
### Для запуска лабораторной работы необходимо ввести в консоль следующую команду:
|
||||||
|
```
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
## Результат запуска:
|
||||||
|
```
|
||||||
|
[+] Running 4/4
|
||||||
|
✔ Container dolgov_dmitriy_lab_1-wordpress-1 Running 0.0s
|
||||||
|
✔ Container dolgov_dmitriy_lab_1-database-1 Running 0.0s
|
||||||
|
✔ Container dolgov_dmitriy_lab_1-mediawiki-1 Running 0.0s
|
||||||
|
✔ Container gitea Running
|
||||||
|
```
|
||||||
|
|
||||||
|
## Видео с результатом запуска:
|
||||||
|
|
||||||
|
Видео можно посмотреть по данной [ссылке](https://drive.google.com/file/d/1hC6HhNvYBRuYVClobXyDMReA4ngwxhwc/view?usp=drive_link).
|
||||||
73
dolgov_dmitriy_lab_1/docker-compose.yml
Normal file
73
dolgov_dmitriy_lab_1/docker-compose.yml
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
# Сервисы по заданию
|
||||||
|
services:
|
||||||
|
# Сервис MediaWiki
|
||||||
|
mediawiki:
|
||||||
|
# Образ MediaWiki
|
||||||
|
image: mediawiki
|
||||||
|
# Автоматический перезапуск при сбое
|
||||||
|
restart: always
|
||||||
|
# проброс порта 80 из контейнера на порт 8080 хоста
|
||||||
|
ports:
|
||||||
|
- "8080:80"
|
||||||
|
# связь с сервисом database
|
||||||
|
links:
|
||||||
|
- database
|
||||||
|
# монтирование volume для хранения данных
|
||||||
|
volumes:
|
||||||
|
- images:/var/www/html/images
|
||||||
|
|
||||||
|
# Сервис WordPress
|
||||||
|
wordpress:
|
||||||
|
# Образ WordPress
|
||||||
|
image: wordpress:latest
|
||||||
|
# Автоматический перезапуск при сбое
|
||||||
|
ports:
|
||||||
|
- "8082:80"
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- ./wordpress:/var/www/html
|
||||||
|
|
||||||
|
# Сервис Gitea
|
||||||
|
server:
|
||||||
|
image: gitea/gitea:latest
|
||||||
|
container_name: gitea
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
- USER_UID=1000
|
||||||
|
- USER_GID=1000
|
||||||
|
volumes:
|
||||||
|
- ./data:/data
|
||||||
|
- ./custom:/app/gitea/custom
|
||||||
|
- ./log:/app/gitea/log
|
||||||
|
ports:
|
||||||
|
- "8081:3000"
|
||||||
|
links:
|
||||||
|
- database
|
||||||
|
depends_on:
|
||||||
|
- database
|
||||||
|
|
||||||
|
# Сервис MariaDB
|
||||||
|
database:
|
||||||
|
# Образ MariaDB
|
||||||
|
image: mariadb
|
||||||
|
# Автоматический перезапуск при сбое
|
||||||
|
restart: always
|
||||||
|
# переменные окружения для настройки базы данных
|
||||||
|
environment:
|
||||||
|
# имя базы данных
|
||||||
|
MYSQL_DATABASE: my_wiki
|
||||||
|
# имя пользователя
|
||||||
|
MYSQL_USER: user
|
||||||
|
# пароль пользователя
|
||||||
|
MYSQL_PASSWORD: user
|
||||||
|
# случайный пароль для пользователя root
|
||||||
|
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
|
||||||
|
# монтирование volume для хранения данных
|
||||||
|
volumes:
|
||||||
|
- db:/var/lib/mysql
|
||||||
|
|
||||||
|
# тома для хранения данных
|
||||||
|
volumes:
|
||||||
|
images:
|
||||||
|
db:
|
||||||
|
|
||||||
BIN
dolgov_dmitriy_lab_1/screenshots/image.png
Normal file
BIN
dolgov_dmitriy_lab_1/screenshots/image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 275 KiB |
23
emelyanov_artem_lab_2/README.md
Normal file
23
emelyanov_artem_lab_2/README.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Распределённое приложение для поиска файлов и обработки чисел
|
||||||
|
## Описаниe
|
||||||
|
Данное распределённое приложение состоит из двух консольных Java-приложений, которые работают в контейнерах Docker. Приложения выполняют следующие задачи:
|
||||||
|
|
||||||
|
### file-finder:
|
||||||
|
Ищет самый большой файл в директории /var/data и копирует его в /var/result/data.txt.
|
||||||
|
### number-processor:
|
||||||
|
Считывает числа из файла /var/result/data.txt и сохраняет произведение первого и последнего числа в файл /var/result/result.txt.
|
||||||
|
|
||||||
|
#### Приложения работают совместно через Docker Compose, используя общий том для передачи файлов между контейнерами.
|
||||||
|
|
||||||
|
### Как запустить
|
||||||
|
1. #### Подготовка данных
|
||||||
|
Убедитесь, что в директории data находятся файлы, которые вы хотите обработать. Это могут быть текстовые файлы с числами.
|
||||||
|
|
||||||
|
2. #### Сборка и запуск контейнеров
|
||||||
|
Выполните команду для сборки и запуска контейнеров с помощью Docker Compose: docker-compose up --build
|
||||||
|
|
||||||
|
3. #### Результаты выполнения
|
||||||
|
#### Приложение file-finder находит самый большой файл в директории /var/data (локально это монтируемая директория data/) и копирует его в файл /var/result/data.txt.
|
||||||
|
#### Приложение number-processor читает файл /var/result/data.txt и сохраняет произведение первого и последнего числа в файл /var/result/result.txt.
|
||||||
|
|
||||||
|
#### Ссылка на видео https://drive.google.com/file/d/1u7nwZdUI4KHC4NzUAXdOABflYswokGwx/view
|
||||||
31
emelyanov_artem_lab_2/app_1/.gitignore
vendored
Normal file
31
emelyanov_artem_lab_2/app_1/.gitignore
vendored
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
### IntelliJ IDEA ###
|
||||||
|
out/
|
||||||
|
!**/src/main/**/out/
|
||||||
|
!**/src/test/**/out/
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
bin/
|
||||||
|
!**/src/main/**/bin/
|
||||||
|
!**/src/test/**/bin/
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
||||||
|
/.idea/modules.xml
|
||||||
|
/.idea/vcs.xml
|
||||||
8
emelyanov_artem_lab_2/app_1/.idea/.gitignore
generated
vendored
Normal file
8
emelyanov_artem_lab_2/app_1/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
17
emelyanov_artem_lab_2/app_1/Dockerfile
Normal file
17
emelyanov_artem_lab_2/app_1/Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Используем базовый образ с установленной JDK
|
||||||
|
FROM openjdk:17-jdk-slim
|
||||||
|
|
||||||
|
# Создаем директорию для исходных файлов
|
||||||
|
RUN mkdir /var/data
|
||||||
|
|
||||||
|
# Создаем директорию для приложения
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
#Копируем исходные файлы приложения внутрь контейнера
|
||||||
|
COPY src /app/src
|
||||||
|
|
||||||
|
#Компилируем код
|
||||||
|
RUN javac /app/src/Main.java
|
||||||
|
|
||||||
|
# Определяем команду для запуска приложения
|
||||||
|
CMD ["java", "-cp", "/app/src", "Main"]
|
||||||
64
emelyanov_artem_lab_2/app_1/src/Main.java
Normal file
64
emelyanov_artem_lab_2/app_1/src/Main.java
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
Ищет в каталоге /var/data самый большой по объёму файл и перекладывает его в /var/result/data.txt.
|
||||||
|
*/
|
||||||
|
|
||||||
|
File sourceDir = new File("/var/data");
|
||||||
|
File targetFile = new File("/var/result/data.txt");
|
||||||
|
|
||||||
|
// Проверяем, что sourceDir существует и является директорией
|
||||||
|
if (!sourceDir.exists() || !sourceDir.isDirectory()) {
|
||||||
|
System.out.println("Каталог " + sourceDir + " не существует или не является директорией.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
File[] files = sourceDir.listFiles();
|
||||||
|
if (files == null || files.length == 0) {
|
||||||
|
System.out.println("Каталог " + sourceDir + " пуст.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
long maxFileSize = -1L;
|
||||||
|
File maxFile = null;
|
||||||
|
|
||||||
|
// Находим файл с максимальным размером
|
||||||
|
for (File item : files) {
|
||||||
|
if (item.isFile() && item.length() > maxFileSize) {
|
||||||
|
maxFileSize = item.length();
|
||||||
|
maxFile = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxFile != null) {
|
||||||
|
// Проверяем, существует ли конечная директория, если нет — создаем её
|
||||||
|
File targetDir = targetFile.getParentFile();
|
||||||
|
if (!targetDir.exists()) {
|
||||||
|
boolean dirCreated = targetDir.mkdirs();
|
||||||
|
if (dirCreated) {
|
||||||
|
System.out.println("Директория " + targetDir + " была успешно создана.");
|
||||||
|
} else {
|
||||||
|
System.out.println("Не удалось создать директорию " + targetDir);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Копируем файл
|
||||||
|
Files.copy(maxFile.toPath(), targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
System.out.println("Самый большой файл: " + maxFile.getName() + " был скопирован в /var/result/data.txt");
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Ошибка копирования файла: " + e.getMessage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("Файлы для копирования не найдены.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
30
emelyanov_artem_lab_2/app_2/.gitignore
vendored
Normal file
30
emelyanov_artem_lab_2/app_2/.gitignore
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
### IntelliJ IDEA ###
|
||||||
|
out/
|
||||||
|
!**/src/main/**/out/
|
||||||
|
!**/src/test/**/out/
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
bin/
|
||||||
|
!**/src/main/**/bin/
|
||||||
|
!**/src/test/**/bin/
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
||||||
|
/.idea/misc.xml
|
||||||
10
emelyanov_artem_lab_2/app_2/.idea/.gitignore
generated
vendored
Normal file
10
emelyanov_artem_lab_2/app_2/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
|
/modules.xml
|
||||||
|
/vcs.xml
|
||||||
17
emelyanov_artem_lab_2/app_2/Dockerfile
Normal file
17
emelyanov_artem_lab_2/app_2/Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Используем базовый образ с установленной JDK
|
||||||
|
FROM openjdk:17-jdk-slim
|
||||||
|
|
||||||
|
# Создаем директорию для исходных файлов
|
||||||
|
RUN mkdir /var/data
|
||||||
|
|
||||||
|
# Создаем директорию для приложения
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
#Копируем исходные файлы приложения внутрь контейнера
|
||||||
|
COPY src /app/src
|
||||||
|
|
||||||
|
#Компилируем код
|
||||||
|
RUN javac /app/src/Main.java
|
||||||
|
|
||||||
|
# Определяем команду для запуска приложения
|
||||||
|
CMD ["java", "-cp", "/app/src", "Main"]
|
||||||
46
emelyanov_artem_lab_2/app_2/src/Main.java
Normal file
46
emelyanov_artem_lab_2/app_2/src/Main.java
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
// Сохраняет произведение первого и последнего числа из файла /var/result/data.txt в /var/result/result.txt.
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
File sourceFile = new File("/var/result/data.txt");
|
||||||
|
File targetFile = new File("/var/result/result.txt");
|
||||||
|
|
||||||
|
int firstNumber = 0;
|
||||||
|
int lastNumber = 0;
|
||||||
|
boolean isFirstNumber = true;
|
||||||
|
|
||||||
|
try (Scanner scanner = new Scanner(sourceFile)) {
|
||||||
|
// Считываем числа
|
||||||
|
while (scanner.hasNextInt()) {
|
||||||
|
int currentNumber = scanner.nextInt();
|
||||||
|
|
||||||
|
if (isFirstNumber) {
|
||||||
|
firstNumber = currentNumber; // Сохраняем первое число
|
||||||
|
isFirstNumber = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastNumber = currentNumber; // Последнее число обновляется на каждом шаге
|
||||||
|
}
|
||||||
|
} catch (FileNotFoundException ex) {
|
||||||
|
System.out.println("Файл не найден: " + ex.getMessage());
|
||||||
|
return; // Выходим, если файл не найден
|
||||||
|
}
|
||||||
|
|
||||||
|
// Рассчитываем произведение первого и последнего числа
|
||||||
|
int result = firstNumber * lastNumber;
|
||||||
|
|
||||||
|
// Сохраняем результат в файл
|
||||||
|
try (PrintWriter writer = new PrintWriter(targetFile)) {
|
||||||
|
writer.println(result);
|
||||||
|
System.out.println("Произведение первого и последнего числа: " + result);
|
||||||
|
} catch (FileNotFoundException ex) {
|
||||||
|
System.out.println("Ошибка записи в файл: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
emelyanov_artem_lab_2/data/1.txt
Normal file
10
emelyanov_artem_lab_2/data/1.txt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
2
|
||||||
|
32
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
54
|
||||||
|
64
|
||||||
|
4
|
||||||
|
3
|
||||||
|
3
|
||||||
12
emelyanov_artem_lab_2/data/2.txt
Normal file
12
emelyanov_artem_lab_2/data/2.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
12
|
||||||
|
4
|
||||||
|
12
|
||||||
|
3
|
||||||
|
21
|
||||||
|
3
|
||||||
|
12
|
||||||
|
1
|
||||||
|
3
|
||||||
|
32
|
||||||
|
2
|
||||||
|
5
|
||||||
9
emelyanov_artem_lab_2/data/3.txt
Normal file
9
emelyanov_artem_lab_2/data/3.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
12
|
||||||
|
2
|
||||||
|
1
|
||||||
|
2
|
||||||
|
4
|
||||||
|
3
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
21
emelyanov_artem_lab_2/docker-compose.yml
Normal file
21
emelyanov_artem_lab_2/docker-compose.yml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
file-finder:
|
||||||
|
build:
|
||||||
|
context: ./app_1 # Путь к первому приложению
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
volumes:
|
||||||
|
- C:/Users/Admin/Desktop/УлГТУ/Распределенные вычисления и приложения/DAS_2024_1/emelyanov_artem_lab_2/data:/var/data # Монтируем директорию с файлами
|
||||||
|
- shared-result:/var/result
|
||||||
|
|
||||||
|
number-processor:
|
||||||
|
build:
|
||||||
|
context: ./app_2 # Путь ко второму приложению
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
depends_on:
|
||||||
|
- file-finder
|
||||||
|
volumes:
|
||||||
|
- shared-result:/var/result
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
shared-result: # Объявляем общий том
|
||||||
93
kashin_maxim_lab_1/README.md
Normal file
93
kashin_maxim_lab_1/README.md
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
# Кашин Максим ПИбд-42
|
||||||
|
|
||||||
|
## Описание
|
||||||
|
|
||||||
|
Этот проект разворачивает среду с базой данных MySQL, системами управления проектами Redmine и платформой для создания сайтов WordPress с использованием Docker Compose. Ниже приведены шаги для запуска и настройки.
|
||||||
|
|
||||||
|
## 0. Предварительные действия
|
||||||
|
|
||||||
|
Перед запуском Docker Compose выполнил следующие шаги:
|
||||||
|
|
||||||
|
1. Установил [Docker Desktop](https://www.docker.com/products/docker-desktop) для моей операционной системы.
|
||||||
|
2. Настроил брандмауэр Windows и разрешил доступ Docker.
|
||||||
|
3. Открыл PowerShell с правами администратора и выполнил следующие команды:
|
||||||
|
```bash
|
||||||
|
net start vmcompute
|
||||||
|
wsl --set-default-version 2
|
||||||
|
```
|
||||||
|
|
||||||
|
## 1. Структура и запуск сервиса
|
||||||
|
|
||||||
|
Файл `docker-compose.yml` содержит описание трех сервисов:
|
||||||
|
- **db (MySQL)** – база данных;
|
||||||
|
- **redmine (Redmine)** – система управления проектами;
|
||||||
|
- **wordpress (WordPress)** – платформа для создания сайтов.
|
||||||
|
|
||||||
|
Запуск всех сервисов происходит через команду:
|
||||||
|
```bash
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
## 2. Сервис MySQL
|
||||||
|
|
||||||
|
Сервис `db` представляет собой контейнер с MySQL версии 8.0.
|
||||||
|
|
||||||
|
- **Образ**: `mysql:8.0`
|
||||||
|
- **Переменные окружения**:
|
||||||
|
- `MYSQL_ROOT_PASSWORD` — пароль для пользователя root.
|
||||||
|
- `MYSQL_DATABASE` — имя создаваемой базы данных (exampledb).
|
||||||
|
- `MYSQL_USER` — имя пользователя базы данных (exampleuser).
|
||||||
|
- `MYSQL_PASSWORD` — пароль пользователя базы данных (examplepass).
|
||||||
|
- **Тома (volumes)**:
|
||||||
|
- `db-data:/var/lib/mysql` — том для хранения данных базы данных.
|
||||||
|
|
||||||
|
Сервис MySQL необходим для работы как Redmine, так и WordPress.
|
||||||
|
|
||||||
|
## 3. Сервис Redmine
|
||||||
|
|
||||||
|
Сервис `redmine` представляет собой контейнер с системой управления проектами Redmine.
|
||||||
|
|
||||||
|
- **Образ**: `redmine`
|
||||||
|
- **Порты**:
|
||||||
|
- `8080:3000` — Redmine будет доступен по адресу http://localhost:8080.
|
||||||
|
- **Переменные окружения**:
|
||||||
|
- `REDMINE_DB_DATABASE` — имя базы данных (exampledb).
|
||||||
|
- `REDMINE_DB_MYSQL` — имя хоста базы данных (db).
|
||||||
|
- `REDMINE_DB_PASSWORD` — пароль для подключения к базе данных (example).
|
||||||
|
- `REDMINE_SECRET_KEY_BASE` — секретный ключ для работы с сессиями.
|
||||||
|
- **Тома (volumes)**:
|
||||||
|
- `redmine:/usr/src/redmine/files` — том для хранения файлов Redmine.
|
||||||
|
|
||||||
|
## 4. Сервис WordPress
|
||||||
|
|
||||||
|
Сервис `wordpress` представляет собой контейнер с платформой WordPress.
|
||||||
|
|
||||||
|
- **Образ**: `wordpress`
|
||||||
|
- **Порты**:
|
||||||
|
- `8081:80` — WordPress будет доступен по адресу http://localhost:8081.
|
||||||
|
- **Переменные окружения**:
|
||||||
|
- `WORDPRESS_DB_HOST` — хост базы данных (db).
|
||||||
|
- `WORDPRESS_DB_USER` — имя пользователя базы данных (exampleuser).
|
||||||
|
- `WORDPRESS_DB_PASSWORD` — пароль для подключения к базе данных (examplepass).
|
||||||
|
- `WORDPRESS_DB_NAME` — имя базы данных (exampledb).
|
||||||
|
- **Тома (volumes)**:
|
||||||
|
- `wordpress:/var/www/html` — том для хранения файлов WordPress.
|
||||||
|
|
||||||
|
## 5. Томa данных
|
||||||
|
|
||||||
|
Для хранения данных и постоянства контейнеров используются три тома:
|
||||||
|
|
||||||
|
- `wordpress` — для данных WordPress.
|
||||||
|
- `db-data` — для данных MySQL.
|
||||||
|
- `redmine` — для файлов Redmine.
|
||||||
|
|
||||||
|
## 6. Остановка сервисов
|
||||||
|
|
||||||
|
Для остановки и удаления всех контейнеров необходимо выполнить команду:
|
||||||
|
```bash
|
||||||
|
docker-compose down
|
||||||
|
```
|
||||||
|
|
||||||
|
## 7. Ссылка на видео
|
||||||
|
|
||||||
|
[Видео-отчёт Кашин Максим ПИбд-42](https://disk.yandex.ru/i/O8L1qmk4PIbCvA)
|
||||||
45
kashin_maxim_lab_1/docker-compose.yml
Normal file
45
kashin_maxim_lab_1/docker-compose.yml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
version: '3.1' # Версия Docker Compose файла
|
||||||
|
|
||||||
|
services: # Определение сервисов, которые будут запускаться
|
||||||
|
|
||||||
|
db: # Сервис базы данных MySQL
|
||||||
|
image: mysql:8.0 # Образ
|
||||||
|
restart: always # Автоматический перезапуск контейнера
|
||||||
|
environment: # Переменные окружения для конфигурации базы данных
|
||||||
|
MYSQL_ROOT_PASSWORD: example
|
||||||
|
MYSQL_DATABASE: exampledb
|
||||||
|
MYSQL_USER: exampleuser
|
||||||
|
MYSQL_PASSWORD: examplepass
|
||||||
|
volumes: # Определение томов для сохранения данных базы данных
|
||||||
|
- db-data:/var/lib/mysql
|
||||||
|
|
||||||
|
redmine: # redmine Система учёта багов, т.е. баг-трекер.
|
||||||
|
image: redmine # Образ
|
||||||
|
restart: always # Автоматический перезапуск контейнера
|
||||||
|
ports:
|
||||||
|
- 8080:3000 # Переадресация локального порта 8080 на порт 3000 в контейнере
|
||||||
|
environment: # Переменные окружения для настройки Redmine (подключение к бд)
|
||||||
|
REDMINE_DB_DATABASE: exampledb
|
||||||
|
REDMINE_DB_MYSQL: db
|
||||||
|
REDMINE_DB_PASSWORD: example
|
||||||
|
REDMINE_SECRET_KEY_BASE: supersecretkey
|
||||||
|
volumes: # Том для хранения данных Redmine
|
||||||
|
- redmine:/usr/src/redmine/files
|
||||||
|
|
||||||
|
wordpress: # wordpress Популярная система управления контентом.
|
||||||
|
image: wordpress # Образ
|
||||||
|
restart: always # Автоматический перезапуск контейнера
|
||||||
|
ports:
|
||||||
|
- 8081:80 # Переадресация локального порта 8081 на порт 80 в контейнере
|
||||||
|
environment: # Переменные окружения для настройки WordPress (подключение к бд)
|
||||||
|
WORDPRESS_DB_HOST: db
|
||||||
|
WORDPRESS_DB_USER: exampleuser
|
||||||
|
WORDPRESS_DB_PASSWORD: examplepass
|
||||||
|
WORDPRESS_DB_NAME: exampledb
|
||||||
|
volumes: # Том для хранения данных WordPress
|
||||||
|
- wordpress:/var/www/html
|
||||||
|
|
||||||
|
volumes: # Определение томов для хранения данных
|
||||||
|
wordpress:
|
||||||
|
db-data:
|
||||||
|
redmine:
|
||||||
30
kuzarin_maxim_lab_2/.dockerignore
Normal file
30
kuzarin_maxim_lab_2/.dockerignore
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
**/.classpath
|
||||||
|
**/.dockerignore
|
||||||
|
**/.env
|
||||||
|
**/.git
|
||||||
|
**/.gitignore
|
||||||
|
**/.project
|
||||||
|
**/.settings
|
||||||
|
**/.toolstarget
|
||||||
|
**/.vs
|
||||||
|
**/.vscode
|
||||||
|
**/*.*proj.user
|
||||||
|
**/*.dbmdl
|
||||||
|
**/*.jfm
|
||||||
|
**/azds.yaml
|
||||||
|
**/bin
|
||||||
|
**/charts
|
||||||
|
**/docker-compose*
|
||||||
|
**/Dockerfile*
|
||||||
|
**/node_modules
|
||||||
|
**/npm-debug.log
|
||||||
|
**/obj
|
||||||
|
**/secrets.dev.yaml
|
||||||
|
**/values.dev.yaml
|
||||||
|
LICENSE
|
||||||
|
README.md
|
||||||
|
!**/.gitignore
|
||||||
|
!.git/HEAD
|
||||||
|
!.git/config
|
||||||
|
!.git/packed-refs
|
||||||
|
!.git/refs/heads/**
|
||||||
490
kuzarin_maxim_lab_2/.gitignore
vendored
Normal file
490
kuzarin_maxim_lab_2/.gitignore
vendored
Normal file
@@ -0,0 +1,490 @@
|
|||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from `dotnet new gitignore`
|
||||||
|
|
||||||
|
# dotenv files
|
||||||
|
.env
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.rsuser
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
mono_crash.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
[Ww][Ii][Nn]32/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
[Ll]ogs/
|
||||||
|
|
||||||
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# Visual Studio 2017 auto generated files
|
||||||
|
Generated\ Files/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUnit
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
nunit-*.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
# Tye
|
||||||
|
.tye/
|
||||||
|
|
||||||
|
# ASP.NET Scaffolding
|
||||||
|
ScaffoldingReadMe.txt
|
||||||
|
|
||||||
|
# StyleCop
|
||||||
|
StyleCopReport.xml
|
||||||
|
|
||||||
|
# Files built by Visual Studio
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_h.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.iobj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.ipdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*_wpftmp.csproj
|
||||||
|
*.log
|
||||||
|
*.tlog
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
*.e2e
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Coverlet is a free, cross platform Code Coverage Tool
|
||||||
|
coverage*.json
|
||||||
|
coverage*.xml
|
||||||
|
coverage*.info
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
*.snupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/[Pp]ackages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/[Pp]ackages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/[Pp]ackages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
*.appxbundle
|
||||||
|
*.appxupload
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!?*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Including strong name files can present a security risk
|
||||||
|
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||||
|
#*.snk
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
ServiceFabricBackup/
|
||||||
|
*.rptproj.bak
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
*.rptproj.rsuser
|
||||||
|
*- [Bb]ackup.rdl
|
||||||
|
*- [Bb]ackup ([0-9]).rdl
|
||||||
|
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||||
|
*.vbp
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||||
|
*.dsw
|
||||||
|
*.dsp
|
||||||
|
|
||||||
|
# Visual Studio 6 technical files
|
||||||
|
*.ncb
|
||||||
|
*.aps
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# CodeRush personal settings
|
||||||
|
.cr/personal
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
|
|
||||||
|
# Azure Stream Analytics local run output
|
||||||
|
ASALocalRun/
|
||||||
|
|
||||||
|
# MSBuild Binary and Structured Log
|
||||||
|
*.binlog
|
||||||
|
|
||||||
|
# NVidia Nsight GPU debugger configuration file
|
||||||
|
*.nvuser
|
||||||
|
|
||||||
|
# MFractors (Xamarin productivity tool) working folder
|
||||||
|
.mfractor/
|
||||||
|
|
||||||
|
# Local History for Visual Studio
|
||||||
|
.localhistory/
|
||||||
|
|
||||||
|
# Visual Studio History (VSHistory) files
|
||||||
|
.vshistory/
|
||||||
|
|
||||||
|
# BeatPulse healthcheck temp database
|
||||||
|
healthchecksdb
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
MigrationBackup/
|
||||||
|
|
||||||
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
|
.ionide/
|
||||||
|
|
||||||
|
# Fody - auto-generated XML schema
|
||||||
|
FodyWeavers.xsd
|
||||||
|
|
||||||
|
# VS Code files for those working on multiple tools
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
.history/
|
||||||
|
|
||||||
|
# Windows Installer files from build outputs
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
*.sln.iml
|
||||||
|
.idea
|
||||||
|
|
||||||
|
##
|
||||||
|
## Visual studio for Mac
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
# globs
|
||||||
|
Makefile.in
|
||||||
|
*.userprefs
|
||||||
|
*.usertasks
|
||||||
|
config.make
|
||||||
|
config.status
|
||||||
|
aclocal.m4
|
||||||
|
install-sh
|
||||||
|
autom4te.cache/
|
||||||
|
*.tar.gz
|
||||||
|
tarballs/
|
||||||
|
test-results/
|
||||||
|
|
||||||
|
# Mac bundle stuff
|
||||||
|
*.dmg
|
||||||
|
*.app
|
||||||
|
|
||||||
|
# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
|
||||||
|
# Windows thumbnail cache files
|
||||||
|
Thumbs.db
|
||||||
|
ehthumbs.db
|
||||||
|
ehthumbs_vista.db
|
||||||
|
|
||||||
|
# Dump file
|
||||||
|
*.stackdump
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
[Dd]esktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Windows Installer files
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# Windows shortcuts
|
||||||
|
*.lnk
|
||||||
|
|
||||||
|
# Vim temporary swap files
|
||||||
|
*.swp
|
||||||
|
|
||||||
|
# Delete volumes
|
||||||
|
/volumes
|
||||||
|
|
||||||
|
# Delete .vs folder
|
||||||
|
/.vs/*
|
||||||
37
kuzarin_maxim_lab_2/DAaS_FileConnections.sln
Normal file
37
kuzarin_maxim_lab_2/DAaS_FileConnections.sln
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.10.34916.146
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DAaS_FileConnections", "DAaS_FileConnections\DAaS_FileConnections.csproj", "{23B07B06-0AB4-42F8-9753-264639E1D38B}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FirstApplication", "FirstApplication\FirstApplication.csproj", "{FBC01B2E-C887-42D1-A899-3C4781EF67E9}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecondApplication", "SecondApplication\SecondApplication.csproj", "{5888DB56-82F2-467D-8F6B-AB94CC4A33B5}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{23B07B06-0AB4-42F8-9753-264639E1D38B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{23B07B06-0AB4-42F8-9753-264639E1D38B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{23B07B06-0AB4-42F8-9753-264639E1D38B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{23B07B06-0AB4-42F8-9753-264639E1D38B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{FBC01B2E-C887-42D1-A899-3C4781EF67E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{FBC01B2E-C887-42D1-A899-3C4781EF67E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{FBC01B2E-C887-42D1-A899-3C4781EF67E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{FBC01B2E-C887-42D1-A899-3C4781EF67E9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{5888DB56-82F2-467D-8F6B-AB94CC4A33B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{5888DB56-82F2-467D-8F6B-AB94CC4A33B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5888DB56-82F2-467D-8F6B-AB94CC4A33B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{5888DB56-82F2-467D-8F6B-AB94CC4A33B5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {E290B7D1-0F4E-406E-ADF3-8F543C0FA96E}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="PIHelperSh.RandomEx" Version="1.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
29
kuzarin_maxim_lab_2/DAaS_FileConnections/Program.cs
Normal file
29
kuzarin_maxim_lab_2/DAaS_FileConnections/Program.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
using PIHelperSh.RandomEx.Extentions;
|
||||||
|
|
||||||
|
string inputPath = Environment.GetEnvironmentVariable("INPUT_PATH") ?? ".\\input1";
|
||||||
|
string outputPath = Environment.GetEnvironmentVariable("OUTPUT_PATH") ?? ".\\output1";
|
||||||
|
|
||||||
|
if(!Directory.Exists(inputPath))
|
||||||
|
Directory.CreateDirectory(inputPath);
|
||||||
|
|
||||||
|
if(!Directory.Exists(outputPath))
|
||||||
|
Directory.CreateDirectory(outputPath);
|
||||||
|
|
||||||
|
var rnd = new Random();
|
||||||
|
|
||||||
|
for (int i = 0; i < rnd.Next(1000); i++)
|
||||||
|
{
|
||||||
|
using var writer = new StreamWriter(Path.Combine(inputPath, $"{rnd.NextString(10)}.txt"), false);
|
||||||
|
|
||||||
|
for (int j = 0; j < rnd.Next(1000); j++)
|
||||||
|
|
||||||
|
{
|
||||||
|
writer.WriteLine(rnd.Next());
|
||||||
|
}
|
||||||
|
writer.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
35
kuzarin_maxim_lab_2/FirstApplication/Dockerfile
Normal file
35
kuzarin_maxim_lab_2/FirstApplication/Dockerfile
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# Это базовый образ для сборки.
|
||||||
|
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
|
||||||
|
# Указываем рабочий каталог для следующих комманд
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Проект нужно сначала собрать, поэтому берём sdk
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
|
# Это пременная. Будем собирать в режиме Relece.
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
WORKDIR /src
|
||||||
|
# Копируем из папки хоста в контейнер
|
||||||
|
COPY ["FirstApplication.csproj", "FirstApplication/"]
|
||||||
|
# Выполняем комманду для загрузки всех нужных зависимостей
|
||||||
|
RUN dotnet restore "FirstApplication/FirstApplication.csproj"
|
||||||
|
# Назначаем новую базовую папку
|
||||||
|
WORKDIR "/src/FirstApplication"
|
||||||
|
# Копируем всё в папку для сборки
|
||||||
|
COPY . .
|
||||||
|
# Выполняем сборку проекта
|
||||||
|
RUN dotnet build "FirstApplication.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||||
|
|
||||||
|
# В этот этап попадает всё, что было в publish
|
||||||
|
FROM build AS publish
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
# Публикуем всё в папку /app/publish
|
||||||
|
RUN dotnet publish "FirstApplication.csproj" -c $BUILD_CONFIGURATION -o /app/publish --self-contained false --no-restore
|
||||||
|
|
||||||
|
# Берём тот образ, что определили в первой строке
|
||||||
|
FROM base AS final
|
||||||
|
# Указываем рабочую директорию
|
||||||
|
WORKDIR /app
|
||||||
|
# Из опубликованного блока берём то, что опубликовано и закидывае в /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
# Указываем комманду запуска приложения (когда контейнер запустится, то начнёт с этого)
|
||||||
|
ENTRYPOINT ["dotnet", "FirstApplication.dll"]
|
||||||
15
kuzarin_maxim_lab_2/FirstApplication/FirstApplication.csproj
Normal file
15
kuzarin_maxim_lab_2/FirstApplication/FirstApplication.csproj
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
17
kuzarin_maxim_lab_2/FirstApplication/Program.cs
Normal file
17
kuzarin_maxim_lab_2/FirstApplication/Program.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
Console.WriteLine("Запущен первый сервис");
|
||||||
|
string inputPath = Environment.GetEnvironmentVariable("INPUT_PATH") ?? "./input1";
|
||||||
|
string outputPath = Environment.GetEnvironmentVariable("OUTPUT_PATH") ?? "./output1";
|
||||||
|
|
||||||
|
if (!Directory.Exists(inputPath))
|
||||||
|
Directory.CreateDirectory(inputPath);
|
||||||
|
|
||||||
|
if (!Directory.Exists(outputPath))
|
||||||
|
Directory.CreateDirectory(outputPath);
|
||||||
|
|
||||||
|
var file = new DirectoryInfo(inputPath).EnumerateFiles().Aggregate((x, y) => x.Length > y.Length ? x : y);
|
||||||
|
|
||||||
|
var outputFilePath = Path.Combine(outputPath, "data.txt");
|
||||||
|
|
||||||
|
if(File.Exists(outputFilePath))
|
||||||
|
File.Delete(outputFilePath);
|
||||||
|
File.Move(file.FullName, Path.Combine(outputPath, "data.txt"));
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"FirstApplication": {
|
||||||
|
"commandName": "Project"
|
||||||
|
},
|
||||||
|
"Container (Dockerfile)": {
|
||||||
|
"commandName": "Docker"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
kuzarin_maxim_lab_2/README.md
Normal file
25
kuzarin_maxim_lab_2/README.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Лабораторная работа 2
|
||||||
|
Данная работа посвящена теме создания контейнеров из исходного кода посредства dockerfile, а так же взаимодействию сервисов через общие папки
|
||||||
|
## Описание
|
||||||
|
Был варана следующая комбинация вариантов:
|
||||||
|
- Первое приложение - 0-ой
|
||||||
|
- Второе приложение - 1-ый
|
||||||
|
В результате, после запуска система изучит папку ./volumes/input, найдёт самый большой файл, а затем найдёт в нём самое большое число, выведя в директорию ./volumes/output файл с его квадратом.
|
||||||
|
Буфер же, по сути не имеет физического отображения на папку хоста.
|
||||||
|
## Запуск
|
||||||
|
Для запуска лабораторной работы необходимо иметь запущенный движок Docker на устройстве.
|
||||||
|
Необходимо перейти в папку, где располагается данный файл. Далее открыть терминал и ввести команду:
|
||||||
|
```
|
||||||
|
docker compose up --build
|
||||||
|
```
|
||||||
|
В данном случае флаг `--build` заставит систему в любом случае собрать образы из исходников (даже если они уже есть).
|
||||||
|
В результате, после сборки оба сервиса запустятся и выведут в консоль логи примерно следующего содержания:
|
||||||
|
## Описание dockerfile файла
|
||||||
|
Подробное описание дано в виде комментариев в самом файле первого сервиса. Так как для разработки использовался .net 8.0, команд довольно много. При этом, так как второй сервис написан на той же платформе, особенных отличий двух docekrfile-ов нет(кроме пути
|
||||||
|
## Описание compose файла
|
||||||
|
Благодаря директиве `depends_on` в compose файле второй сервис будет ждать, пока не будет поднят первый сервис, и только потом начнёт подниматься.
|
||||||
|
Директива `build` позволяет использовать в compose не уже готовый образ, а тот, что будет собран непосредственно в момент запуска(если он уже существует и нет флага силовой сборки, будет использоваться существующий образ)
|
||||||
|
Область volumes позволяет создать буферную область. Эту папку можно монтировать как результирующую для первого сервиса и исходную - для второго
|
||||||
|
## Видеодемонстрация
|
||||||
|
Был записан видеоролик, демонстрирующий процесс запуска и работы сервисов. Он расположен по [адресу](https://drive.google.com/file/d/1sACiKx3_HRApa89a7LZFAZV05o7POhq6/view?usp=sharing)
|
||||||
|
|
||||||
20
kuzarin_maxim_lab_2/SecondApplication/Dockerfile
Normal file
20
kuzarin_maxim_lab_2/SecondApplication/Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["SecondApplication.csproj", "SecondApplication/"]
|
||||||
|
RUN dotnet restore "./SecondApplication/SecondApplication.csproj"
|
||||||
|
WORKDIR "/src/SecondApplication"
|
||||||
|
COPY . .
|
||||||
|
RUN dotnet build "SecondApplication.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
RUN dotnet publish "SecondApplication.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "SecondApplication.dll"]
|
||||||
31
kuzarin_maxim_lab_2/SecondApplication/Program.cs
Normal file
31
kuzarin_maxim_lab_2/SecondApplication/Program.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
Console.WriteLine("Запущен второй сервис");
|
||||||
|
string inputPath = Environment.GetEnvironmentVariable("INPUT_PATH") ?? ".\\input2";
|
||||||
|
string outputPath = Environment.GetEnvironmentVariable("OUTPUT_PATH") ?? ".\\output2";
|
||||||
|
|
||||||
|
if (!Directory.Exists(outputPath))
|
||||||
|
Directory.CreateDirectory(outputPath);
|
||||||
|
|
||||||
|
var inputFilePath = Path.Combine(inputPath, "data.txt");
|
||||||
|
var outputFilePath = Path.Combine(outputPath, "result.txt");
|
||||||
|
|
||||||
|
if (!File.Exists(inputFilePath))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Нет исходного файла {inputFilePath}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var reader = new StreamReader(inputFilePath);
|
||||||
|
|
||||||
|
long maxNumber = 0;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
var str = reader.ReadLine();
|
||||||
|
if (str == null) break;
|
||||||
|
|
||||||
|
if (long.TryParse(str, out var number) && number > maxNumber)
|
||||||
|
maxNumber = number;
|
||||||
|
}
|
||||||
|
|
||||||
|
File.WriteAllText(outputFilePath, (maxNumber * maxNumber).ToString());
|
||||||
|
Console.WriteLine($"Результат выполнения: {maxNumber * maxNumber}");
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"SecondApplication": {
|
||||||
|
"commandName": "Project"
|
||||||
|
},
|
||||||
|
"Container (Dockerfile)": {
|
||||||
|
"commandName": "Docker"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
22
kuzarin_maxim_lab_2/docker-compose.yml
Normal file
22
kuzarin_maxim_lab_2/docker-compose.yml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
services:
|
||||||
|
first:
|
||||||
|
build: ./FirstApplication/
|
||||||
|
volumes:
|
||||||
|
- ./volumes/input:/var/data
|
||||||
|
- buffer:/var/result
|
||||||
|
environment:
|
||||||
|
INPUT_PATH: "/var/data"
|
||||||
|
OUTPUT_PATH: "/var/result"
|
||||||
|
|
||||||
|
second:
|
||||||
|
build: ./SecondApplication/
|
||||||
|
depends_on:
|
||||||
|
- first
|
||||||
|
volumes:
|
||||||
|
- buffer:/var/data
|
||||||
|
- ./volumes/output:/var/result
|
||||||
|
environment:
|
||||||
|
INPUT_PATH: "/var/data"
|
||||||
|
OUTPUT_PATH: "/var/result"
|
||||||
|
volumes:
|
||||||
|
buffer:
|
||||||
30
kuzarin_maxim_lab_3/.dockerignore
Normal file
30
kuzarin_maxim_lab_3/.dockerignore
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
**/.classpath
|
||||||
|
**/.dockerignore
|
||||||
|
**/.env
|
||||||
|
**/.git
|
||||||
|
**/.gitignore
|
||||||
|
**/.project
|
||||||
|
**/.settings
|
||||||
|
**/.toolstarget
|
||||||
|
**/.vs
|
||||||
|
**/.vscode
|
||||||
|
**/*.*proj.user
|
||||||
|
**/*.dbmdl
|
||||||
|
**/*.jfm
|
||||||
|
**/azds.yaml
|
||||||
|
**/bin
|
||||||
|
**/charts
|
||||||
|
**/docker-compose*
|
||||||
|
**/Dockerfile*
|
||||||
|
**/node_modules
|
||||||
|
**/npm-debug.log
|
||||||
|
**/obj
|
||||||
|
**/secrets.dev.yaml
|
||||||
|
**/values.dev.yaml
|
||||||
|
LICENSE
|
||||||
|
README.md
|
||||||
|
!**/.gitignore
|
||||||
|
!.git/HEAD
|
||||||
|
!.git/config
|
||||||
|
!.git/packed-refs
|
||||||
|
!.git/refs/heads/**
|
||||||
63
kuzarin_maxim_lab_3/.gitattributes
vendored
Normal file
63
kuzarin_maxim_lab_3/.gitattributes
vendored
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
###############################################################################
|
||||||
|
# Set default behavior to automatically normalize line endings.
|
||||||
|
###############################################################################
|
||||||
|
* text=auto
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Set default behavior for command prompt diff.
|
||||||
|
#
|
||||||
|
# This is need for earlier builds of msysgit that does not have it on by
|
||||||
|
# default for csharp files.
|
||||||
|
# Note: This is only used by command line
|
||||||
|
###############################################################################
|
||||||
|
#*.cs diff=csharp
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Set the merge driver for project and solution files
|
||||||
|
#
|
||||||
|
# Merging from the command prompt will add diff markers to the files if there
|
||||||
|
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||||
|
# the diff markers are never inserted). Diff markers may cause the following
|
||||||
|
# file extensions to fail to load in VS. An alternative would be to treat
|
||||||
|
# these files as binary and thus will always conflict and require user
|
||||||
|
# intervention with every merge. To do so, just uncomment the entries below
|
||||||
|
###############################################################################
|
||||||
|
#*.sln merge=binary
|
||||||
|
#*.csproj merge=binary
|
||||||
|
#*.vbproj merge=binary
|
||||||
|
#*.vcxproj merge=binary
|
||||||
|
#*.vcproj merge=binary
|
||||||
|
#*.dbproj merge=binary
|
||||||
|
#*.fsproj merge=binary
|
||||||
|
#*.lsproj merge=binary
|
||||||
|
#*.wixproj merge=binary
|
||||||
|
#*.modelproj merge=binary
|
||||||
|
#*.sqlproj merge=binary
|
||||||
|
#*.wwaproj merge=binary
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# behavior for image files
|
||||||
|
#
|
||||||
|
# image files are treated as binary by default.
|
||||||
|
###############################################################################
|
||||||
|
#*.jpg binary
|
||||||
|
#*.png binary
|
||||||
|
#*.gif binary
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# diff behavior for common document formats
|
||||||
|
#
|
||||||
|
# Convert binary document formats to text before diffing them. This feature
|
||||||
|
# is only available from the command line. Turn it on by uncommenting the
|
||||||
|
# entries below.
|
||||||
|
###############################################################################
|
||||||
|
#*.doc diff=astextplain
|
||||||
|
#*.DOC diff=astextplain
|
||||||
|
#*.docx diff=astextplain
|
||||||
|
#*.DOCX diff=astextplain
|
||||||
|
#*.dot diff=astextplain
|
||||||
|
#*.DOT diff=astextplain
|
||||||
|
#*.pdf diff=astextplain
|
||||||
|
#*.PDF diff=astextplain
|
||||||
|
#*.rtf diff=astextplain
|
||||||
|
#*.RTF diff=astextplain
|
||||||
363
kuzarin_maxim_lab_3/.gitignore
vendored
Normal file
363
kuzarin_maxim_lab_3/.gitignore
vendored
Normal file
@@ -0,0 +1,363 @@
|
|||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.rsuser
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
mono_crash.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
[Ww][Ii][Nn]32/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Oo]ut/
|
||||||
|
[Ll]og/
|
||||||
|
[Ll]ogs/
|
||||||
|
|
||||||
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# Visual Studio 2017 auto generated files
|
||||||
|
Generated\ Files/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUnit
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
nunit-*.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
# ASP.NET Scaffolding
|
||||||
|
ScaffoldingReadMe.txt
|
||||||
|
|
||||||
|
# StyleCop
|
||||||
|
StyleCopReport.xml
|
||||||
|
|
||||||
|
# Files built by Visual Studio
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_h.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.iobj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.ipdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*_wpftmp.csproj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
*.e2e
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Coverlet is a free, cross platform Code Coverage Tool
|
||||||
|
coverage*.json
|
||||||
|
coverage*.xml
|
||||||
|
coverage*.info
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
*.snupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/[Pp]ackages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/[Pp]ackages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/[Pp]ackages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
*.appxbundle
|
||||||
|
*.appxupload
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!?*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Including strong name files can present a security risk
|
||||||
|
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||||
|
#*.snk
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
ServiceFabricBackup/
|
||||||
|
*.rptproj.bak
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
*.rptproj.rsuser
|
||||||
|
*- [Bb]ackup.rdl
|
||||||
|
*- [Bb]ackup ([0-9]).rdl
|
||||||
|
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# CodeRush personal settings
|
||||||
|
.cr/personal
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
|
|
||||||
|
# Azure Stream Analytics local run output
|
||||||
|
ASALocalRun/
|
||||||
|
|
||||||
|
# MSBuild Binary and Structured Log
|
||||||
|
*.binlog
|
||||||
|
|
||||||
|
# NVidia Nsight GPU debugger configuration file
|
||||||
|
*.nvuser
|
||||||
|
|
||||||
|
# MFractors (Xamarin productivity tool) working folder
|
||||||
|
.mfractor/
|
||||||
|
|
||||||
|
# Local History for Visual Studio
|
||||||
|
.localhistory/
|
||||||
|
|
||||||
|
# BeatPulse healthcheck temp database
|
||||||
|
healthchecksdb
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
MigrationBackup/
|
||||||
|
|
||||||
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
|
.ionide/
|
||||||
|
|
||||||
|
# Fody - auto-generated XML schema
|
||||||
|
FodyWeavers.xsd
|
||||||
31
kuzarin_maxim_lab_3/DSaC.sln
Normal file
31
kuzarin_maxim_lab_3/DSaC.sln
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.10.34916.146
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DSaC", "DSaC\DSaC.csproj", "{C1051C12-D7D0-4C77-AFBC-4F5FFD8EE367}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DSaC_second", "DSaC_second\DSaC_second.csproj", "{64F78585-2BBC-4656-BC50-41FBB8917719}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{C1051C12-D7D0-4C77-AFBC-4F5FFD8EE367}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C1051C12-D7D0-4C77-AFBC-4F5FFD8EE367}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C1051C12-D7D0-4C77-AFBC-4F5FFD8EE367}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{C1051C12-D7D0-4C77-AFBC-4F5FFD8EE367}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{64F78585-2BBC-4656-BC50-41FBB8917719}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{64F78585-2BBC-4656-BC50-41FBB8917719}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{64F78585-2BBC-4656-BC50-41FBB8917719}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{64F78585-2BBC-4656-BC50-41FBB8917719}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {30D05708-634E-4FDE-9BCA-5A1B7A5EFF59}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
using DSaC.Models.DTOs;
|
||||||
|
using DSaC.Models.Internal.Queries;
|
||||||
|
using DSaC.Models.Internal.Сommands;
|
||||||
|
using MediatR;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
|
||||||
|
namespace DSaC.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class CounterpartiesController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IMediator mediator;
|
||||||
|
|
||||||
|
public CounterpartiesController(IMediator mediator)
|
||||||
|
{
|
||||||
|
this.mediator = mediator;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("")]
|
||||||
|
public async Task<IActionResult> GetCounterparties(
|
||||||
|
[FromQuery] int page = 0,
|
||||||
|
[FromQuery] int pageSize = 10,
|
||||||
|
[FromQuery] List<Guid>? ids = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
var request = new GetCounterpartiesQuery
|
||||||
|
{
|
||||||
|
Page = page,
|
||||||
|
PageSize = pageSize,
|
||||||
|
Ids = ids
|
||||||
|
};
|
||||||
|
|
||||||
|
var response = await mediator.Send(request);
|
||||||
|
|
||||||
|
return !response.IsError ? Ok(response.Value) : StatusCode(response.ErrorCode!.Value, response.ErrorText);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("{uuid:guid}")]
|
||||||
|
public async Task<IActionResult> GetFullCounterparty([FromRoute] Guid uuid)
|
||||||
|
{
|
||||||
|
var request = new GetCounterpartyQuery
|
||||||
|
{
|
||||||
|
Id = uuid
|
||||||
|
};
|
||||||
|
|
||||||
|
var response = await mediator.Send(request);
|
||||||
|
|
||||||
|
return !response.IsError ? Ok(response.Value) : StatusCode(response.ErrorCode!.Value, response.ErrorText);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("")]
|
||||||
|
public async Task<IActionResult> CreateCounterparty([FromBody] CounterpartyBaseDto dto)
|
||||||
|
{
|
||||||
|
var response = await mediator.Send(new CreateCounterpartyCommand()
|
||||||
|
{
|
||||||
|
Model = dto
|
||||||
|
});
|
||||||
|
|
||||||
|
return !response.IsError ? Ok(response.Value) : StatusCode(response.ErrorCode!.Value, response.ErrorText);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut("{uuid:guid}")]
|
||||||
|
public async Task<IActionResult> UpdateRecord([FromRoute] Guid uuid, [FromBody] CounterpartyViewDto dto)
|
||||||
|
{
|
||||||
|
var response = await mediator.Send(new UpdateCounterpartyCommand()
|
||||||
|
{
|
||||||
|
Id=uuid,
|
||||||
|
Model = dto
|
||||||
|
});
|
||||||
|
|
||||||
|
return !response.IsError ? Ok(response.Value) : StatusCode(response.ErrorCode!.Value, response.ErrorText);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete("{uuid:guid}")]
|
||||||
|
public async Task<IActionResult> DeleteRecord([FromRoute] Guid uuid)
|
||||||
|
{
|
||||||
|
var response = await mediator.Send(new DeleteCounterpartyCommand()
|
||||||
|
{
|
||||||
|
Id = uuid,
|
||||||
|
});
|
||||||
|
|
||||||
|
return !response.IsError ? Ok() : StatusCode(response.ErrorCode!.Value, response.ErrorText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
kuzarin_maxim_lab_3/DSaC/DSaC.csproj
Normal file
26
kuzarin_maxim_lab_3/DSaC/DSaC.csproj
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<UserSecretsId>55894bef-8317-4e30-a5f0-4dcd5c3f861e</UserSecretsId>
|
||||||
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="MediatR" Version="12.4.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
|
||||||
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.12" />
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
|
||||||
|
<PackageReference Include="PIHelperSh.Configuration" Version="1.0.1" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
14
kuzarin_maxim_lab_3/DSaC/Database/DsacContext.cs
Normal file
14
kuzarin_maxim_lab_3/DSaC/Database/DsacContext.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using DSaC.Database.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace DSaC.Database
|
||||||
|
{
|
||||||
|
public class DsacContext: DbContext
|
||||||
|
{
|
||||||
|
public DsacContext(DbContextOptions options) : base(options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public DbSet<Counterparty> Counterparties { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
24
kuzarin_maxim_lab_3/DSaC/Database/Models/Counterparty.cs
Normal file
24
kuzarin_maxim_lab_3/DSaC/Database/Models/Counterparty.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using DSaC.Models.DTOs;
|
||||||
|
using DSaC.Models.Internal.Сommands;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace DSaC.Database.Models
|
||||||
|
{
|
||||||
|
[Table("counterparty")]
|
||||||
|
[AutoMap(typeof(CounterpartyBaseDto))]
|
||||||
|
[AutoMap(typeof(CounterpartyViewDto))]
|
||||||
|
public class Counterparty
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[Column("id")]
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
[MaxLength(255)]
|
||||||
|
[Column("name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
24
kuzarin_maxim_lab_3/DSaC/Dockerfile
Normal file
24
kuzarin_maxim_lab_3/DSaC/Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 8080
|
||||||
|
EXPOSE 8081
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["DSaC.csproj", "DSaC/"]
|
||||||
|
RUN dotnet restore "DSaC/DSaC.csproj"
|
||||||
|
WORKDIR "/src/DSaC"
|
||||||
|
COPY . .
|
||||||
|
RUN dotnet build "DSaC.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
RUN dotnet publish "DSaC.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "DSaC.dll"]
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using DSaC.Database;
|
||||||
|
using DSaC.Database.Models;
|
||||||
|
using DSaC.Logic.Handlers.Queries;
|
||||||
|
using DSaC.Models.DTOs;
|
||||||
|
using DSaC.Models.Internal;
|
||||||
|
using DSaC.Models.Internal.Сommands;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace DSaC.Logic.Handlers.Commands
|
||||||
|
{
|
||||||
|
public class CreateCounterpartyCommandHandler : IRequestHandler<CreateCounterpartyCommand, ResponseModel<CounterpartyViewDto>>
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly DsacContext _context;
|
||||||
|
private readonly IMapper _mapper;
|
||||||
|
|
||||||
|
public CreateCounterpartyCommandHandler(ILogger<CreateCounterpartyCommandHandler> logger, DsacContext context, IMapper mapper)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_context = context;
|
||||||
|
_mapper = mapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ResponseModel<CounterpartyViewDto>> Handle(CreateCounterpartyCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = _mapper.Map<Counterparty>(request.Model);
|
||||||
|
|
||||||
|
var res = await _context.AddAsync(model);
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Value = _mapper.Map<CounterpartyViewDto>(res.Entity)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error on creating counterparty");
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
StatusCode = System.Net.HttpStatusCode.NotFound,
|
||||||
|
ErrorText = "Cannot create counterparty"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using DSaC.Database;
|
||||||
|
using DSaC.Database.Models;
|
||||||
|
using DSaC.Models.DTOs;
|
||||||
|
using DSaC.Models.Internal;
|
||||||
|
using DSaC.Models.Internal.Сommands;
|
||||||
|
using MediatR;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace DSaC.Logic.Handlers.Commands
|
||||||
|
{
|
||||||
|
public class DeleteCounterpartyCommandHandler: IRequestHandler<DeleteCounterpartyCommand, ResponseModel>
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly DsacContext _context;
|
||||||
|
private readonly IMapper _mapper;
|
||||||
|
|
||||||
|
public DeleteCounterpartyCommandHandler(ILogger<DeleteCounterpartyCommandHandler> logger, DsacContext context, IMapper mapper)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_context = context;
|
||||||
|
_mapper = mapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ResponseModel> Handle(DeleteCounterpartyCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var res = await _context.Counterparties.Where(x=>x.Id == request.Id).ExecuteDeleteAsync();
|
||||||
|
|
||||||
|
if (res == 1)return new();
|
||||||
|
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
ErrorText = "Cannot find object to delete",
|
||||||
|
StatusCode = System.Net.HttpStatusCode.NotFound
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error on deleteing counterparty");
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
StatusCode = System.Net.HttpStatusCode.NotFound,
|
||||||
|
ErrorText = "Cannot delete counterparty"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using DSaC.Database;
|
||||||
|
using DSaC.Database.Models;
|
||||||
|
using DSaC.Models.DTOs;
|
||||||
|
using DSaC.Models.Internal;
|
||||||
|
using DSaC.Models.Internal.Сommands;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace DSaC.Logic.Handlers.Commands
|
||||||
|
{
|
||||||
|
public class UpdateCounterpartyCommandHandler: IRequestHandler<UpdateCounterpartyCommand, ResponseModel<CounterpartyViewDto>>
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly DsacContext _context;
|
||||||
|
private readonly IMapper _mapper;
|
||||||
|
|
||||||
|
public UpdateCounterpartyCommandHandler(ILogger<UpdateCounterpartyCommandHandler> logger, DsacContext context, IMapper mapper)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_context = context;
|
||||||
|
_mapper = mapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ResponseModel<CounterpartyViewDto>> Handle(UpdateCounterpartyCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = _mapper.Map<Counterparty>(request.Model);
|
||||||
|
|
||||||
|
var res = _context.Update(model);
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Value = _mapper.Map<CounterpartyViewDto>(res.Entity)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error on updating counterparty");
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
StatusCode = System.Net.HttpStatusCode.NotFound,
|
||||||
|
ErrorText = "Cannot update counterparty"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using DSaC.Database;
|
||||||
|
using DSaC.Models.DTOs;
|
||||||
|
using DSaC.Models.Internal;
|
||||||
|
using DSaC.Models.Internal.Queries;
|
||||||
|
using MediatR;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace DSaC.Logic.Handlers.Queries
|
||||||
|
{
|
||||||
|
public class GetCounterpartiesQueryHandler : IRequestHandler<GetCounterpartiesQuery, ResponseModel<List<CounterpartyViewDto>>>
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly DsacContext _context;
|
||||||
|
private readonly IMapper _mapper;
|
||||||
|
|
||||||
|
public GetCounterpartiesQueryHandler(ILogger<GetCounterpartiesQueryHandler> logger, DsacContext context, IMapper mapper)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_context = context;
|
||||||
|
_mapper = mapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ResponseModel<List<CounterpartyViewDto>>> Handle(GetCounterpartiesQuery request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var res = await _context.Counterparties
|
||||||
|
.Where(x=>request.Ids == null || request.Ids.Contains(x.Id))
|
||||||
|
.Skip(request.Page * request.PageSize).Take(request.PageSize)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Value = res.Select(_mapper.Map<CounterpartyViewDto>).ToList(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error on getting records");
|
||||||
|
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
StatusCode = System.Net.HttpStatusCode.BadRequest,
|
||||||
|
ErrorText = "Cannot get Counterparties by this request",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using DSaC.Database;
|
||||||
|
using DSaC.Models.DTOs;
|
||||||
|
using DSaC.Models.Internal;
|
||||||
|
using DSaC.Models.Internal.Queries;
|
||||||
|
using MediatR;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace DSaC.Logic.Handlers.Queries
|
||||||
|
{
|
||||||
|
public class GetCounterpartyQueryHandler: IRequestHandler<GetCounterpartyQuery, ResponseModel<CounterpartyViewDto>>
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly DsacContext _context;
|
||||||
|
private readonly IMapper _mapper;
|
||||||
|
|
||||||
|
public GetCounterpartyQueryHandler(ILogger<GetCounterpartyQueryHandler> logger, DsacContext context, IMapper mapper)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_context = context;
|
||||||
|
_mapper = mapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ResponseModel<CounterpartyViewDto>> Handle(GetCounterpartyQuery request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var res = await _context.Counterparties.FirstOrDefaultAsync(x=>x.Id == request.Id);
|
||||||
|
|
||||||
|
if (res == null)
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
StatusCode = System.Net.HttpStatusCode.NotFound,
|
||||||
|
ErrorText = "Counterparty with this ID does not exsist",
|
||||||
|
};
|
||||||
|
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Value = _mapper.Map<CounterpartyViewDto>(res),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error on getting record");
|
||||||
|
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
StatusCode = System.Net.HttpStatusCode.NotFound,
|
||||||
|
ErrorText = "Cannot get Counterparty by id",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
kuzarin_maxim_lab_3/DSaC/Migrations/20240907133944_InitMigraton.Designer.cs
generated
Normal file
60
kuzarin_maxim_lab_3/DSaC/Migrations/20240907133944_InitMigraton.Designer.cs
generated
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using DSaC.Database;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DSaC.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DsacContext))]
|
||||||
|
[Migration("20240907133944_InitMigraton")]
|
||||||
|
partial class InitMigraton
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.8")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("DSaC.Database.Models.Counterparty", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
b.Property<string>("ContractNumber")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("character varying(50)")
|
||||||
|
.HasColumnName("contract_number");
|
||||||
|
|
||||||
|
b.Property<string>("ManagerName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)")
|
||||||
|
.HasColumnName("manager_name");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)")
|
||||||
|
.HasColumnName("name");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("counterparty");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DSaC.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class InitMigraton : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "counterparty",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
||||||
|
contract_number = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
||||||
|
manager_name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_counterparty", x => x.id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "counterparty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
64
kuzarin_maxim_lab_3/DSaC/Migrations/20240907140843_ChangingContractInfo.Designer.cs
generated
Normal file
64
kuzarin_maxim_lab_3/DSaC/Migrations/20240907140843_ChangingContractInfo.Designer.cs
generated
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using DSaC.Database;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DSaC.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DsacContext))]
|
||||||
|
[Migration("20240907140843_ChangingContractInfo")]
|
||||||
|
partial class ChangingContractInfo
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.8")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("DSaC.Database.Models.Counterparty", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
b.Property<string>("ContractNumber")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("character varying(50)")
|
||||||
|
.HasColumnName("contract_number");
|
||||||
|
|
||||||
|
b.Property<bool>("IsContractClosed")
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasColumnName("is_contract_closed");
|
||||||
|
|
||||||
|
b.Property<string>("ManagerName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)")
|
||||||
|
.HasColumnName("manager_name");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)")
|
||||||
|
.HasColumnName("name");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("counterparty");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DSaC.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class ChangingContractInfo : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "is_contract_closed",
|
||||||
|
table: "counterparty",
|
||||||
|
type: "boolean",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "is_contract_closed",
|
||||||
|
table: "counterparty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
63
kuzarin_maxim_lab_3/DSaC/Migrations/20240907141343_SmallHotfix.Designer.cs
generated
Normal file
63
kuzarin_maxim_lab_3/DSaC/Migrations/20240907141343_SmallHotfix.Designer.cs
generated
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using DSaC.Database;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DSaC.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DsacContext))]
|
||||||
|
[Migration("20240907141343_SmallHotfix")]
|
||||||
|
partial class SmallHotfix
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.8")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("DSaC.Database.Models.Counterparty", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
b.Property<string>("ContractNumber")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("character varying(50)")
|
||||||
|
.HasColumnName("contract_number");
|
||||||
|
|
||||||
|
b.Property<bool>("IsContractClosed")
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasColumnName("is_contract_closed");
|
||||||
|
|
||||||
|
b.Property<string>("ManagerName")
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)")
|
||||||
|
.HasColumnName("manager_name");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)")
|
||||||
|
.HasColumnName("name");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("counterparty");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DSaC.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class SmallHotfix : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "manager_name",
|
||||||
|
table: "counterparty",
|
||||||
|
type: "character varying(255)",
|
||||||
|
maxLength: 255,
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "character varying(255)",
|
||||||
|
oldMaxLength: 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "manager_name",
|
||||||
|
table: "counterparty",
|
||||||
|
type: "character varying(255)",
|
||||||
|
maxLength: 255,
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "",
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "character varying(255)",
|
||||||
|
oldMaxLength: 255,
|
||||||
|
oldNullable: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
48
kuzarin_maxim_lab_3/DSaC/Migrations/20240914065929_after-reconstruction.Designer.cs
generated
Normal file
48
kuzarin_maxim_lab_3/DSaC/Migrations/20240914065929_after-reconstruction.Designer.cs
generated
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using DSaC.Database;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DSaC.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DsacContext))]
|
||||||
|
[Migration("20240914065929_after-reconstruction")]
|
||||||
|
partial class afterreconstruction
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.8")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("DSaC.Database.Models.Counterparty", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)")
|
||||||
|
.HasColumnName("name");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("counterparty");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DSaC.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class afterreconstruction : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "contract_number",
|
||||||
|
table: "counterparty");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "is_contract_closed",
|
||||||
|
table: "counterparty");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "manager_name",
|
||||||
|
table: "counterparty");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "contract_number",
|
||||||
|
table: "counterparty",
|
||||||
|
type: "character varying(50)",
|
||||||
|
maxLength: 50,
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "is_contract_closed",
|
||||||
|
table: "counterparty",
|
||||||
|
type: "boolean",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "manager_name",
|
||||||
|
table: "counterparty",
|
||||||
|
type: "character varying(255)",
|
||||||
|
maxLength: 255,
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using DSaC.Database;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DSaC.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DsacContext))]
|
||||||
|
partial class DsacContextModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.8")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("DSaC.Database.Models.Counterparty", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)")
|
||||||
|
.HasColumnName("name");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("counterparty");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
kuzarin_maxim_lab_3/DSaC/Models/DTOs/ContractViewDto.cs
Normal file
17
kuzarin_maxim_lab_3/DSaC/Models/DTOs/ContractViewDto.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace DSaC.Models.DTOs
|
||||||
|
{
|
||||||
|
public class ContractViewDto
|
||||||
|
{
|
||||||
|
[Required(ErrorMessage = "Contract number must be present")]
|
||||||
|
public string ContractNumber { get; set; } = null!;
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Manager name must be present")]
|
||||||
|
public string ManagerName { get; set; } = null!;
|
||||||
|
|
||||||
|
public DateTime CreatinTime { get; set; }
|
||||||
|
|
||||||
|
public bool IsClosed { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
13
kuzarin_maxim_lab_3/DSaC/Models/DTOs/CounterpartyBaseDto.cs
Normal file
13
kuzarin_maxim_lab_3/DSaC/Models/DTOs/CounterpartyBaseDto.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
using AutoMapper;
|
||||||
|
using DSaC.Database.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace DSaC.Models.DTOs
|
||||||
|
{
|
||||||
|
public class CounterpartyBaseDto
|
||||||
|
{
|
||||||
|
[Required(ErrorMessage = "Cpty name must be present")]
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
kuzarin_maxim_lab_3/DSaC/Models/DTOs/CounterpartyViewDto.cs
Normal file
11
kuzarin_maxim_lab_3/DSaC/Models/DTOs/CounterpartyViewDto.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using DSaC.Database.Models;
|
||||||
|
|
||||||
|
namespace DSaC.Models.DTOs
|
||||||
|
{
|
||||||
|
[AutoMap(typeof(Counterparty))]
|
||||||
|
public class CounterpartyViewDto: CounterpartyBaseDto
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using DSaC.Models.DTOs;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace DSaC.Models.Internal.Queries
|
||||||
|
{
|
||||||
|
public class GetCounterpartiesQuery: IRequest<ResponseModel<List<CounterpartyViewDto>>>
|
||||||
|
{
|
||||||
|
public List<Guid>? Ids { get; set; }
|
||||||
|
|
||||||
|
public int Page { get; set; }
|
||||||
|
|
||||||
|
public int PageSize { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using DSaC.Models.DTOs;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace DSaC.Models.Internal.Queries
|
||||||
|
{
|
||||||
|
public class GetCounterpartyQuery: IRequest<ResponseModel<CounterpartyViewDto>>
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
30
kuzarin_maxim_lab_3/DSaC/Models/Internal/ResponseModel.cs
Normal file
30
kuzarin_maxim_lab_3/DSaC/Models/Internal/ResponseModel.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace DSaC.Models.Internal
|
||||||
|
{
|
||||||
|
public class ResponseModel
|
||||||
|
{
|
||||||
|
public string? ErrorText;
|
||||||
|
|
||||||
|
public bool IsError => !string.IsNullOrEmpty(ErrorText);
|
||||||
|
|
||||||
|
private int? _errorCode = 200;
|
||||||
|
|
||||||
|
public int? ErrorCode
|
||||||
|
{
|
||||||
|
get => _errorCode;
|
||||||
|
set => _errorCode = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HttpStatusCode? StatusCode
|
||||||
|
{
|
||||||
|
get => (HttpStatusCode?)_errorCode;
|
||||||
|
set => _errorCode = (int?)value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ResponseModel<T> : ResponseModel
|
||||||
|
{
|
||||||
|
public T? Value { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using DSaC.Models.DTOs;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace DSaC.Models.Internal.Сommands
|
||||||
|
{
|
||||||
|
public class CreateCounterpartyCommand : IRequest<ResponseModel<CounterpartyViewDto>>
|
||||||
|
{
|
||||||
|
public CounterpartyBaseDto Model { get; set; } = null!;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace DSaC.Models.Internal.Сommands
|
||||||
|
{
|
||||||
|
public class DeleteCounterpartyCommand: IRequest<ResponseModel>
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using DSaC.Models.DTOs;
|
||||||
|
using MediatR;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace DSaC.Models.Internal.Сommands
|
||||||
|
{
|
||||||
|
public class UpdateCounterpartyCommand: IRequest<ResponseModel<CounterpartyViewDto>>
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "UpdateMessageMust be present")]
|
||||||
|
public CounterpartyViewDto Model { get; set; } = null!;
|
||||||
|
}
|
||||||
|
}
|
||||||
128
kuzarin_maxim_lab_3/DSaC/Program.cs
Normal file
128
kuzarin_maxim_lab_3/DSaC/Program.cs
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
using DSaC.Database;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.OpenApi.Models;
|
||||||
|
using NLog.Config;
|
||||||
|
using NLog.Extensions.Logging;
|
||||||
|
using NLog.Targets;
|
||||||
|
using PIHelperSh.Configuration;
|
||||||
|
using PIHelperSh.Configuration.Attributes;
|
||||||
|
using System.Reflection;
|
||||||
|
using LogLevel = NLog.LogLevel;
|
||||||
|
|
||||||
|
[TrackedType]
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
private static WebApplication? app;
|
||||||
|
|
||||||
|
[Constant(BlockName = "Database")]
|
||||||
|
private static string ConnectionString;
|
||||||
|
|
||||||
|
[Constant(BlockName = "GatewaySettings")]
|
||||||
|
private static string AppPrefix;
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
ConfigureLogger(builder);
|
||||||
|
|
||||||
|
ConfigureServices(builder);
|
||||||
|
|
||||||
|
ConfigureDatabase(builder);
|
||||||
|
|
||||||
|
app = builder.Build();
|
||||||
|
|
||||||
|
var t = MigrateDatabase();
|
||||||
|
|
||||||
|
app.UseSwagger(c =>
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(AppPrefix))
|
||||||
|
{
|
||||||
|
//c.RouteTemplate = AppPrefix + "/swagger/{documentName}/swagger.json";
|
||||||
|
|
||||||
|
c.PreSerializeFilters.Add((swaggerDoc, httpReq) =>
|
||||||
|
{
|
||||||
|
swaggerDoc.Servers = new List<OpenApiServer> { new OpenApiServer { Url = $"{httpReq.Scheme}://{httpReq.Host.Value}/{AppPrefix}" } };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
app.UseSwaggerUI(c =>
|
||||||
|
{
|
||||||
|
//if (!string.IsNullOrEmpty(AppPrefix))
|
||||||
|
//{
|
||||||
|
// c.SwaggerEndpoint($"/{AppPrefix}/swagger/v1/swagger.json", $"APP API");
|
||||||
|
// c.RoutePrefix = $"{AppPrefix}/swagger";
|
||||||
|
//}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.MapControllers();
|
||||||
|
|
||||||
|
t.Wait();
|
||||||
|
|
||||||
|
app.Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConfigureLogger(WebApplicationBuilder builder)
|
||||||
|
{
|
||||||
|
var nLogConfig = new LoggingConfiguration();
|
||||||
|
var logConsole = new ConsoleTarget();
|
||||||
|
var blackhole = new NullTarget();
|
||||||
|
|
||||||
|
var logFile = new FileTarget()
|
||||||
|
{
|
||||||
|
FileName = "${basedir}/logs/${shortdate}_logs.log"
|
||||||
|
};
|
||||||
|
|
||||||
|
nLogConfig.AddRule(LogLevel.Trace, LogLevel.Trace, blackhole, "Microsoft.AspNetCore.*", true);
|
||||||
|
nLogConfig.AddRule(LogLevel.Info, LogLevel.Warn, logFile, "Microsoft.EntityFrameworkCore.*", true);
|
||||||
|
nLogConfig.AddRule(LogLevel.Info, LogLevel.Warn, logFile, "Microsoft.AspNetCore.*", true);
|
||||||
|
nLogConfig.AddRule(LogLevel.Info, LogLevel.Warn, logFile, "System.Net.Http.HttpClient.Refit.*", true);
|
||||||
|
nLogConfig.AddRule(LogLevel.Info, LogLevel.Error, logConsole);
|
||||||
|
nLogConfig.AddRule(LogLevel.Debug, LogLevel.Error, logFile);
|
||||||
|
|
||||||
|
builder.Logging.ClearProviders();
|
||||||
|
builder.Services.AddLogging(m => m.AddNLog(nLogConfig));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConfigureServices(WebApplicationBuilder builder)
|
||||||
|
{
|
||||||
|
builder.Services.AddConfigurations(builder.Configuration);
|
||||||
|
builder.Configuration.AddConstants();
|
||||||
|
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
|
||||||
|
|
||||||
|
builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblyContaining<Program>());
|
||||||
|
|
||||||
|
builder.Services.AddControllers().AddNewtonsoftJson();
|
||||||
|
|
||||||
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
builder.Services.AddSwaggerGen(c =>
|
||||||
|
{
|
||||||
|
c.SwaggerDoc("v1", new OpenApiInfo
|
||||||
|
{
|
||||||
|
Title = "Distributed computing and applications",
|
||||||
|
Version = "v1",
|
||||||
|
Description = ""
|
||||||
|
});
|
||||||
|
|
||||||
|
//c.EnableAnnotations();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConfigureDatabase(WebApplicationBuilder builder)
|
||||||
|
{
|
||||||
|
builder.Services.AddDbContext<DsacContext>(options =>
|
||||||
|
{
|
||||||
|
options.UseNpgsql(ConnectionString);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task MigrateDatabase()
|
||||||
|
{
|
||||||
|
var context = app?.Services.CreateScope().ServiceProvider.GetService<DsacContext>();
|
||||||
|
if(context != null)
|
||||||
|
await context.Database.MigrateAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
52
kuzarin_maxim_lab_3/DSaC/Properties/launchSettings.json
Normal file
52
kuzarin_maxim_lab_3/DSaC/Properties/launchSettings.json
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
},
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"applicationUrl": "http://localhost:5062"
|
||||||
|
},
|
||||||
|
"https": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
},
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"applicationUrl": "https://localhost:7219;http://localhost:5062"
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Container (Dockerfile)": {
|
||||||
|
"commandName": "Docker",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_HTTPS_PORTS": "8081",
|
||||||
|
"ASPNETCORE_HTTP_PORTS": "8080"
|
||||||
|
},
|
||||||
|
"publishAllPorts": true,
|
||||||
|
"useSSL": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:9154",
|
||||||
|
"sslPort": 44381
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
kuzarin_maxim_lab_3/DSaC/appsettings.Development.json
Normal file
14
kuzarin_maxim_lab_3/DSaC/appsettings.Development.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Database": {
|
||||||
|
"ConnectionString": "Host=db.dev-moio.online;Port=31153;Database=dsac_maxim;Username=postgres;Password=postgres_password"
|
||||||
|
},
|
||||||
|
"GatewaySettings": {
|
||||||
|
"AppPrefix": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
9
kuzarin_maxim_lab_3/DSaC/appsettings.json
Normal file
9
kuzarin_maxim_lab_3/DSaC/appsettings.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
using DSaC_second.Models.DTOs;
|
||||||
|
using DSaC_second.Models.Internal.Queries;
|
||||||
|
using DSaC_second.Models.Internal.Сommands;
|
||||||
|
using MediatR;
|
||||||
|
using Microsoft.AspNetCore.Components.Forms;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace DSaC_second.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class ContractController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IMediator _mediator;
|
||||||
|
|
||||||
|
public ContractController(IMediator mediator)
|
||||||
|
{
|
||||||
|
_mediator = mediator;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("")]
|
||||||
|
public async Task<IActionResult> GetContracts(
|
||||||
|
[FromQuery] int page = 0,
|
||||||
|
[FromQuery] int pageSize = 10,
|
||||||
|
[FromQuery] List<Guid>? ids = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
var request = new GetContractsQuery
|
||||||
|
{
|
||||||
|
Page = page,
|
||||||
|
PageSize = pageSize,
|
||||||
|
Ids = ids
|
||||||
|
};
|
||||||
|
|
||||||
|
var response = await _mediator.Send(request);
|
||||||
|
|
||||||
|
return !response.IsError ? Ok(response.Value) : StatusCode(response.ErrorCode!.Value, response.ErrorText);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("{uuid:guid}")]
|
||||||
|
public async Task<IActionResult> GetFullContract([FromRoute] Guid uuid)
|
||||||
|
{
|
||||||
|
var request = new GetContractQuery
|
||||||
|
{
|
||||||
|
Id = uuid
|
||||||
|
};
|
||||||
|
|
||||||
|
var response = await _mediator.Send(request);
|
||||||
|
|
||||||
|
return !response.IsError ? Ok(response.Value) : StatusCode(response.ErrorCode!.Value, response.ErrorText);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("")]
|
||||||
|
public async Task<IActionResult> CreateContract([FromBody] ContractBaseDto dto)
|
||||||
|
{
|
||||||
|
var response = await _mediator.Send(new CreateContractCommand()
|
||||||
|
{
|
||||||
|
Model = dto
|
||||||
|
});
|
||||||
|
|
||||||
|
return !response.IsError ? Ok(response.Value) : StatusCode(response.ErrorCode!.Value, response.ErrorText);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut("{uuid:guid}")]
|
||||||
|
public async Task<IActionResult> UpdateContract([FromRoute] Guid uuid, [FromBody] ContractViewDto dto)
|
||||||
|
{
|
||||||
|
var response = await _mediator.Send(new UpdateContractCommand()
|
||||||
|
{
|
||||||
|
Id = uuid,
|
||||||
|
Model = dto
|
||||||
|
});
|
||||||
|
|
||||||
|
return !response.IsError ? Ok(response.Value) : StatusCode(response.ErrorCode!.Value, response.ErrorText);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete("{uuid:guid}")]
|
||||||
|
public async Task<IActionResult> DeleteContract([FromRoute] Guid uuid)
|
||||||
|
{
|
||||||
|
var response = await _mediator.Send(new DeleteContractCommand()
|
||||||
|
{
|
||||||
|
Id = uuid,
|
||||||
|
});
|
||||||
|
|
||||||
|
return !response.IsError ? Ok() : StatusCode(response.ErrorCode!.Value, response.ErrorText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
27
kuzarin_maxim_lab_3/DSaC_second/DSaC_second.csproj
Normal file
27
kuzarin_maxim_lab_3/DSaC_second/DSaC_second.csproj
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<UserSecretsId>39d29416-63e9-4884-9c5f-9d6ff461995f</UserSecretsId>
|
||||||
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="MediatR" Version="12.4.1" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
|
||||||
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.13" />
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
|
||||||
|
<PackageReference Include="PIHelperSh.Configuration" Version="1.0.1" />
|
||||||
|
<PackageReference Include="RestSharp" Version="112.0.0" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
15
kuzarin_maxim_lab_3/DSaC_second/Database/DsacContext.cs
Normal file
15
kuzarin_maxim_lab_3/DSaC_second/Database/DsacContext.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using DSaC_second.Database.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace DSaC_second.Database
|
||||||
|
{
|
||||||
|
public class DsacContext : DbContext
|
||||||
|
{
|
||||||
|
public DsacContext(DbContextOptions options) : base(options)
|
||||||
|
{
|
||||||
|
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DbSet<Contract> Contracts { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
38
kuzarin_maxim_lab_3/DSaC_second/Database/Models/Contract.cs
Normal file
38
kuzarin_maxim_lab_3/DSaC_second/Database/Models/Contract.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using DSaC_second.Models.DTOs;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace DSaC_second.Database.Models
|
||||||
|
{
|
||||||
|
[Table("contract")]
|
||||||
|
[AutoMap(typeof(ContractBaseDto))]
|
||||||
|
[AutoMap(typeof(ContractViewDto))]
|
||||||
|
public class Contract
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[Column("id")]
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
[Column("contract_number")]
|
||||||
|
[Required]
|
||||||
|
public string ContractNumber { get; set; }
|
||||||
|
|
||||||
|
[Column("manager_name")]
|
||||||
|
[Required]
|
||||||
|
public string ManagerName { get; set; }
|
||||||
|
|
||||||
|
[Column("counterparty_id")]
|
||||||
|
[Required]
|
||||||
|
public Guid CounterpartyId { get; set; }
|
||||||
|
|
||||||
|
[Column("creation_time")]
|
||||||
|
[Required]
|
||||||
|
public DateTime CreatinTime { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
[Column("is_closed")]
|
||||||
|
[DefaultValue(false)]
|
||||||
|
public bool IsClosed { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
24
kuzarin_maxim_lab_3/DSaC_second/Dockerfile
Normal file
24
kuzarin_maxim_lab_3/DSaC_second/Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 8080
|
||||||
|
EXPOSE 8081
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["DSaC_second.csproj", "DSaC_second/"]
|
||||||
|
RUN dotnet restore "DSaC_second/DSaC_second.csproj"
|
||||||
|
WORKDIR "/src/DSaC_second"
|
||||||
|
COPY . .
|
||||||
|
RUN dotnet build "DSaC_second.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
RUN dotnet publish "DSaC_second.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "DSaC_second.dll"]
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user