Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions consumer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Stage 1: Build shared-dto
FROM maven:3.9.6-eclipse-temurin-21 AS build
WORKDIR /app

# Copy and build shared-dto
COPY shared-dto ./shared-dto
RUN mvn install -f shared-dto/pom.xml -DskipTests

# Copy and build consumer (flat, to avoid nesting)
COPY consumer ./consumer
RUN mvn clean package -f consumer/pom.xml -DskipTests

# Stage 2: Run the application
FROM eclipse-temurin:21-jre
WORKDIR /app
COPY --from=build /app/consumer/target/consumer-0.0.1-SNAPSHOT.jar app.jar
EXPOSE 9220
ENTRYPOINT ["java", "-jar", "app.jar"]
43 changes: 43 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: "3.8"

services:
zookeeper:
image: confluentinc/cp-zookeeper:7.5.0
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
ports:
- "2181:2181"

kafka:
image: confluentinc/cp-kafka:7.5.0
depends_on:
- zookeeper
ports:
- "9092:9092"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:9092
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,PLAINTEXT_HOST://0.0.0.0:9093
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1

publisher:
image: janindu1999/publisher-app:latest
depends_on:
- kafka
ports:
- "9219:9219"
environment:
SPRING_KAFKA_BOOTSTRAP_SERVERS: kafka:9092

consumer:
image: janindu1999/consumer-app:latest
depends_on:
- kafka
ports:
- "9229:9229"
environment:
SPRING_KAFKA_BOOTSTRAP_SERVERS: kafka:9092
19 changes: 19 additions & 0 deletions publisher/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Stage 1: Build shared-dto
FROM maven:3.9.6-eclipse-temurin-21 AS build
WORKDIR /app

# Copy and build shared-dto first
COPY shared-dto ./shared-dto
RUN mvn install -f shared-dto/pom.xml -DskipTests

# Copy the rest and build publisher (including its dependencies)
COPY publisher ./publisher
COPY consumer ./consumer
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add Consumer to the Publisher's context?

RUN mvn clean package -f publisher/pom.xml -DskipTests

# Stage 2: Run the application
FROM eclipse-temurin:21-jre
WORKDIR /app
COPY --from=build /app/publisher/target/publisher-0.0.1-SNAPSHOT.jar app.jar
EXPOSE 9219
ENTRYPOINT ["java", "-jar", "app.jar"]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
E:\I_Learn_Cloud\Projects\Springboot Kafka\shared-dto\src\main\java\com\shared\dto\Customer.java
C:\Projects\Java\Spring Boot\Kafka\springboot-kafka-pubsub\shared-dto\src\main\java\com\shared\dto\Customer.java
Binary file modified shared-dto/target/shared-dto-1.0.0.jar
Binary file not shown.