DAS_2023_1/tepechin_kirill_lab_3/README.md

100 lines
2.1 KiB
Markdown
Raw Normal View History

2023-12-12 03:34:05 +04:00
## Лабораторная работа №3, ПИбд-42 Тепечин Кирилл
### Сервисы
* `opop-service`
* `document-service`
### Синхронный обмен между микросервисами
Синхронное взаимодействие осуществляется через `RestTemplate`
Пример взаимодействия:
````java
2023-12-12 03:39:50 +04:00
RestTemplate restTemplate = new RestTemplate();
String URL = "http://document-service:8081/document/";
2023-12-12 03:34:05 +04:00
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