DAS_2023_1/tepechin_kirill_lab_3
2023-12-12 03:34:05 +04:00
..
document-service tepechin_kirill_lab_3 2023-12-12 03:34:05 +04:00
nginx-conf tepechin_kirill_lab_3 2023-12-12 03:34:05 +04:00
opop-service tepechin_kirill_lab_3 2023-12-12 03:34:05 +04:00
docker-compose.yml tepechin_kirill_lab_3 2023-12-12 03:34:05 +04:00
README.md tepechin_kirill_lab_3 2023-12-12 03:34:05 +04:00

Лабораторная работа №3, ПИбд-42 Тепечин Кирилл

Сервисы

  • opop-service
  • document-service

Синхронный обмен между микросервисами

Синхронное взаимодействие осуществляется через RestTemplate

Пример взаимодействия:

restTemplate.getForObject(URL+ opopDto.getDocumentId(), DocumentInfo.class)

Докерфайлы

FROM eclipse-temurin:17-jdk-alpine
VOLUME /tmp
ARG JAR_FILE
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

docker-compose файл

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