упаковал всё в docker-compose

This commit is contained in:
2025-04-15 20:50:01 +03:00
parent 9312ec1f2d
commit 3245ffa10f
6 changed files with 64 additions and 11 deletions

12
lab3/.gitignore vendored
View File

@@ -1,9 +1,3 @@
*
!.gitignore
!report
!report/**
!producer
!producer/**
!consumer
!consumer/**
!my-variant.txt
*.jpg
*.pdf
*.docx

9
lab3/consumer/Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
FROM gradle:8.13-jdk21
WORKDIR /app
COPY . .
RUN gradle build --no-daemon
CMD ["gradle", "run", "--no-daemon"]

View File

@@ -10,7 +10,7 @@ public class Recv {
public static void main(String[] argv) throws Exception {
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
factory.setHost("rabbitmq");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();

41
lab3/docker-compose.yml Normal file
View File

@@ -0,0 +1,41 @@
services:
rabbitmq:
image: rabbitmq:4.0-management
hostname: rabbitmq
container_name: rabbitmq
ports:
- "5672:5672"
- "15672:15672"
networks:
- rabbitnet
producer1:
container_name: producer1
build:
context: ./producer
depends_on:
- rabbitmq
networks:
- rabbitnet
producer2:
container_name: producer2
build:
context: ./producer
depends_on:
- rabbitmq
networks:
- rabbitnet
consumer:
container_name: consumer
build:
context: ./consumer
depends_on:
- rabbitmq
networks:
- rabbitnet
networks:
rabbitnet:
driver: bridge

9
lab3/producer/Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
FROM gradle:8.13-jdk21
WORKDIR /app
COPY . .
RUN gradle build --no-daemon
CMD ["gradle", "run", "--no-daemon"]

View File

@@ -9,7 +9,7 @@ public class Send {
public static void main(String[] args) throws Exception {
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
factory.setHost("rabbitmq");
try (Connection connection = factory.newConnection();
Channel channel = connection.createChannel()) {
channel.queueDeclare(QUEUE_NAME, false, false, false, null);