98 lines
2.0 KiB
Markdown
98 lines
2.0 KiB
Markdown
|
## Лабораторная работа №3, ПИбд-42 Тепечин Кирилл
|
||
|
|
||
|
### Сервисы
|
||
|
* `opop-service`
|
||
|
* `document-service`
|
||
|
|
||
|
### Синхронный обмен между микросервисами
|
||
|
Синхронное взаимодействие осуществляется через `RestTemplate`
|
||
|
|
||
|
Пример взаимодействия:
|
||
|
|
||
|
````java
|
||
|
restTemplate.getForObject(URL+ opopDto.getDocumentId(), DocumentInfo.class)
|
||
|
````
|
||
|
|
||
|
### Докерфайлы
|
||
|
|
||
|
````dockerfile
|
||
|
FROM eclipse-temurin:17-jdk-alpine
|
||
|
VOLUME /tmp
|
||
|
ARG JAR_FILE
|
||
|
COPY ${JAR_FILE} app.jar
|
||
|
ENTRYPOINT ["java","-jar","/app.jar"]
|
||
|
````
|
||
|
### docker-compose файл
|
||
|
````yaml
|
||
|
version: '3'
|
||
|
services:
|
||
|
opop-service:
|
||
|
build:
|
||
|
context: /opop-service
|
||
|
dockerfile: Dockerfile
|
||
|
args:
|
||
|
JAR_FILE: build/libs/*.jar
|
||
|
ports:
|
||
|
- "8080:8080"
|
||
|
networks:
|
||
|
- my-network
|
||
|
environment:
|
||
|
server.forward-headers-strategy: framework
|
||
|
|
||
|
document-service:
|
||
|
build:
|
||
|
context: /document-service
|
||
|
dockerfile: Dockerfile
|
||
|
args:
|
||
|
JAR_FILE: build/libs/*.jar
|
||
|
ports:
|
||
|
- "8081:8081"
|
||
|
networks:
|
||
|
- my-network
|
||
|
environment:
|
||
|
server.forward-headers-strategy: framework
|
||
|
|
||
|
nginx:
|
||
|
image: nginx
|
||
|
ports:
|
||
|
- "80:80"
|
||
|
networks:
|
||
|
- my-network
|
||
|
volumes:
|
||
|
- ./nginx-conf:/etc/nginx/conf.d
|
||
|
depends_on:
|
||
|
- opop-service
|
||
|
- document-service
|
||
|
|
||
|
networks:
|
||
|
my-network:
|
||
|
driver: bridge
|
||
|
````
|
||
|
|
||
|
### nginx.conf
|
||
|
````
|
||
|
server {
|
||
|
listen 80;
|
||
|
|
||
|
location /opop-service/ {
|
||
|
proxy_pass_request_headers on;
|
||
|
proxy_set_header Host $host;
|
||
|
proxy_set_header X-Forwarded-Prefix '/opop-service';
|
||
|
proxy_pass http://opop-service:8080/;
|
||
|
}
|
||
|
|
||
|
location /document-service/ {
|
||
|
proxy_pass_request_headers on;
|
||
|
proxy_set_header Host $host;
|
||
|
proxy_set_header X-Forwarded-Prefix '/document-service';
|
||
|
proxy_pass http://document-service:8081/;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
````
|
||
|
|
||
|
### Ссылка на видео
|
||
|
https://vk.com/video170089763_456239482?list=ln-0DBU1KuruzjrZvKRLE
|
||
|
|
||
|
|