forked from Alexey/DAS_2024_1
Compare commits
84 Commits
yakovleva_
...
main
Author | SHA1 | Date | |
---|---|---|---|
85b809333b | |||
5e3c9c0d5b | |||
daf24d364d | |||
6c13deb231 | |||
543d41d9c3 | |||
153684c403 | |||
0708b01560 | |||
8a6932ff20 | |||
35cf16824d | |||
ac3dc2e566 | |||
2f46c05849 | |||
84cb26162c | |||
129b991712 | |||
ffecef8fa3 | |||
1289d67a62 | |||
b09f3ea844 | |||
2f368ffb07 | |||
ead06782ad | |||
b2ac5eba9a | |||
0c0a47549a | |||
|
84e8cac198 | ||
bde242318f | |||
761cc83ebd | |||
4699fda797 | |||
940cc6757f | |||
1e9bdf2806 | |||
|
9bd14a60b4 | ||
5aa2cae670 | |||
281d30a89e | |||
f2093f376c | |||
80c666d6b0 | |||
a589994db5 | |||
38ce2bb347 | |||
f25af86d9c | |||
45eb2b72c5 | |||
77bdc1d8e9 | |||
da6593c4d0 | |||
|
eeac04be49 | ||
0a73e2d5d4 | |||
1565e49462 | |||
858ea65e71 | |||
0f898b968d | |||
8b96102dbd | |||
82ecad71f4 | |||
8a96320fd5 | |||
bd25930973 | |||
ef68b506b8 | |||
|
8efc2422cf | ||
c3537b5abe | |||
a0ef65e0f9 | |||
6815b2e560 | |||
48b7fbd900 | |||
080625d270 | |||
37996c249a | |||
9456d4fe01 | |||
c14e105db5 | |||
4d1e900721 | |||
7184d6d728 | |||
|
6e7055efa4 | ||
|
9e40adc53c | ||
|
4a36528cc7 | ||
ad3988e5fc | |||
780b4b2924 | |||
d9f5f75f5e | |||
7d9c9ec4d0 | |||
5047b16cde | |||
2b87427299 | |||
|
21cdd4971d | ||
bdb5cc07ed | |||
e761e33201 | |||
|
ceee500b95 | ||
2be2c71b69 | |||
|
aa8180ba49 | ||
6ce78e60ad | |||
b13182c80e | |||
822467bd99 | |||
|
ba7480cb4f | ||
520337f92d | |||
d7faf2a1b7 | |||
d98803227e | |||
6f12270c73 | |||
6e6266c228 | |||
06d1d8cdd4 | |||
|
1adaac9281 |
64
balakhonov_danila_lab_2/README.md
Normal file
64
balakhonov_danila_lab_2/README.md
Normal file
@ -0,0 +1,64 @@
|
||||
# Лабораторная работа номер 2
|
||||
|
||||
> Здравствуйте меня зовут Балахонов Данила группа ПИбд-42
|
||||
>
|
||||
> *— Балахонов Данила ПИбд-42*
|
||||
|
||||
Видео лабораторной работы номер 2 доступно по этой [ссылке](https://drive.google.com/file/d/1N4NgWsFLlHY5lGOO3Ps7DPvdJbHNxaqz/view?usp=sharing).
|
||||
|
||||
## Как запустить лабораторную работу номер 2?
|
||||
### Необходимые компоненты для запуска лабораторной работы номер 2
|
||||
> Здесь рассказана установка необходимых компонентов для запуска лабораторной работы номер 2 под дистрибутив GNU/Linux **Ubuntu**.
|
||||
|
||||
Для запуска лабораторной работы номер 2 необходимы такие компоненты:
|
||||
- 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
|
||||
```
|
||||
### Запуск лабораторной работы номер 2
|
||||
Для запуска лабораторной работы номер 2 необходимо **склонировать** репозиторий в любую папку и **перейти на ветку** balakhonov_danila_lab_2.
|
||||
Далее в папке с `docker-compose.yaml` нужно вызвать такую команду:
|
||||
``` bash
|
||||
sudo docker-compose up --build
|
||||
```
|
||||
Таким образом контейнеры будут подготовлены и запущены. Результат выполнения будет находится внутри директории докера. Расположение файлов data.txt и result.txt: `/var/lib/docker/volumes/balakhonov_danila_lab_2_result/_data/`
|
||||
|
||||
## Какие технологии были использованы?
|
||||
Для выполнения лабораторной работы номер 2 были применены такие технологии, как:
|
||||
- Dockerfile
|
||||
- Docker compose
|
||||
- Git
|
||||
- .NET SDK и F# в частности
|
||||
|
||||
Сервисы были написаны с использованием .NET SDK на языке F#.
|
||||
## Что делает лабораторная работа номер 2?
|
||||
Лабораторная работа номер 2 запускает два сервиса:
|
||||
|
||||
1. Сервис, который берёт из каталога `/var/data` случайный файл и перекладывает его в `/var/result/data.txt`
|
||||
2. Сервис, который ищет наибольшее число из файла `/var/result/data.txt` и сохраняет количество таких чисел из последовательности в `/var/result/result.txt`
|
||||
|
||||
Благодаря лабораторной работе номер 2 были получены навыки создания Dockerfile для развертывания проектов в контейнерах, а также их связки с помощью docker-compose.yaml.
|
22
balakhonov_danila_lab_2/docker-compose.yaml
Normal file
22
balakhonov_danila_lab_2/docker-compose.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
services:
|
||||
app1:
|
||||
build: ./sigma_app_1/
|
||||
volumes:
|
||||
# Создание папки /var/data внутри контейнера
|
||||
# И копирование файлов из ./files в эту папку
|
||||
- ./files:/var/data
|
||||
# Создание папки /var/result внутри контейнера
|
||||
# А также папки result внутри директории докера
|
||||
- result:/var/result
|
||||
app2:
|
||||
build: ./skibidi_app_2/
|
||||
# Указано, что пока не запуститься app1, app2 не запустится
|
||||
# Он ЗАВИСИТ от app1 (depends on (с англ.) - зависит от)
|
||||
depends_on:
|
||||
- app1
|
||||
volumes:
|
||||
- result:/var/result
|
||||
volumes:
|
||||
# Указывается, что будет создана папка result
|
||||
# внутри директории докера
|
||||
result:
|
323
balakhonov_danila_lab_2/files/1.txt
Normal file
323
balakhonov_danila_lab_2/files/1.txt
Normal file
@ -0,0 +1,323 @@
|
||||
245
|
||||
678
|
||||
12
|
||||
987
|
||||
456
|
||||
234
|
||||
789
|
||||
345
|
||||
678
|
||||
123
|
||||
456
|
||||
789
|
||||
234
|
||||
567
|
||||
890
|
||||
12
|
||||
34
|
||||
56
|
||||
78
|
||||
90
|
||||
123
|
||||
456
|
||||
789
|
||||
321
|
||||
654
|
||||
987
|
||||
432
|
||||
876
|
||||
543
|
||||
210
|
||||
987
|
||||
654
|
||||
321
|
||||
456
|
||||
789
|
||||
12
|
||||
34
|
||||
56
|
||||
78
|
||||
90
|
||||
123
|
||||
456
|
||||
789
|
||||
234
|
||||
567
|
||||
890
|
||||
123
|
||||
456
|
||||
789
|
||||
987
|
||||
654
|
||||
321
|
||||
432
|
||||
876
|
||||
543
|
||||
210
|
||||
678
|
||||
345
|
||||
678
|
||||
123
|
||||
456
|
||||
789
|
||||
234
|
||||
567
|
||||
890
|
||||
12
|
||||
34
|
||||
56
|
||||
78
|
||||
90
|
||||
123
|
||||
456
|
||||
789
|
||||
321
|
||||
654
|
||||
987
|
||||
432
|
||||
876
|
||||
543
|
||||
210
|
||||
678
|
||||
345
|
||||
678
|
||||
123
|
||||
456
|
||||
789
|
||||
234
|
||||
567
|
||||
890
|
||||
12
|
||||
34
|
||||
56
|
||||
78
|
||||
90
|
||||
123
|
||||
456
|
||||
789
|
||||
321
|
||||
654
|
||||
987
|
||||
432
|
||||
876
|
||||
543
|
||||
210
|
||||
678
|
||||
345
|
||||
678
|
||||
123
|
||||
456
|
||||
789
|
||||
234
|
||||
567
|
||||
890
|
||||
12
|
||||
34
|
||||
56
|
||||
78
|
||||
90
|
||||
123
|
||||
456
|
||||
789
|
||||
321
|
||||
654
|
||||
987
|
||||
432
|
||||
876
|
||||
543
|
||||
210
|
||||
678
|
||||
345
|
||||
678
|
||||
123
|
||||
456
|
||||
789
|
||||
234
|
||||
567
|
||||
890
|
||||
12
|
||||
34
|
||||
56
|
||||
78
|
||||
90
|
||||
123
|
||||
456
|
||||
789
|
||||
321
|
||||
654
|
||||
987
|
||||
432
|
||||
876
|
||||
543
|
||||
210
|
||||
678
|
||||
345
|
||||
678
|
||||
123
|
||||
456
|
||||
789
|
||||
234
|
||||
567
|
||||
890
|
||||
12
|
||||
34
|
||||
56
|
||||
78
|
||||
90
|
||||
123
|
||||
456
|
||||
789
|
||||
321
|
||||
654
|
||||
987
|
||||
432
|
||||
876
|
||||
543
|
||||
210
|
||||
678
|
||||
345
|
||||
678
|
||||
123
|
||||
456
|
||||
789
|
||||
234
|
||||
567
|
||||
890
|
||||
12
|
||||
34
|
||||
56
|
||||
78
|
||||
90
|
||||
123
|
||||
456
|
||||
789
|
||||
321
|
||||
654
|
||||
987
|
||||
432
|
||||
876
|
||||
543
|
||||
210
|
||||
678
|
||||
345
|
||||
678
|
||||
123
|
||||
456
|
||||
789
|
||||
234
|
||||
567
|
||||
890
|
||||
12
|
||||
34
|
||||
56
|
||||
78
|
||||
90
|
||||
123
|
||||
456
|
||||
789
|
||||
321
|
||||
654
|
||||
987
|
||||
432
|
||||
876
|
||||
543
|
||||
210
|
||||
678
|
||||
345
|
||||
678
|
||||
123
|
||||
456
|
||||
789
|
||||
234
|
||||
567
|
||||
890
|
||||
12
|
||||
34
|
||||
56
|
||||
78
|
||||
90
|
||||
123
|
||||
456
|
||||
789
|
||||
321
|
||||
654
|
||||
987
|
||||
432
|
||||
876
|
||||
543
|
||||
210
|
||||
678
|
||||
345
|
||||
678
|
||||
123
|
||||
456
|
||||
789
|
||||
234
|
||||
567
|
||||
890
|
||||
12
|
||||
34
|
||||
56
|
||||
78
|
||||
90
|
||||
123
|
||||
456
|
||||
789
|
||||
321
|
||||
654
|
||||
987
|
||||
432
|
||||
876
|
||||
543
|
||||
210
|
||||
678
|
||||
345
|
||||
678
|
||||
123
|
||||
456
|
||||
789
|
||||
234
|
||||
567
|
||||
890
|
||||
12
|
||||
34
|
||||
56
|
||||
78
|
||||
90
|
||||
123
|
||||
456
|
||||
789
|
||||
321
|
||||
654
|
||||
987
|
||||
432
|
||||
876
|
||||
543
|
||||
210
|
||||
678
|
||||
345
|
||||
678
|
||||
123
|
||||
456
|
||||
789
|
||||
234
|
||||
567
|
||||
890
|
||||
12
|
||||
34
|
||||
56
|
||||
78
|
||||
90
|
||||
123
|
||||
456
|
||||
789
|
||||
321
|
||||
654
|
||||
987
|
||||
432
|
||||
876
|
||||
543
|
||||
210
|
||||
678
|
||||
345
|
||||
678
|
642
balakhonov_danila_lab_2/files/2.txt
Normal file
642
balakhonov_danila_lab_2/files/2.txt
Normal file
@ -0,0 +1,642 @@
|
||||
873
|
||||
62
|
||||
455
|
||||
879
|
||||
235
|
||||
941
|
||||
267
|
||||
811
|
||||
174
|
||||
517
|
||||
382
|
||||
399
|
||||
460
|
||||
221
|
||||
640
|
||||
915
|
||||
384
|
||||
622
|
||||
897
|
||||
212
|
||||
798
|
||||
109
|
||||
477
|
||||
546
|
||||
29
|
||||
995
|
||||
678
|
||||
342
|
||||
135
|
||||
804
|
||||
890
|
||||
453
|
||||
726
|
||||
891
|
||||
664
|
||||
290
|
||||
872
|
||||
190
|
||||
526
|
||||
304
|
||||
12
|
||||
587
|
||||
234
|
||||
753
|
||||
980
|
||||
197
|
||||
824
|
||||
579
|
||||
458
|
||||
15
|
||||
999
|
||||
614
|
||||
704
|
||||
205
|
||||
860
|
||||
537
|
||||
842
|
||||
491
|
||||
668
|
||||
210
|
||||
920
|
||||
477
|
||||
811
|
||||
350
|
||||
731
|
||||
95
|
||||
639
|
||||
287
|
||||
127
|
||||
423
|
||||
1000
|
||||
394
|
||||
521
|
||||
8
|
||||
267
|
||||
154
|
||||
431
|
||||
715
|
||||
266
|
||||
834
|
||||
173
|
||||
268
|
||||
947
|
||||
582
|
||||
157
|
||||
367
|
||||
882
|
||||
737
|
||||
305
|
||||
472
|
||||
481
|
||||
651
|
||||
960
|
||||
843
|
||||
701
|
||||
122
|
||||
514
|
||||
92
|
||||
658
|
||||
884
|
||||
371
|
||||
458
|
||||
637
|
||||
620
|
||||
793
|
||||
285
|
||||
611
|
||||
785
|
||||
495
|
||||
822
|
||||
849
|
||||
708
|
||||
592
|
||||
465
|
||||
469
|
||||
78
|
||||
734
|
||||
667
|
||||
606
|
||||
241
|
||||
666
|
||||
474
|
||||
569
|
||||
543
|
||||
918
|
||||
68
|
||||
906
|
||||
123
|
||||
501
|
||||
330
|
||||
947
|
||||
111
|
||||
365
|
||||
734
|
||||
249
|
||||
429
|
||||
296
|
||||
16
|
||||
511
|
||||
974
|
||||
317
|
||||
764
|
||||
230
|
||||
542
|
||||
920
|
||||
821
|
||||
718
|
||||
281
|
||||
556
|
||||
575
|
||||
900
|
||||
632
|
||||
720
|
||||
462
|
||||
88
|
||||
275
|
||||
403
|
||||
100
|
||||
418
|
||||
684
|
||||
600
|
||||
119
|
||||
863
|
||||
781
|
||||
225
|
||||
971
|
||||
670
|
||||
80
|
||||
643
|
||||
220
|
||||
176
|
||||
588
|
||||
58
|
||||
202
|
||||
850
|
||||
537
|
||||
934
|
||||
748
|
||||
378
|
||||
817
|
||||
505
|
||||
696
|
||||
21
|
||||
630
|
||||
324
|
||||
117
|
||||
420
|
||||
257
|
||||
493
|
||||
826
|
||||
688
|
||||
305
|
||||
772
|
||||
654
|
||||
927
|
||||
208
|
||||
525
|
||||
511
|
||||
256
|
||||
650
|
||||
447
|
||||
163
|
||||
99
|
||||
74
|
||||
99
|
||||
487
|
||||
306
|
||||
754
|
||||
510
|
||||
132
|
||||
201
|
||||
392
|
||||
785
|
||||
778
|
||||
512
|
||||
258
|
||||
904
|
||||
932
|
||||
589
|
||||
694
|
||||
204
|
||||
884
|
||||
110
|
||||
673
|
||||
152
|
||||
649
|
||||
295
|
||||
387
|
||||
758
|
||||
927
|
||||
538
|
||||
619
|
||||
904
|
||||
651
|
||||
174
|
||||
712
|
||||
104
|
||||
641
|
||||
474
|
||||
198
|
||||
322
|
||||
764
|
||||
204
|
||||
407
|
||||
550
|
||||
42
|
||||
879
|
||||
716
|
||||
368
|
||||
316
|
||||
43
|
||||
600
|
||||
893
|
||||
370
|
||||
137
|
||||
631
|
||||
244
|
||||
571
|
||||
663
|
||||
551
|
||||
907
|
||||
211
|
||||
166
|
||||
746
|
||||
583
|
||||
708
|
||||
771
|
||||
215
|
||||
90
|
||||
829
|
||||
653
|
||||
494
|
||||
563
|
||||
334
|
||||
794
|
||||
745
|
||||
936
|
||||
718
|
||||
126
|
||||
923
|
||||
451
|
||||
668
|
||||
966
|
||||
532
|
||||
935
|
||||
886
|
||||
646
|
||||
75
|
||||
858
|
||||
693
|
||||
859
|
||||
284
|
||||
315
|
||||
679
|
||||
133
|
||||
878
|
||||
292
|
||||
340
|
||||
716
|
||||
128
|
||||
250
|
||||
554
|
||||
482
|
||||
789
|
||||
677
|
||||
308
|
||||
494
|
||||
931
|
||||
144
|
||||
337
|
||||
982
|
||||
713
|
||||
535
|
||||
893
|
||||
939
|
||||
932
|
||||
905
|
||||
805
|
||||
236
|
||||
991
|
||||
781
|
||||
686
|
||||
572
|
||||
951
|
||||
335
|
||||
58
|
||||
303
|
||||
335
|
||||
145
|
||||
608
|
||||
794
|
||||
862
|
||||
792
|
||||
619
|
||||
54
|
||||
292
|
||||
878
|
||||
585
|
||||
293
|
||||
959
|
||||
379
|
||||
20
|
||||
484
|
||||
144
|
||||
678
|
||||
67
|
||||
363
|
||||
946
|
||||
566
|
||||
106
|
||||
442
|
||||
820
|
||||
562
|
||||
109
|
||||
201
|
||||
759
|
||||
481
|
||||
289
|
||||
698
|
||||
25
|
||||
847
|
||||
648
|
||||
733
|
||||
613
|
||||
776
|
||||
989
|
||||
257
|
||||
864
|
||||
32
|
||||
703
|
||||
989
|
||||
465
|
||||
103
|
||||
963
|
||||
515
|
||||
829
|
||||
30
|
||||
303
|
||||
926
|
||||
159
|
||||
586
|
||||
268
|
||||
852
|
||||
953
|
||||
321
|
||||
306
|
||||
978
|
||||
909
|
||||
177
|
||||
835
|
||||
458
|
||||
994
|
||||
885
|
||||
213
|
||||
775
|
||||
385
|
||||
598
|
||||
267
|
||||
754
|
||||
448
|
||||
1000
|
||||
555
|
||||
354
|
||||
657
|
||||
231
|
||||
979
|
||||
265
|
||||
374
|
||||
68
|
||||
197
|
||||
953
|
||||
648
|
||||
153
|
||||
523
|
||||
761
|
||||
827
|
||||
819
|
||||
63
|
||||
782
|
||||
766
|
||||
882
|
||||
404
|
||||
258
|
||||
672
|
||||
883
|
||||
80
|
||||
111
|
||||
212
|
||||
681
|
||||
812
|
||||
911
|
||||
837
|
||||
194
|
||||
161
|
||||
143
|
||||
427
|
||||
981
|
||||
132
|
||||
357
|
||||
605
|
||||
810
|
||||
414
|
||||
20
|
||||
210
|
||||
772
|
||||
882
|
||||
313
|
||||
186
|
||||
578
|
||||
154
|
||||
523
|
||||
339
|
||||
383
|
||||
903
|
||||
29
|
||||
172
|
||||
62
|
||||
314
|
||||
491
|
||||
289
|
||||
550
|
||||
521
|
||||
327
|
||||
794
|
||||
299
|
||||
678
|
||||
769
|
||||
415
|
||||
266
|
||||
77
|
||||
33
|
||||
438
|
||||
233
|
||||
160
|
||||
11
|
||||
523
|
||||
623
|
||||
254
|
||||
29
|
||||
327
|
||||
924
|
||||
938
|
||||
588
|
||||
444
|
||||
976
|
||||
547
|
||||
775
|
||||
638
|
||||
35
|
||||
23
|
||||
203
|
||||
203
|
||||
927
|
||||
149
|
||||
198
|
||||
150
|
||||
370
|
||||
728
|
||||
775
|
||||
818
|
||||
768
|
||||
99
|
||||
40
|
||||
969
|
||||
435
|
||||
49
|
||||
276
|
||||
360
|
||||
964
|
||||
277
|
||||
283
|
||||
825
|
||||
479
|
||||
331
|
||||
471
|
||||
381
|
||||
652
|
||||
264
|
||||
564
|
||||
891
|
||||
638
|
||||
470
|
||||
291
|
||||
101
|
||||
143
|
||||
93
|
||||
663
|
||||
328
|
||||
841
|
||||
881
|
||||
94
|
||||
327
|
||||
2
|
||||
628
|
||||
474
|
||||
905
|
||||
545
|
||||
421
|
||||
453
|
||||
282
|
||||
276
|
||||
24
|
||||
655
|
||||
295
|
||||
48
|
||||
102
|
||||
49
|
||||
676
|
||||
187
|
||||
773
|
||||
169
|
||||
170
|
||||
165
|
||||
405
|
||||
348
|
||||
4
|
||||
654
|
||||
276
|
||||
343
|
||||
153
|
||||
381
|
||||
756
|
||||
753
|
||||
816
|
||||
474
|
||||
186
|
||||
652
|
||||
67
|
||||
689
|
||||
69
|
||||
920
|
||||
880
|
||||
363
|
||||
637
|
||||
524
|
||||
171
|
||||
753
|
||||
12
|
||||
634
|
||||
648
|
||||
668
|
||||
220
|
||||
408
|
||||
348
|
||||
887
|
||||
341
|
||||
738
|
||||
681
|
||||
408
|
||||
377
|
||||
693
|
||||
234
|
||||
83
|
||||
982
|
||||
417
|
||||
222
|
||||
322
|
||||
253
|
||||
494
|
||||
868
|
||||
951
|
||||
344
|
||||
60
|
||||
23
|
||||
41
|
||||
99
|
||||
944
|
||||
723
|
||||
156
|
||||
813
|
||||
5
|
||||
44
|
||||
62
|
||||
899
|
||||
835
|
||||
482
|
||||
469
|
||||
157
|
||||
637
|
||||
295
|
||||
929
|
||||
992
|
||||
234
|
||||
66
|
||||
31
|
||||
170
|
||||
333
|
||||
92
|
||||
185
|
||||
117
|
||||
627
|
||||
82
|
||||
292
|
||||
796
|
||||
840
|
||||
768
|
||||
532
|
||||
981
|
||||
300
|
||||
125
|
||||
958
|
||||
4
|
489
balakhonov_danila_lab_2/files/3.txt
Normal file
489
balakhonov_danila_lab_2/files/3.txt
Normal file
@ -0,0 +1,489 @@
|
||||
522
|
||||
173
|
||||
815
|
||||
671
|
||||
284
|
||||
903
|
||||
477
|
||||
639
|
||||
732
|
||||
143
|
||||
928
|
||||
564
|
||||
812
|
||||
109
|
||||
397
|
||||
249
|
||||
868
|
||||
301
|
||||
848
|
||||
376
|
||||
794
|
||||
99
|
||||
506
|
||||
217
|
||||
645
|
||||
12
|
||||
187
|
||||
930
|
||||
811
|
||||
583
|
||||
684
|
||||
455
|
||||
94
|
||||
499
|
||||
118
|
||||
722
|
||||
603
|
||||
267
|
||||
772
|
||||
947
|
||||
845
|
||||
210
|
||||
495
|
||||
632
|
||||
372
|
||||
930
|
||||
908
|
||||
546
|
||||
327
|
||||
685
|
||||
883
|
||||
235
|
||||
613
|
||||
579
|
||||
762
|
||||
491
|
||||
328
|
||||
672
|
||||
156
|
||||
739
|
||||
1000
|
||||
421
|
||||
731
|
||||
215
|
||||
867
|
||||
610
|
||||
847
|
||||
732
|
||||
204
|
||||
411
|
||||
515
|
||||
150
|
||||
438
|
||||
651
|
||||
174
|
||||
590
|
||||
725
|
||||
963
|
||||
530
|
||||
889
|
||||
577
|
||||
694
|
||||
417
|
||||
261
|
||||
767
|
||||
480
|
||||
934
|
||||
125
|
||||
558
|
||||
282
|
||||
899
|
||||
96
|
||||
653
|
||||
908
|
||||
303
|
||||
774
|
||||
617
|
||||
407
|
||||
482
|
||||
538
|
||||
239
|
||||
472
|
||||
766
|
||||
118
|
||||
920
|
||||
206
|
||||
797
|
||||
420
|
||||
853
|
||||
205
|
||||
340
|
||||
123
|
||||
387
|
||||
497
|
||||
640
|
||||
24
|
||||
999
|
||||
476
|
||||
77
|
||||
920
|
||||
382
|
||||
405
|
||||
55
|
||||
834
|
||||
371
|
||||
167
|
||||
290
|
||||
300
|
||||
611
|
||||
53
|
||||
470
|
||||
81
|
||||
232
|
||||
14
|
||||
451
|
||||
678
|
||||
623
|
||||
564
|
||||
787
|
||||
99
|
||||
648
|
||||
873
|
||||
803
|
||||
888
|
||||
504
|
||||
186
|
||||
256
|
||||
405
|
||||
102
|
||||
999
|
||||
673
|
||||
721
|
||||
434
|
||||
814
|
||||
305
|
||||
582
|
||||
436
|
||||
90
|
||||
774
|
||||
216
|
||||
706
|
||||
855
|
||||
702
|
||||
307
|
||||
59
|
||||
835
|
||||
812
|
||||
234
|
||||
736
|
||||
168
|
||||
523
|
||||
219
|
||||
868
|
||||
365
|
||||
294
|
||||
500
|
||||
207
|
||||
927
|
||||
450
|
||||
521
|
||||
851
|
||||
703
|
||||
992
|
||||
327
|
||||
916
|
||||
554
|
||||
846
|
||||
658
|
||||
88
|
||||
659
|
||||
628
|
||||
764
|
||||
84
|
||||
45
|
||||
10
|
||||
870
|
||||
779
|
||||
320
|
||||
882
|
||||
942
|
||||
93
|
||||
792
|
||||
836
|
||||
137
|
||||
489
|
||||
862
|
||||
391
|
||||
337
|
||||
887
|
||||
114
|
||||
237
|
||||
178
|
||||
874
|
||||
569
|
||||
135
|
||||
919
|
||||
931
|
||||
231
|
||||
50
|
||||
995
|
||||
215
|
||||
658
|
||||
139
|
||||
484
|
||||
292
|
||||
903
|
||||
113
|
||||
755
|
||||
333
|
||||
829
|
||||
942
|
||||
360
|
||||
172
|
||||
689
|
||||
42
|
||||
127
|
||||
799
|
||||
191
|
||||
455
|
||||
533
|
||||
234
|
||||
15
|
||||
404
|
||||
636
|
||||
373
|
||||
884
|
||||
921
|
||||
977
|
||||
113
|
||||
227
|
||||
703
|
||||
173
|
||||
297
|
||||
440
|
||||
604
|
||||
575
|
||||
971
|
||||
855
|
||||
82
|
||||
252
|
||||
589
|
||||
276
|
||||
826
|
||||
206
|
||||
166
|
||||
482
|
||||
375
|
||||
174
|
||||
612
|
||||
818
|
||||
854
|
||||
832
|
||||
809
|
||||
569
|
||||
306
|
||||
993
|
||||
931
|
||||
289
|
||||
148
|
||||
943
|
||||
421
|
||||
784
|
||||
441
|
||||
536
|
||||
426
|
||||
548
|
||||
49
|
||||
687
|
||||
415
|
||||
505
|
||||
951
|
||||
583
|
||||
368
|
||||
172
|
||||
974
|
||||
47
|
||||
173
|
||||
570
|
||||
264
|
||||
754
|
||||
701
|
||||
693
|
||||
796
|
||||
914
|
||||
809
|
||||
310
|
||||
512
|
||||
725
|
||||
963
|
||||
829
|
||||
614
|
||||
220
|
||||
410
|
||||
631
|
||||
860
|
||||
270
|
||||
158
|
||||
168
|
||||
595
|
||||
62
|
||||
715
|
||||
913
|
||||
517
|
||||
157
|
||||
5
|
||||
660
|
||||
274
|
||||
414
|
||||
139
|
||||
300
|
||||
698
|
||||
675
|
||||
263
|
||||
872
|
||||
292
|
||||
142
|
||||
375
|
||||
696
|
||||
895
|
||||
302
|
||||
75
|
||||
576
|
||||
899
|
||||
524
|
||||
362
|
||||
721
|
||||
916
|
||||
883
|
||||
347
|
||||
980
|
||||
29
|
||||
392
|
||||
839
|
||||
971
|
||||
593
|
||||
708
|
||||
804
|
||||
678
|
||||
234
|
||||
719
|
||||
659
|
||||
418
|
||||
914
|
||||
437
|
||||
550
|
||||
418
|
||||
576
|
||||
776
|
||||
293
|
||||
737
|
||||
348
|
||||
292
|
||||
48
|
||||
975
|
||||
547
|
||||
205
|
||||
831
|
||||
783
|
||||
587
|
||||
657
|
||||
132
|
||||
733
|
||||
53
|
||||
700
|
||||
785
|
||||
292
|
||||
332
|
||||
771
|
||||
849
|
||||
994
|
||||
905
|
||||
460
|
||||
420
|
||||
923
|
||||
663
|
||||
134
|
||||
658
|
||||
673
|
||||
618
|
||||
779
|
||||
951
|
||||
244
|
||||
425
|
||||
312
|
||||
436
|
||||
878
|
||||
538
|
||||
236
|
||||
805
|
||||
457
|
||||
897
|
||||
799
|
||||
134
|
||||
469
|
||||
56
|
||||
724
|
||||
370
|
||||
521
|
||||
654
|
||||
20
|
||||
260
|
||||
315
|
||||
525
|
||||
501
|
||||
433
|
||||
90
|
||||
368
|
||||
192
|
||||
162
|
||||
198
|
||||
65
|
||||
652
|
||||
613
|
||||
222
|
||||
160
|
||||
76
|
||||
755
|
||||
541
|
||||
305
|
||||
257
|
||||
669
|
||||
179
|
||||
849
|
||||
878
|
||||
249
|
||||
224
|
||||
4
|
||||
1
|
||||
860
|
||||
967
|
||||
738
|
||||
712
|
||||
281
|
||||
834
|
||||
908
|
||||
774
|
||||
964
|
||||
880
|
||||
902
|
||||
234
|
||||
635
|
||||
138
|
||||
305
|
||||
532
|
||||
585
|
||||
956
|
||||
68
|
||||
21
|
||||
278
|
||||
639
|
||||
622
|
||||
473
|
||||
769
|
||||
161
|
||||
580
|
||||
285
|
||||
204
|
||||
410
|
||||
115
|
||||
430
|
||||
953
|
||||
968
|
||||
593
|
||||
703
|
||||
704
|
||||
469
|
||||
835
|
||||
623
|
||||
991
|
4
balakhonov_danila_lab_2/sigma_app_1/.dockerignore
Normal file
4
balakhonov_danila_lab_2/sigma_app_1/.dockerignore
Normal file
@ -0,0 +1,4 @@
|
||||
bin/
|
||||
obj/
|
||||
Dockerfile
|
||||
README.md
|
484
balakhonov_danila_lab_2/sigma_app_1/.gitignore
vendored
Normal file
484
balakhonov_danila_lab_2/sigma_app_1/.gitignore
vendored
Normal file
@ -0,0 +1,484 @@
|
||||
## 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
|
14
balakhonov_danila_lab_2/sigma_app_1/Dockerfile
Normal file
14
balakhonov_danila_lab_2/sigma_app_1/Dockerfile
Normal file
@ -0,0 +1,14 @@
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
WORKDIR /App
|
||||
|
||||
# Copy everything
|
||||
COPY . ./
|
||||
# Restore as distinct layers
|
||||
RUN dotnet restore
|
||||
# Build and publish a release
|
||||
RUN dotnet publish -c Release -o out
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS runtime
|
||||
WORKDIR /App
|
||||
COPY --from=build /App/out .
|
||||
ENTRYPOINT ["dotnet", "sigma_app_1.dll"]
|
14
balakhonov_danila_lab_2/sigma_app_1/Program.fs
Normal file
14
balakhonov_danila_lab_2/sigma_app_1/Program.fs
Normal file
@ -0,0 +1,14 @@
|
||||
let PATH = @"/var/data/"
|
||||
let RESULT_PATH = @"/var/result/data.txt"
|
||||
|
||||
let getFiles(path: string): seq<string> =
|
||||
System.IO.Directory.EnumerateFiles(path)
|
||||
|
||||
let getRandFile(files: seq<string>) =
|
||||
let rand = System.Random()
|
||||
let index = rand.Next(Seq.length files)
|
||||
Seq.item index files
|
||||
|
||||
let files = getFiles(PATH)
|
||||
let randFile = getRandFile(files)
|
||||
System.IO.File.Copy(randFile, RESULT_PATH)
|
4
balakhonov_danila_lab_2/sigma_app_1/README.md
Normal file
4
balakhonov_danila_lab_2/sigma_app_1/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Первая программа лабораторной работы номер 2
|
||||
> Вариант 6
|
||||
>
|
||||
> Берёт из каталога `/var/data` случайный файл и перекладывает его в `/var/result/data.txt`
|
12
balakhonov_danila_lab_2/sigma_app_1/sigma_app_1.fsproj
Normal file
12
balakhonov_danila_lab_2/sigma_app_1/sigma_app_1.fsproj
Normal file
@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.fs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
4
balakhonov_danila_lab_2/skibidi_app_2/.dockerignore
Normal file
4
balakhonov_danila_lab_2/skibidi_app_2/.dockerignore
Normal file
@ -0,0 +1,4 @@
|
||||
bin/
|
||||
obj/
|
||||
Dockerfile
|
||||
README.md
|
484
balakhonov_danila_lab_2/skibidi_app_2/.gitignore
vendored
Normal file
484
balakhonov_danila_lab_2/skibidi_app_2/.gitignore
vendored
Normal file
@ -0,0 +1,484 @@
|
||||
## 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
|
14
balakhonov_danila_lab_2/skibidi_app_2/Dockerfile
Normal file
14
balakhonov_danila_lab_2/skibidi_app_2/Dockerfile
Normal file
@ -0,0 +1,14 @@
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
WORKDIR /App
|
||||
|
||||
# Copy everything
|
||||
COPY . ./
|
||||
# Restore as distinct layers
|
||||
RUN dotnet restore
|
||||
# Build and publish a release
|
||||
RUN dotnet publish -c Release -o out
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS runtime
|
||||
WORKDIR /App
|
||||
COPY --from=build /App/out .
|
||||
ENTRYPOINT ["dotnet", "skibidi_app_2.dll"]
|
16
balakhonov_danila_lab_2/skibidi_app_2/Program.fs
Normal file
16
balakhonov_danila_lab_2/skibidi_app_2/Program.fs
Normal file
@ -0,0 +1,16 @@
|
||||
let INPUT_FILE = @"/var/result/data.txt"
|
||||
let OUTPUT_FILE = @"/var/result/result.txt"
|
||||
|
||||
let getNumbersFromFile(path: string): seq<int> =
|
||||
System.IO.File.ReadLines(path)
|
||||
|> Seq.map int
|
||||
|
||||
let getCountOfMaxNumber(numbers: seq<int>): int =
|
||||
numbers
|
||||
|> Seq.max
|
||||
|> fun maxNum -> Seq.filter ((=) maxNum) numbers
|
||||
|> Seq.length
|
||||
|
||||
let numbers = getNumbersFromFile(INPUT_FILE)
|
||||
let count = getCountOfMaxNumber(numbers)
|
||||
System.IO.File.WriteAllText(OUTPUT_FILE, string count)
|
4
balakhonov_danila_lab_2/skibidi_app_2/README.md
Normal file
4
balakhonov_danila_lab_2/skibidi_app_2/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Вторая программа лабораторной работы номер 2
|
||||
> Вариант 3
|
||||
>
|
||||
> Ищет набольшее число из файла `/var/result/data.txt` и сохраняет количество таких чисел из последовательности в `/var/result/result.txt`
|
12
balakhonov_danila_lab_2/skibidi_app_2/skibidi_app_2.fsproj
Normal file
12
balakhonov_danila_lab_2/skibidi_app_2/skibidi_app_2.fsproj
Normal file
@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.fs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
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
|
35
bogdanov_dmitry_lab_1/README.md
Normal file
35
bogdanov_dmitry_lab_1/README.md
Normal file
@ -0,0 +1,35 @@
|
||||
# Лабораторная работа №1
|
||||
|
||||
## Богданов Дмитрий ПИбд-42
|
||||
|
||||
### Для выполнения были развернуты следующие сервисы:
|
||||
|
||||
* PostgreSQL - база данных
|
||||
* Mediawiki - движок вики
|
||||
* Gitea - движок гита
|
||||
|
||||
### С использованием следующих технологий:
|
||||
|
||||
* git
|
||||
* docker
|
||||
* docker-compose
|
||||
|
||||
|
||||
### Запуск лабораторной:
|
||||
Необходимо перейти в папку с файлом docker-compose.yaml и ввести следующую команду:
|
||||
```
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
## Результат запуска:
|
||||
```
|
||||
[+] Running 4/4
|
||||
✔ Network bogdanov_dmitry_lab_1_default Created 0.0s
|
||||
✔ Container bogdanov_dmitry_lab_1-mediawiki-1 Started 0.7s
|
||||
✔ Container bogdanov_dmitry_lab_1-git-1 Started 0.8s
|
||||
✔ Container bogdanov_dmitry_lab_1-db-1 Started 0.7s
|
||||
```
|
||||
|
||||
## Видео с результатом запуска:
|
||||
|
||||
Видео можно посмотреть по данной [ссылке](https://drive.google.com/file/d/1TES58HIeCnnKbtwWgED2oig4N7plBmol/view).
|
40
bogdanov_dmitry_lab_1/docker-compose.yaml
Normal file
40
bogdanov_dmitry_lab_1/docker-compose.yaml
Normal file
@ -0,0 +1,40 @@
|
||||
services:
|
||||
# PostgreSQL
|
||||
db:
|
||||
# Образ контейнера
|
||||
image: postgres
|
||||
# Перезапуск при падении
|
||||
restart: always
|
||||
# Порт для подключения
|
||||
ports:
|
||||
- 5432:5432
|
||||
# Каталог с данными. Каталог компьютера:каталог контейнера
|
||||
volumes:
|
||||
- ./volumes/postgres:/var/lib/postgresql/data
|
||||
# Переменные среды для определения хотя бы одного пользователя при запуске
|
||||
environment:
|
||||
- POSTGRES_USER=admin
|
||||
- POSTGRES_PASSWORD=admin
|
||||
# Mediawiki
|
||||
mediawiki:
|
||||
# Образ
|
||||
image: mediawiki
|
||||
# Перезапуск при падении
|
||||
restart: always
|
||||
# Порт для подключения
|
||||
ports:
|
||||
- 8080:80
|
||||
# Каталоги
|
||||
volumes:
|
||||
- ./volumes/mediawiki:/var/www/html/images
|
||||
# Gitea
|
||||
git:
|
||||
image: gitea/gitea:latest
|
||||
restart: always
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "222:22"
|
||||
volumes:
|
||||
- ./volumes/gitea:/data
|
||||
- ./volumes/timezone:/etc/timezone:ro
|
||||
- ./volumes/localtime:/etc/localtime:ro
|
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);
|
||||
}
|
||||
}
|
58
borschevskaya_anna_lab_3/README.md
Normal file
58
borschevskaya_anna_lab_3/README.md
Normal file
@ -0,0 +1,58 @@
|
||||
# Отчет. Лабораторная работа 3
|
||||
|
||||
## Описание
|
||||
В рамках лабораторной работы № 3 были реализованы два сервиса (Java + Spring), осуществляющие CRUD-операции над сущностями.
|
||||
|
||||
Модель данных следующая:
|
||||
|
||||
Сущность "Компания" (сервис company)
|
||||
- идентификатор компании
|
||||
- название
|
||||
- адрес
|
||||
|
||||
Сущность "Вакансия" (сервис vacancy)
|
||||
- идентификатор вакансии
|
||||
- название
|
||||
- описание
|
||||
- нижняя граница зарплаты
|
||||
- верхняя граница зарплаты
|
||||
- идентификатор компании
|
||||
|
||||
Компания с вакансией связана как "один ко многим".
|
||||
|
||||
Каждый из сервисов имеет API с пятью эндпоинтами. При этом в сервисе vacancy при запросе вакансии по id происходит
|
||||
дополнительный запрос в сервис company для получения информации по компании, связанной с вакансией.
|
||||
Происходит это взаимодействие с помощью библиотеки OpenFeign, которая "под капотом" использует HttpClient.
|
||||
|
||||
В качестве хранилища данных использовалась СУБД Postgres. У каждого сервиса своя база данных в поднятой СУБД.
|
||||
Для создания схемы БД была использована библиотека Flyway, которая применила написанные миграции при старте приложения.
|
||||
|
||||
Запросы к сервисам проксирует шлюз на основе Nginx. Для этого перед запуском nginx был описан конфигурационный файл nginx.conf,
|
||||
в котором описан прослушиваемый порт и название сервера (в блоке server), маршруты до микросервисов и параметры проксирования (в блоке location).
|
||||
|
||||
Таким образом, с помощью Docker Compose были подняты сервисы:
|
||||
- company
|
||||
- vacancy
|
||||
- postgres
|
||||
- nginx
|
||||
## Как запустить
|
||||
Для того, чтобы запустить сервисы, необходимо выполнить следующие действия:
|
||||
1. Установить и запустить Docker Engine или Docker Desktop
|
||||
2. Через консоль перейти в папку, в которой расположен файл docker-compose.yml
|
||||
3. Выполнить команду:
|
||||
```
|
||||
docker compose up --build
|
||||
```
|
||||
В случае успешного запуска всех контейнеров в консоли будет выведено следующее сообщение:
|
||||
```
|
||||
[+] Running 5/5
|
||||
✔ Network borschevskaya_anna_lab_3_default Created 0.0s
|
||||
✔ Container postgres Started 0.6s
|
||||
✔ Container vacancy Started 1.1s
|
||||
✔ Container company Started 0.9s
|
||||
✔ Container borschevskaya_anna_lab_3-nginx-1 Started
|
||||
```
|
||||
Далее можно осуществлять запросы к сервисам по адресу http://localhost/{location}, где часть пути location меняется в зависимости от сервиса и запроса.
|
||||
## Видео-отчет
|
||||
Работоспособность лабораторной работы можно оценить в следующем [видео](https://disk.yandex.ru/i/KPNBfnlcgl1auw).
|
||||
Демонстрация взаимодействия с системой производится с применением сервиса Postman.
|
38
borschevskaya_anna_lab_3/company-service/.gitignore
vendored
Normal file
38
borschevskaya_anna_lab_3/company-service/.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
|
21
borschevskaya_anna_lab_3/company-service/Dockerfile
Normal file
21
borschevskaya_anna_lab_3/company-service/Dockerfile
Normal file
@ -0,0 +1,21 @@
|
||||
# Используем образ Maven для сборки
|
||||
FROM maven:3.8-eclipse-temurin-21-alpine AS build
|
||||
|
||||
# Устанавливаем рабочую директорию
|
||||
WORKDIR /app
|
||||
|
||||
# Копируем остальные исходные файлы
|
||||
COPY pom.xml .
|
||||
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"]
|
66
borschevskaya_anna_lab_3/company-service/pom.xml
Normal file
66
borschevskaya_anna_lab_3/company-service/pom.xml
Normal file
@ -0,0 +1,66 @@
|
||||
<?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.somecompany</groupId>
|
||||
<artifactId>company-service</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.2.3</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.30</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,12 @@
|
||||
package ru.somecompany;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class CompanyApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CompanyApplication.class, args);
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package ru.somecompany.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import ru.somecompany.domain.CompanyEntity;
|
||||
import ru.somecompany.domain.CreateCompanyRequest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@Validated
|
||||
@Tag(name = "company", description = "API для управления компаниями")
|
||||
public interface CompanyController {
|
||||
|
||||
@Operation(summary = "Получение всех компаний")
|
||||
@GetMapping(value = "/api/v1/company")
|
||||
List<CompanyEntity> getCompanies();
|
||||
|
||||
@Operation(summary = "Создание компании")
|
||||
@PostMapping(value = "/api/v1/company")
|
||||
CompanyEntity createCompany(@RequestBody @NotNull CreateCompanyRequest companyRequest);
|
||||
|
||||
@Operation(summary = "Получение информации о компании по id")
|
||||
@GetMapping(value = "/api/v1/company/{companyId}")
|
||||
CompanyEntity getCompany(@PathVariable UUID companyId);
|
||||
|
||||
@Operation(summary = "Редактирование компании")
|
||||
@PutMapping(value = "/api/v1/company/{companyId}")
|
||||
CompanyEntity updateCompany(@PathVariable UUID companyId,
|
||||
@RequestBody @NotNull CreateCompanyRequest companyRequest);
|
||||
|
||||
@Operation(summary = "Удалении компании по id")
|
||||
@DeleteMapping(value = "/api/v1/company/{companyId}")
|
||||
void deleteCompany(@PathVariable UUID companyId);
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package ru.somecompany.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ru.somecompany.domain.CompanyEntity;
|
||||
import ru.somecompany.domain.CreateCompanyRequest;
|
||||
import ru.somecompany.service.CompanyService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class CompanyControllerImpl implements CompanyController {
|
||||
|
||||
private final CompanyService companyService;
|
||||
|
||||
@Override
|
||||
public List<CompanyEntity> getCompanies() {
|
||||
return companyService.getCompanies();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyEntity createCompany(CreateCompanyRequest companyRequest) {
|
||||
return companyService.createCompany(companyRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyEntity getCompany(UUID companyId) {
|
||||
return companyService.getCompany(companyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyEntity updateCompany(UUID companyId, CreateCompanyRequest companyRequest) {
|
||||
return companyService.updateCompany(companyId, companyRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCompany(UUID companyId) {
|
||||
companyService.deleteCompany(companyId);
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package ru.somecompany.domain;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Builder
|
||||
@Table(name = "company")
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CompanyEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private UUID id;
|
||||
|
||||
@Column(name = "name", unique = true, nullable = false)
|
||||
private String name;
|
||||
|
||||
@Column(name = "address", unique = true, nullable = false)
|
||||
private String address;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package ru.somecompany.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class CreateCompanyRequest {
|
||||
|
||||
private String name;
|
||||
|
||||
private String address;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package ru.somecompany.exception;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
||||
|
||||
@Slf4j
|
||||
public abstract class AbstractWebExceptionHandler {
|
||||
|
||||
public static ResponseEntity<ResponseError> buildResponse(ErrorCode errorCode, HttpStatus status, String msg,
|
||||
boolean details, Throwable ex) {
|
||||
return buildResponse(errorCode.name(), status, msg, details, ex, LocalDateTime.now());
|
||||
}
|
||||
|
||||
public static ResponseEntity<ResponseError> buildResponse(String errorCode, HttpStatus status, String msg,
|
||||
boolean details, Throwable ex, LocalDateTime timestamp) {
|
||||
if (details) {
|
||||
log.error(msg, ex); // with stack-trace
|
||||
} else {
|
||||
var message = StringUtils.equals(msg, ex.getMessage()) ? msg : msg + ": " + ex.getMessage();
|
||||
if (status == NOT_FOUND) {
|
||||
log.warn(message);
|
||||
} else {
|
||||
log.error(message);
|
||||
}
|
||||
}
|
||||
|
||||
return ResponseEntity.status(status.value())
|
||||
.body(ResponseError.builder()
|
||||
.code(errorCode)
|
||||
.message(msg)
|
||||
.timestamp(timestamp)
|
||||
.status(status.value())
|
||||
.build());
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package ru.somecompany.exception;
|
||||
|
||||
public enum BasicError implements ErrorCode {
|
||||
NOT_FOUND
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package ru.somecompany.exception;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
@Getter
|
||||
public class CompanyAppRuntimeException extends RuntimeException {
|
||||
private final ErrorCode errorCode;
|
||||
private final HttpStatus status;
|
||||
private final boolean details;
|
||||
|
||||
public CompanyAppRuntimeException(ErrorCode errorCode, HttpStatus status, String message) {
|
||||
this(errorCode, status, message, null);
|
||||
}
|
||||
|
||||
public CompanyAppRuntimeException(ErrorCode errorCode, HttpStatus status, String message, Throwable error) {
|
||||
this(errorCode, status, message, true, error);
|
||||
}
|
||||
|
||||
public CompanyAppRuntimeException(ErrorCode errorCode, HttpStatus status, String message, boolean details, Throwable error) {
|
||||
super(message, error);
|
||||
this.errorCode = errorCode;
|
||||
this.status = status;
|
||||
this.details = details;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package ru.somecompany.exception;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface ErrorCode extends Serializable {
|
||||
|
||||
String name();
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package ru.somecompany.exception;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import static ru.somecompany.exception.BasicError.NOT_FOUND;
|
||||
|
||||
public class ResourceNotFoundException extends CompanyAppRuntimeException {
|
||||
|
||||
public ResourceNotFoundException(ErrorCode errorCode, String message) {
|
||||
this(errorCode, message, null);
|
||||
}
|
||||
|
||||
public ResourceNotFoundException(ErrorCode errorCode, String message, Throwable error) {
|
||||
super(errorCode, HttpStatus.NOT_FOUND, message, error);
|
||||
}
|
||||
|
||||
public static ResourceNotFoundException notFound(String message, Object... args) {
|
||||
return new ResourceNotFoundException(NOT_FOUND, String.format(message, args), null);
|
||||
}
|
||||
|
||||
public static ResourceNotFoundException notFound() {
|
||||
return new ResourceNotFoundException(NOT_FOUND, "Запрашиваемые данные не найдены", null);
|
||||
}
|
||||
|
||||
public static ResourceNotFoundException notFound(Throwable error) {
|
||||
return new ResourceNotFoundException(NOT_FOUND, error.getMessage(), error);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package ru.somecompany.exception;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ResponseError {
|
||||
@JsonProperty(required = true)
|
||||
private LocalDateTime timestamp;
|
||||
@JsonProperty(required = true)
|
||||
private Integer status;
|
||||
@JsonProperty(required = true)
|
||||
private String message;
|
||||
@JsonProperty(required = true)
|
||||
private String code;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package ru.somecompany.exception;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
@Slf4j
|
||||
@Getter
|
||||
@RestControllerAdvice
|
||||
@RequiredArgsConstructor
|
||||
public class WebExceptionHandler extends AbstractWebExceptionHandler {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@ExceptionHandler(CompanyAppRuntimeException.class)
|
||||
public ResponseEntity<ResponseError> handleException(CompanyAppRuntimeException ex) {
|
||||
return buildResponse(ex.getErrorCode(), ex.getStatus(), ex.getMessage(), ex.isDetails(), ex);
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package ru.somecompany.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import ru.somecompany.domain.CompanyEntity;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface CompanyRepository extends JpaRepository<CompanyEntity, UUID> {
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package ru.somecompany.service;
|
||||
|
||||
import ru.somecompany.domain.CompanyEntity;
|
||||
import ru.somecompany.domain.CreateCompanyRequest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface CompanyService {
|
||||
|
||||
List<CompanyEntity> getCompanies();
|
||||
|
||||
CompanyEntity createCompany(CreateCompanyRequest companyRequest);
|
||||
|
||||
CompanyEntity updateCompany(UUID companyId, CreateCompanyRequest companyRequest);
|
||||
|
||||
void deleteCompany(UUID companyId);
|
||||
|
||||
CompanyEntity getCompany(UUID companyId);
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package ru.somecompany.service;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.somecompany.domain.CompanyEntity;
|
||||
import ru.somecompany.domain.CreateCompanyRequest;
|
||||
import ru.somecompany.repository.CompanyRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static ru.somecompany.exception.ResourceNotFoundException.notFound;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CompanyServiceImpl implements CompanyService {
|
||||
|
||||
private final CompanyRepository companyRepository;
|
||||
|
||||
@Override
|
||||
public List<CompanyEntity> getCompanies() {
|
||||
return companyRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyEntity createCompany(CreateCompanyRequest companyRequest) {
|
||||
var entity = CompanyEntity.builder()
|
||||
.name(companyRequest.getName())
|
||||
.address(companyRequest.getAddress())
|
||||
.build();
|
||||
return companyRepository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyEntity updateCompany(UUID companyId, CreateCompanyRequest companyRequest) {
|
||||
var company = getById(companyId);
|
||||
company.setName(companyRequest.getName());
|
||||
company.setAddress(companyRequest.getAddress());
|
||||
return companyRepository.save(company);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCompany(UUID companyId) {
|
||||
var company = getById(companyId);
|
||||
companyRepository.delete(company);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyEntity getCompany(UUID companyId) {
|
||||
return getById(companyId);
|
||||
}
|
||||
|
||||
private CompanyEntity getById(UUID companyId) {
|
||||
return companyRepository.findById(companyId)
|
||||
.orElseThrow(() -> notFound("Компания не найдена"));
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
server:
|
||||
port: ${SERVER_PORT:8080}
|
||||
spring:
|
||||
application:
|
||||
name: company-app
|
||||
jpa:
|
||||
database: POSTGRESQL
|
||||
open-in-view: false
|
||||
show-sql: false
|
||||
hibernate:
|
||||
ddl-auto: none
|
||||
properties:
|
||||
hibernate:
|
||||
dialect: org.hibernate.dialect.PostgreSQLDialect
|
||||
datasource:
|
||||
url: ${DB_URL:jdbc:postgresql://postgres:5433/company}
|
||||
username: ${DB_USERNAME:postgres}
|
||||
password: ${DB_PASSWORD:postgres}
|
||||
driverClassName: org.postgresql.Driver
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
hikari:
|
||||
maximum-pool-size: 15
|
||||
minimum-idle: 4
|
||||
idle-timeout: 180000
|
||||
max-lifetime: 599000
|
||||
flyway:
|
||||
enabled: true
|
||||
locations: db/migration/
|
@ -0,0 +1,6 @@
|
||||
CREATE TABLE company (
|
||||
id UUID
|
||||
CONSTRAINT company_pk PRIMARY KEY,
|
||||
name VARCHAR(255) UNIQUE NOT NULL,
|
||||
address VARCHAR(255) NOT NULL
|
||||
);
|
43
borschevskaya_anna_lab_3/docker-compose.yml
Normal file
43
borschevskaya_anna_lab_3/docker-compose.yml
Normal file
@ -0,0 +1,43 @@
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:latest
|
||||
container_name: postgres
|
||||
environment:
|
||||
POSTGRES_USERNAME: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
PGDATA: "/var/lib/postgresql/data/pgdata"
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- ./postgres_data:/var/lib/postgresql/data/
|
||||
- ./init-database.sh:/docker-entrypoint-initdb.d/init-database.sh
|
||||
company:
|
||||
build: ./company-service
|
||||
container_name: company
|
||||
depends_on:
|
||||
- postgres
|
||||
environment:
|
||||
SERVER_PORT: 8080
|
||||
DB_URL: jdbc:postgresql://postgres:5432/company
|
||||
DB_USERNAME: postgres
|
||||
DB_PASSWORD: postgres
|
||||
vacancy:
|
||||
build: ./vacancy-service
|
||||
container_name: vacancy
|
||||
depends_on:
|
||||
- postgres
|
||||
environment:
|
||||
SERVER_PORT: 8080
|
||||
DB_URL: jdbc:postgresql://postgres:5432/vacancy
|
||||
DB_USERNAME: postgres
|
||||
DB_PASSWORD: postgres
|
||||
COMPANY_URL: http://nginx/
|
||||
nginx:
|
||||
image: nginx
|
||||
depends_on:
|
||||
- vacancy
|
||||
- company
|
||||
volumes:
|
||||
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
|
||||
ports:
|
||||
- 80:80
|
8
borschevskaya_anna_lab_3/init-database.sh
Normal file
8
borschevskaya_anna_lab_3/init-database.sh
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Создаем БД
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
|
||||
CREATE DATABASE company;
|
||||
CREATE DATABASE vacancy;
|
||||
EOSQL
|
21
borschevskaya_anna_lab_3/nginx/nginx.conf
Normal file
21
borschevskaya_anna_lab_3/nginx/nginx.conf
Normal file
@ -0,0 +1,21 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name localhost;
|
||||
|
||||
location /api/v1/company {
|
||||
proxy_pass http://company:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
location /api/v1/vacancy {
|
||||
proxy_pass http://vacancy:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
}
|
38
borschevskaya_anna_lab_3/vacancy-service/.gitignore
vendored
Normal file
38
borschevskaya_anna_lab_3/vacancy-service/.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
|
21
borschevskaya_anna_lab_3/vacancy-service/Dockerfile
Normal file
21
borschevskaya_anna_lab_3/vacancy-service/Dockerfile
Normal file
@ -0,0 +1,21 @@
|
||||
# Используем образ Maven для сборки
|
||||
FROM maven:3.8-eclipse-temurin-21-alpine AS build
|
||||
|
||||
# Устанавливаем рабочую директорию
|
||||
WORKDIR /app
|
||||
|
||||
# Копируем остальные исходные файлы
|
||||
COPY pom.xml .
|
||||
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"]
|
128
borschevskaya_anna_lab_3/vacancy-service/pom.xml
Normal file
128
borschevskaya_anna_lab_3/vacancy-service/pom.xml
Normal file
@ -0,0 +1,128 @@
|
||||
<?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.somecompany</groupId>
|
||||
<artifactId>vacancy-service</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.2.3</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<mapstruct.version>1.5.5.Final</mapstruct.version>
|
||||
<lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
|
||||
<spring-cloud.version>2023.0.3</spring-cloud.version>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.30</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<version>${mapstruct.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||
<version>${lombok-mapstruct-binding.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${spring-cloud.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>${mapstruct.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.30</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||
<version>${lombok-mapstruct-binding.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
<compilerArgs>
|
||||
<arg>-Amapstruct.defaultComponentModel=spring</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,14 @@
|
||||
package ru.somecompany;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients
|
||||
public class VacancyApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(VacancyApplication.class, args);
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package ru.somecompany.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import ru.somecompany.domain.CreateVacancyRequest;
|
||||
import ru.somecompany.domain.VacancyEntity;
|
||||
import ru.somecompany.domain.VacancyResponse;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Validated
|
||||
@Tag(name = "vacancy", description = "API для управления вакансиями")
|
||||
public interface VacancyController {
|
||||
|
||||
@Operation(summary = "Получение всех вакансий")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "Данные успешно переданы"),
|
||||
})
|
||||
@GetMapping(value = "/api/v1/vacancy")
|
||||
List<VacancyEntity> getVacancies();
|
||||
|
||||
@Operation(summary = "Создание вакансии")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "Вакансия успешно создана"),
|
||||
})
|
||||
@PostMapping(value = "/api/v1/vacancy")
|
||||
VacancyEntity createVacancy(@RequestBody @NotNull CreateVacancyRequest request);
|
||||
|
||||
@Operation(summary = "Получение информации о вакансии по id")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "Данные успешно переданы"),
|
||||
@ApiResponse(responseCode = "404", description = "Вакансия не найдена")
|
||||
})
|
||||
@GetMapping(value = "/api/v1/vacancy/{vacancyId}")
|
||||
VacancyResponse getVacancy(@PathVariable UUID vacancyId);
|
||||
|
||||
@Operation(summary = "Редактирование вакансии")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "Данные вакансии успешно изменены"),
|
||||
@ApiResponse(responseCode = "404", description = "Вакансия не найдена")
|
||||
})
|
||||
@PutMapping(value = "/api/v1/vacancy/{vacancyId}")
|
||||
VacancyEntity updateVacancy(@PathVariable UUID vacancyId,
|
||||
@RequestBody @NotNull CreateVacancyRequest request);
|
||||
|
||||
@Operation(summary = "Удалении вакансии по id")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "Вакансия успешно удалена"),
|
||||
@ApiResponse(responseCode = "404", description = "Вакансия не найдена")
|
||||
})
|
||||
@DeleteMapping(value = "/api/v1/vacancy/{vacancyId}")
|
||||
void deleteVacancy(@PathVariable UUID vacancyId);
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package ru.somecompany.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ru.somecompany.domain.CreateVacancyRequest;
|
||||
import ru.somecompany.domain.VacancyEntity;
|
||||
import ru.somecompany.domain.VacancyResponse;
|
||||
import ru.somecompany.service.VacancyService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class VacancyControllerImpl implements VacancyController {
|
||||
|
||||
private final VacancyService vacancyService;
|
||||
|
||||
@Override
|
||||
public List<VacancyEntity> getVacancies() {
|
||||
return vacancyService.getVacancies();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VacancyEntity createVacancy(CreateVacancyRequest request) {
|
||||
return vacancyService.createVacancy(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VacancyResponse getVacancy(UUID vacancyId) {
|
||||
return vacancyService.getVacancy(vacancyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VacancyEntity updateVacancy(UUID vacancyId, CreateVacancyRequest request) {
|
||||
return vacancyService.updateVacancy(vacancyId, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteVacancy(UUID vacancyId) {
|
||||
vacancyService.deleteVacancy(vacancyId);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package ru.somecompany.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class CompanyResponse {
|
||||
|
||||
private UUID id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String address;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package ru.somecompany.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class CreateVacancyRequest {
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private Integer salaryLow;
|
||||
|
||||
private Integer salaryHigh;
|
||||
|
||||
private UUID companyId;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package ru.somecompany.domain;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Builder
|
||||
@Table(name = "vacancy")
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class VacancyEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private UUID id;
|
||||
|
||||
@Column(name = "name", nullable = false)
|
||||
private String name;
|
||||
|
||||
@Column(name = "description", nullable = true, length = 1000)
|
||||
private String description;
|
||||
|
||||
@Column(name = "salary_low", nullable = false)
|
||||
private Integer salaryLow;
|
||||
|
||||
@Column(name = "salary_high", nullable = false)
|
||||
private Integer salaryHigh;
|
||||
|
||||
@Column(name = "company_id", nullable = false)
|
||||
private UUID companyId;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package ru.somecompany.domain;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@Schema(description = "Данные по вакансии")
|
||||
public class VacancyResponse {
|
||||
|
||||
private UUID id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private Integer salaryLow;
|
||||
|
||||
private Integer salaryHigh;
|
||||
|
||||
private CompanyResponse company;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package ru.somecompany.exception;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
||||
|
||||
@Slf4j
|
||||
public abstract class AbstractWebExceptionHandler {
|
||||
|
||||
public static ResponseEntity<ResponseError> buildResponse(ErrorCode errorCode, HttpStatus status, String msg,
|
||||
boolean details, Throwable ex) {
|
||||
return buildResponse(errorCode.name(), status, msg, details, ex, LocalDateTime.now());
|
||||
}
|
||||
|
||||
public static ResponseEntity<ResponseError> buildResponse(String errorCode, HttpStatus status, String msg,
|
||||
boolean details, Throwable ex, LocalDateTime timestamp) {
|
||||
if (details) {
|
||||
log.error(msg, ex); // with stack-trace
|
||||
} else {
|
||||
var message = StringUtils.equals(msg, ex.getMessage()) ? msg : msg + ": " + ex.getMessage();
|
||||
if (status == NOT_FOUND) {
|
||||
log.warn(message);
|
||||
} else {
|
||||
log.error(message);
|
||||
}
|
||||
}
|
||||
|
||||
return ResponseEntity.status(status.value())
|
||||
.body(ResponseError.builder()
|
||||
.code(errorCode)
|
||||
.message(msg)
|
||||
.timestamp(timestamp)
|
||||
.status(status.value())
|
||||
.build());
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package ru.somecompany.exception;
|
||||
|
||||
public enum BasicError implements ErrorCode {
|
||||
NOT_FOUND
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package ru.somecompany.exception;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
@Getter
|
||||
public class CompanyAppRuntimeException extends RuntimeException {
|
||||
private final ErrorCode errorCode;
|
||||
private final HttpStatus status;
|
||||
private final boolean details;
|
||||
|
||||
public CompanyAppRuntimeException(ErrorCode errorCode, HttpStatus status, String message) {
|
||||
this(errorCode, status, message, null);
|
||||
}
|
||||
|
||||
public CompanyAppRuntimeException(ErrorCode errorCode, HttpStatus status, String message, Throwable error) {
|
||||
this(errorCode, status, message, true, error);
|
||||
}
|
||||
|
||||
public CompanyAppRuntimeException(ErrorCode errorCode, HttpStatus status, String message, boolean details, Throwable error) {
|
||||
super(message, error);
|
||||
this.errorCode = errorCode;
|
||||
this.status = status;
|
||||
this.details = details;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package ru.somecompany.exception;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface ErrorCode extends Serializable {
|
||||
|
||||
String name();
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package ru.somecompany.exception;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import static ru.somecompany.exception.BasicError.NOT_FOUND;
|
||||
|
||||
public class ResourceNotFoundException extends CompanyAppRuntimeException {
|
||||
|
||||
public ResourceNotFoundException(ErrorCode errorCode, String message) {
|
||||
this(errorCode, message, null);
|
||||
}
|
||||
|
||||
public ResourceNotFoundException(ErrorCode errorCode, String message, Throwable error) {
|
||||
super(errorCode, HttpStatus.NOT_FOUND, message, error);
|
||||
}
|
||||
|
||||
public static ResourceNotFoundException notFound(String message, Object... args) {
|
||||
return new ResourceNotFoundException(NOT_FOUND, String.format(message, args), null);
|
||||
}
|
||||
|
||||
public static ResourceNotFoundException notFound() {
|
||||
return new ResourceNotFoundException(NOT_FOUND, "Запрашиваемые данные не найдены", null);
|
||||
}
|
||||
|
||||
public static ResourceNotFoundException notFound(Throwable error) {
|
||||
return new ResourceNotFoundException(NOT_FOUND, error.getMessage(), error);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package ru.somecompany.exception;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ResponseError {
|
||||
@JsonProperty(required = true)
|
||||
private LocalDateTime timestamp;
|
||||
@JsonProperty(required = true)
|
||||
private Integer status;
|
||||
@JsonProperty(required = true)
|
||||
private String message;
|
||||
@JsonProperty(required = true)
|
||||
private String code;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package ru.somecompany.exception;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
@Slf4j
|
||||
@Getter
|
||||
@RestControllerAdvice
|
||||
@RequiredArgsConstructor
|
||||
public class WebExceptionHandler extends AbstractWebExceptionHandler {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@ExceptionHandler(CompanyAppRuntimeException.class)
|
||||
public ResponseEntity<ResponseError> handleException(CompanyAppRuntimeException ex) {
|
||||
return buildResponse(ex.getErrorCode(), ex.getStatus(), ex.getMessage(), ex.isDetails(), ex);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package ru.somecompany.external;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import ru.somecompany.domain.CompanyResponse;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@FeignClient(name = "company", url = "${app.feign.company-url}")
|
||||
public interface CompanyClient {
|
||||
|
||||
@GetMapping(value = "/api/v1/company/{companyId}")
|
||||
CompanyResponse getCompany(@PathVariable UUID companyId);
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package ru.somecompany.mapper;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import ru.somecompany.domain.CompanyResponse;
|
||||
import ru.somecompany.domain.CreateVacancyRequest;
|
||||
import ru.somecompany.domain.VacancyEntity;
|
||||
import ru.somecompany.domain.VacancyResponse;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Mapper(imports = UUID.class)
|
||||
public interface VacancyMapper {
|
||||
|
||||
@Mapping(target = "company", source = "company")
|
||||
@Mapping(target = "name", source = "entity.name")
|
||||
@Mapping(target = "id", source = "entity.id")
|
||||
VacancyResponse map(VacancyEntity entity, CompanyResponse company);
|
||||
|
||||
VacancyEntity map(CreateVacancyRequest request);
|
||||
|
||||
VacancyEntity map(@MappingTarget VacancyEntity entity, CreateVacancyRequest request);
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package ru.somecompany.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import ru.somecompany.domain.VacancyEntity;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Repository
|
||||
public interface VacancyRepository extends JpaRepository<VacancyEntity, UUID> {
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package ru.somecompany.service;
|
||||
|
||||
import ru.somecompany.domain.CreateVacancyRequest;
|
||||
import ru.somecompany.domain.VacancyEntity;
|
||||
import ru.somecompany.domain.VacancyResponse;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface VacancyService {
|
||||
|
||||
List<VacancyEntity> getVacancies();
|
||||
|
||||
VacancyEntity createVacancy(CreateVacancyRequest request);
|
||||
|
||||
VacancyEntity updateVacancy(UUID vacancyId, CreateVacancyRequest request);
|
||||
|
||||
void deleteVacancy(UUID vacancyId);
|
||||
|
||||
VacancyResponse getVacancy(UUID vacancyId);
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package ru.somecompany.service;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.somecompany.domain.CreateVacancyRequest;
|
||||
import ru.somecompany.domain.VacancyEntity;
|
||||
import ru.somecompany.domain.VacancyResponse;
|
||||
import ru.somecompany.mapper.VacancyMapper;
|
||||
import ru.somecompany.repository.VacancyRepository;
|
||||
import ru.somecompany.service.adapter.CompanyAdapter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static ru.somecompany.exception.ResourceNotFoundException.notFound;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class VacancyServiceImpl implements VacancyService {
|
||||
|
||||
private final VacancyRepository vacancyRepository;
|
||||
private final CompanyAdapter companyAdapter;
|
||||
private final VacancyMapper mapper;
|
||||
|
||||
@Override
|
||||
public List<VacancyEntity> getVacancies() {
|
||||
return vacancyRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VacancyEntity createVacancy(CreateVacancyRequest request) {
|
||||
var entity = mapper.map(request);
|
||||
return vacancyRepository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VacancyEntity updateVacancy(UUID vacancyId, CreateVacancyRequest request) {
|
||||
var entity = getById(vacancyId);
|
||||
entity = mapper.map(entity, request);
|
||||
|
||||
return vacancyRepository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteVacancy(UUID vacancyId) {
|
||||
var entity = getById(vacancyId);
|
||||
vacancyRepository.delete(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VacancyResponse getVacancy(UUID vacancyId) {
|
||||
var entity = getById(vacancyId);
|
||||
var company = companyAdapter.getCompanyById(entity.getCompanyId());
|
||||
|
||||
return mapper.map(entity, company);
|
||||
}
|
||||
|
||||
private VacancyEntity getById(UUID vacancyId) {
|
||||
var entity = vacancyRepository.findById(vacancyId);
|
||||
if (entity.isEmpty()) {
|
||||
log.warn("The vacancy with id '{}' was not found", vacancyId);
|
||||
throw notFound("Вакансия не найдена");
|
||||
}
|
||||
return entity.get();
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package ru.somecompany.service.adapter;
|
||||
|
||||
import ru.somecompany.domain.CompanyResponse;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface CompanyAdapter {
|
||||
|
||||
CompanyResponse getCompanyById(UUID companyId);
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package ru.somecompany.service.adapter;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.somecompany.domain.CompanyResponse;
|
||||
import ru.somecompany.external.CompanyClient;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CompanyAdapterImpl implements CompanyAdapter {
|
||||
|
||||
private final CompanyClient companyClient;
|
||||
|
||||
@Override
|
||||
public CompanyResponse getCompanyById(UUID companyId) {
|
||||
return companyClient.getCompany(companyId);
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
server:
|
||||
port: ${SERVER_PORT:8080}
|
||||
spring:
|
||||
application:
|
||||
name: vacancy-app
|
||||
jpa:
|
||||
database: POSTGRESQL
|
||||
open-in-view: false
|
||||
show-sql: false
|
||||
hibernate:
|
||||
ddl-auto: none
|
||||
properties:
|
||||
hibernate:
|
||||
dialect: org.hibernate.dialect.PostgreSQLDialect
|
||||
datasource:
|
||||
url: ${DB_URL:jdbc:postgresql://localhost:5433/vacancy}
|
||||
username: ${DB_USERNAME:postgres}
|
||||
password: ${DB_PASSWORD:postgres}
|
||||
driverClassName: org.postgresql.Driver
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
hikari:
|
||||
maximum-pool-size: 15
|
||||
minimum-idle: 4
|
||||
idle-timeout: 180000
|
||||
max-lifetime: 599000
|
||||
flyway:
|
||||
enabled: true
|
||||
locations: db/migration/
|
||||
|
||||
app:
|
||||
feign:
|
||||
company-url: ${COMPANY_URL:http://localhost:8081}
|
@ -0,0 +1,9 @@
|
||||
CREATE TABLE vacancy (
|
||||
id UUID
|
||||
CONSTRAINT company_pk PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description VARCHAR(1000),
|
||||
salary_low int8 NOT NULL,
|
||||
salary_high int8 NOT NULL,
|
||||
company_id UUID NOT NULL
|
||||
);
|
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 |
2
dolgov_dmitriy_lab_2/.gitignore
vendored
Normal file
2
dolgov_dmitriy_lab_2/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
data
|
||||
result
|
36
dolgov_dmitriy_lab_2/README.md
Normal file
36
dolgov_dmitriy_lab_2/README.md
Normal file
@ -0,0 +1,36 @@
|
||||
# Лабораторная работа №2
|
||||
|
||||
## Выполнил: Долгов Дмитрий, группа ПИбд-42
|
||||
|
||||
### Были выбраны следующие варианты программ:
|
||||
|
||||
* _Вариант первого приложения: 6._ Берёт из каталога /var/data случайный файл и перекладывает его в /var/result/data.txt.
|
||||
* _Вариант второго приложения: 1._ Ищет набольшее число из файла /var/data/data.txt и сохраняет его вторую степень в /var/result/result.txt.
|
||||
|
||||
Кроме того, для генерации файлов был реализован сервис file_generator
|
||||
|
||||
### Были использованы следующие технологии:
|
||||
|
||||
* git
|
||||
* docker
|
||||
* docker-compose
|
||||
* язык программирования Python
|
||||
|
||||
### Для запуска лабораторной работы, находясь в папке `dolgov_dmitriy_lab_2`, необходимо выполнить следующую команду:
|
||||
|
||||
```
|
||||
docker-compose up --build
|
||||
```
|
||||
Таким образом, запустятся все сервисы, необходимые для выполнения лабораторной работы.
|
||||
|
||||
## Результат запуска:
|
||||
```
|
||||
app2-1 | Наибольшее числовое значение: 29.0
|
||||
app2-1 | Результат: 841.0
|
||||
app1-1 | Файл file_3.txt успешно перемещен в /var/result/data.txt
|
||||
app2-1 exited with code 0
|
||||
app1-1 exited with code 0
|
||||
```
|
||||
## Видео с результатом запуска:
|
||||
|
||||
Видео можно посмотреть по данной [ссылке](https://drive.google.com/file/d/1Iw6BR0lRvh4382QsIEfr5E68-09aKX9C/view?usp=drive_link).
|
8
dolgov_dmitriy_lab_2/app1/Dockerfile
Normal file
8
dolgov_dmitriy_lab_2/app1/Dockerfile
Normal file
@ -0,0 +1,8 @@
|
||||
# Стандартный образ Python
|
||||
FROM python:3.9
|
||||
# Указываем рабочую директорию
|
||||
WORKDIR /app
|
||||
# Копируем в ней файл app1.py
|
||||
COPY app1.py .
|
||||
# Команда для запуска при старте контейнера
|
||||
CMD ["python", "app1.py"]
|
27
dolgov_dmitriy_lab_2/app1/app1.py
Normal file
27
dolgov_dmitriy_lab_2/app1/app1.py
Normal file
@ -0,0 +1,27 @@
|
||||
import os
|
||||
import random
|
||||
import shutil
|
||||
|
||||
def move_random_file():
|
||||
src_dir = "/var/data"
|
||||
dst_file = "/var/result/data.txt"
|
||||
|
||||
# Получаем список всех файлов в src_dir
|
||||
files = os.listdir(src_dir)
|
||||
|
||||
if files:
|
||||
# Выбираем случайный файл
|
||||
random_file = random.choice(files)
|
||||
|
||||
# Проверяем, что файл существует
|
||||
if os.path.exists(os.path.join(src_dir, random_file)):
|
||||
# Перемещаем файл в целевое место
|
||||
shutil.move(os.path.join(src_dir, random_file), dst_file)
|
||||
print(f"Файл {random_file} успешно перемещен в {dst_file}")
|
||||
else:
|
||||
print(f"Ошибка: Файл {random_file} не найден в {src_dir}")
|
||||
else:
|
||||
print("Папка пуста")
|
||||
|
||||
if __name__ == "__main__":
|
||||
move_random_file()
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user