Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#48] 도커로 각 모듈 배포 #49

Open
wants to merge 1 commit into
base: feature/28
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spring:
properties:
spring.json.trusted.packages: com.whalewatch.dto,com.whalewatch.domain
redis:
host: localhost
host: redis
port: 6379

jwt:
Expand Down
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ plugins {
id 'io.spring.dependency-management' version '1.1.6'
}

bootJar {
enabled = false
}
jar {
enabled = true
}

group 'com.whalewatch'
version '0.0.1-SNAPSHOT'

Expand Down
6 changes: 3 additions & 3 deletions collector/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# collector/Dockerfile
FROM openjdk:17-slim

COPY build/libs/whalewatch-collector.jar /app/collector.jar
WORKDIR /app
COPY build/libs/collector.jar /app/collector.jar

EXPOSE 8080
EXPOSE 8081

ENTRYPOINT ["java", "-jar", "/app/collector.jar"]
2 changes: 1 addition & 1 deletion collector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ dependencies {
}

bootJar {
archiveFileName = 'whalewatch-collector.jar'
mainClass.set('com.whalewatch.CollectorApplication')
}
7 changes: 7 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@ dependencies {

// Redis (Spring Data Redis)
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
}

bootJar {
enabled = false
}
jar {
enabled = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@
@Configuration
public class KafkaConsumerConfig {

private final KafkaProducerProperties kafkaProducerProperties;

public KafkaConsumerConfig(KafkaProducerProperties kafkaProducerProperties) {
this.kafkaProducerProperties = kafkaProducerProperties;
}

@Bean
public ConsumerFactory<String, TransactionEventDto> consumerFactory() {
Map<String, Object> props = new HashMap<>();
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9093");
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaProducerProperties.getBootstrapServers());
props.put(ConsumerConfig.GROUP_ID_CONFIG, "whalewatch_group");
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class);
Expand Down
126 changes: 120 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,135 @@ services:
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
# 멀티 리스너 설정
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,EXTERNAL://localhost:9093
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,EXTERNAL://0.0.0.0:9093
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,EXTERNAL:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
ports:
- "9092:9092" # 도커 내부 통신용
- "9093:9093" # 호스트(로컬)용
- "9092:9092"
networks:
- whale-net

redis:
image: redis:7.0
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- redis_data:/data
networks:
- whale-net

collector:
image: whalewatch/collector:latest
container_name: collector
ports:
- "8081:8081"
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/${MYSQL_DATABASE}
SPRING_DATASOURCE_USERNAME: ${MYSQL_USER}
SPRING_DATASOURCE_PASSWORD: ${MYSQL_PASSWORD}
SPRING_KAFKA_BOOTSTRAP_SERVERS: kafka:9092
TELEGRAM_TOKEN: ${TELEGRAM_TOKEN}
TELEGRAM_USERNAME: ${TELEGRAM_USERNAME}
TELEGRAM_WEBHOOKURL: ${TELEGRAM_WEBHOOKURL}
SPRING_REDIS_HOST: redis
SPRING_REDIS_PORT: 6379
depends_on:
- mysql
- kafka
- zookeeper
- redis
networks:
- whale-net

user-service:
image: whalewatch/user-service:latest
container_name: user-service
ports:
- "8082:8082"
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/${MYSQL_DATABASE}
SPRING_DATASOURCE_USERNAME: ${MYSQL_USER}
SPRING_DATASOURCE_PASSWORD: ${MYSQL_PASSWORD}
SPRING_KAFKA_BOOTSTRAP_SERVERS: kafka:9092
SPRING_REDIS_HOST: redis
SPRING_REDIS_PORT: 6379
depends_on:
- mysql
- kafka
- zookeeper
- redis
networks:
- whale-net

transaction-service:
image: whalewatch/transaction-service:latest
ports:
- "8083:8083"
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/${MYSQL_DATABASE}
SPRING_DATASOURCE_USERNAME: ${MYSQL_USER}
SPRING_DATASOURCE_PASSWORD: ${MYSQL_PASSWORD}
SPRING_KAFKA_BOOTSTRAP_SERVERS: kafka:9092
SPRING_REDIS_HOST: redis
SPRING_REDIS_PORT: 6379
depends_on:
- mysql
- kafka
- zookeeper
- redis
networks:
- whale-net

notification-service:
image: whalewatch/notification-service:latest
ports:
- "8084:8084"
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/${MYSQL_DATABASE}
SPRING_DATASOURCE_USERNAME: ${MYSQL_USER}
SPRING_DATASOURCE_PASSWORD: ${MYSQL_PASSWORD}
SPRING_KAFKA_BOOTSTRAP_SERVERS: kafka:9092
TELEGRAM_TOKEN: ${TELEGRAM_TOKEN}
TELEGRAM_USERNAME: ${TELEGRAM_USERNAME}
TELEGRAM_WEBHOOKURL: ${TELEGRAM_WEBHOOKURL}
SPRING_REDIS_HOST: redis
SPRING_REDIS_PORT: 6379
depends_on:
- mysql
- kafka
- zookeeper
- redis
networks:
- whale-net

post-service:
image: whalewatch/post-service:latest
container_name: post-service
ports:
- "8085:8085"
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/${MYSQL_DATABASE}
SPRING_DATASOURCE_USERNAME: ${MYSQL_USER}
SPRING_DATASOURCE_PASSWORD: ${MYSQL_PASSWORD}
SPRING_KAFKA_BOOTSTRAP_SERVERS: kafka:9092
SPRING_REDIS_HOST: redis
SPRING_REDIS_PORT: 6379
depends_on:
- mysql
- kafka
- zookeeper
- redis
networks:
- whale-net

volumes:
mysql_data:
redis_data:

networks:
whale-net:
driver: bridge

8 changes: 8 additions & 0 deletions notification-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM openjdk:17-slim

WORKDIR /app
COPY build/libs/notification-service.jar /app/notification-service.jar

EXPOSE 8084

ENTRYPOINT ["java", "-jar", "/app/notification-service.jar"]
7 changes: 6 additions & 1 deletion notification-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ dependencies {

test {
useJUnitPlatform()
}
}

bootJar {
mainClass.set('com.whalewatch.NotificationServiceApplication')
}

8 changes: 8 additions & 0 deletions post-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM openjdk:17-slim

WORKDIR /app
COPY build/libs/post-service.jar /app/post-service.jar

EXPOSE 8085

ENTRYPOINT ["java", "-jar", "/app/post-service.jar"]
6 changes: 5 additions & 1 deletion post-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ dependencies {

test {
useJUnitPlatform()
}
}

bootJar {
mainClass.set('com.whalewatch.PostServiceApplication')
}
8 changes: 8 additions & 0 deletions transaction-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM openjdk:17-slim

WORKDIR /app
COPY build/libs/transaction-service.jar /app/transaction-service.jar

EXPOSE 8083

ENTRYPOINT ["java", "-jar", "/app/transaction-service.jar"]
6 changes: 5 additions & 1 deletion transaction-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ dependencies {

test {
useJUnitPlatform()
}
}

bootJar {
mainClass.set('com.whalewatch.TransactionServiceApplication')
}
8 changes: 8 additions & 0 deletions user-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM openjdk:17-slim

WORKDIR /app
COPY build/libs/user-service.jar /app/user-service.jar

EXPOSE 8082

ENTRYPOINT ["java", "-jar", "/app/user-service.jar"]
4 changes: 4 additions & 0 deletions user-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@ dependencies {

test {
useJUnitPlatform()
}

bootJar {
mainClass.set('com.whalewatch.UserServiceApplication')
}