Skip to content

Commit

Permalink
Merge branch 'develop' into docs/#77
Browse files Browse the repository at this point in the history
  • Loading branch information
DDonghyeo authored May 27, 2024
2 parents d845562 + f46c052 commit 37d7a5d
Show file tree
Hide file tree
Showing 17 changed files with 222 additions and 59 deletions.
40 changes: 24 additions & 16 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: prod

#Setting JDK
- name: Set up JDK 17
Expand All @@ -47,13 +45,13 @@ jobs:
chmod +x ./weather-service/gradlew
#Setting yml
- name: Settings for config service
run: |
cd ./config-service/src/main/resources
touch ./bootstrap.yml
echo "${{ secrets.CONFIG_APPLICATION_YML }}" > ./bootstrap.yml
cd
# - name: Settings for config service
# run: |
# cd ./config-service/src/main/resources
# touch ./bootstrap.yml
# echo "${{ secrets.CONFIG_APPLICATION_YML }}" > ./bootstrap.yml
# cat bootstrap.yml

# DockerHub Login
- name: Docker Hub Login
uses: docker/login-action@v2
Expand Down Expand Up @@ -87,7 +85,7 @@ jobs:
run: |
cd apiGateway-service
./gradlew clean build -x test
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-gateway .
docker build --no-cache -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-gateway .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/waither-gateway
cd ..
Expand All @@ -104,8 +102,9 @@ jobs:
- name: Build with Gradle - noti-service
run: |
cd noti-service
cat src/main/resources/bootstrap.yml
./gradlew clean build -x test
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-noti .
docker build --no-cache -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-noti .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/waither-noti
cd ..
Expand All @@ -114,7 +113,7 @@ jobs:
run: |
cd user-service
./gradlew clean build -x test
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-user .
docker build --no-cache -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-user .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/waither-user
cd ..
Expand All @@ -123,7 +122,7 @@ jobs:
run: |
cd weather-service
./gradlew clean build -x test
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-weather .
docker build --no-cache -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-weather .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/waither-weather
cd ..
Expand All @@ -147,8 +146,17 @@ jobs:
export CONFIG_PASSPHRASE=${{ secrets.CONFIG_PASSPHRASE }}
export DOCKERHUB_USERNAME=${{ secrets.DOCKERHUB_USERNAME }}
bash /home/docker_init.sh
bash /home/common.sh
bash /home/deploy.sh
cd /home
docker-compose pull
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/waither-config
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/waither-gateway
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/waither-noti
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/waither-user
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/waither-weather
bash ./docker_init.sh
bash ./common.sh
bash ./deploy.sh
docker image prune -f
2 changes: 1 addition & 1 deletion apiGateway-service/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spring:
uri: http://localhost:8888
name: database-apiGateway, redis, jwt
kafka:
bootstrap-servers: "localhost:9092"
bootstrap-servers: "http://localhost:9092"
consumer:
group-id: "GroupId"

Expand Down
60 changes: 57 additions & 3 deletions config-service/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,68 @@ server:

spring:
profiles:
active: dev
active: prod
application:
name: config-service
name: config-services
cloud:
config:
server:
git:
uri: ${CONFIG_GIT_URI}
ignore-local-ssh-settings: true
passphrase: ${CONFIG_PASSPHRASE}
private-key: ${CONFIG_PRIVATE_KEY}
private-key: |
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,58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-----
73 changes: 42 additions & 31 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,81 @@ version: '3'

services:

# nginx:
# container_name: nginx
# image: nginx:latest
# ports:
# - "80:80"
# volumes:
# - /home/ec2-user/nginx.conf:/etc/nginx/nginx.conf
# depends_on:
# - "db"
# restart: always #항상 재실행

api-gateway:
container_name: api-gateway
image: ${DOCKERHUB_USERNAME}/waither-gateway
expose:
- "8000"
image: ${DOCKERHUB_USERNAME}/waither-gateway:latest
network_mode: host
depends_on:
- config
ports:
- "8000:8000"
# restart: always
restart: no
volumes:
- /home/ec2-user/logs/api-gateway:/logs


config:
container_name: config
image: ${DOCKERHUB_USERNAME}/waither-config
expose:
- "8888"
image: ${DOCKERHUB_USERNAME}/waither-config:latest
network_mode: host
ports:
- "8888:8888"
depends_on:
- eureka
environment:
CONFIG_GIT_URI : ${CONFIG_GIT_URI}
CONFIG_PASSPHRASE : ${CONFIG_PASSPHRASE}
# CONFIG_PRIVATE_KEY_DIR : ${CONFIG_PRIVATE_KEY_DIR}
# restart: always
restart: no
volumes:
- /home/ec2-user/logs/config:/logs

eureka:
container_name: eureka
image: ${DOCKERHUB_USERNAME}/waither-eureka
expose:
- "8761"
image: ${DOCKERHUB_USERNAME}/waither-eureka:latest
network_mode: host
ports:
- "8761:8761"
# restart: always
restart: no
volumes:
- /home/ec2-user/logs/eureka:/logs

user-service:
container_name: user-service
image: ${DOCKERHUB_USERNAME}/waither-user
expose:
- "8080"
image: ${DOCKERHUB_USERNAME}/waither-user:latest
network_mode: host
depends_on:
- config
ports:
- "8080:8080"
# restart: unless-stopped #수동으로 중지되지 않는 이상 항상 재실행
restart: no
volumes:
- /home/ec2-user/logs/user-service:/logs

weather-service:
container_name: weather-service
image: ${DOCKERHUB_USERNAME}/waither-weather
expose:
- "8081"
image: ${DOCKERHUB_USERNAME}/waither-weather:latest
network_mode: host
depends_on:
- config
ports:
- "8081:8081"
# restart: unless-stopped
restart: no
volumes:
- /home/ec2-user/logs/weather-service:/logs
- /home/ec2-user/logs/weather-service:/logs:latest

noti-service:
container_name: noti-service
image: ${DOCKERHUB_USERNAME}/waither-noti
expose:
- "8082"
image: ${DOCKERHUB_USERNAME}/waither-noti:latest
network_mode: host
depends_on:
- config
ports:
- "8082:8082"
# restart: unless-stopped
restart: no
volumes:
Expand All @@ -93,3 +98,9 @@ services:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
volumes:
- /var/run/docker.sock:/var/run/docker.sock

redis:
image: redis
container_name: redis
ports:
- "6379:6379"
1 change: 1 addition & 0 deletions noti-service/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ springdoc:
default-consumes-media-type: application/json
default-produces-media-type: application/json
enable-spring-security: true

9 changes: 9 additions & 0 deletions script/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ RUNNING_EUREKA=$(docker ps | grep eureka)
RUNNING_CONFIG=$(docker ps | grep config)
RUNNING_ZOOKEEPER=$(docker ps | grep zookeeper)
RUNNING_KAFKA=$(docker ps | grep kafka)
RUNNING_REDIS=$(docker ps | grep redis)

# Eureka 검색
if [ -z "$RUNNING_EUREKA" ]; then
Expand All @@ -22,6 +23,14 @@ else
echo "Config Service is already running"
fi

# Redis 검색
if [ -z "$RUNNING_REDIS" ]; then
echo "Starting Redis ..."
docker-compose -f /home/docker-compose.yml up -d redis
else
echo "Redis is already running"
fi

# Zookeeper 검색
if [ -z "$RUNNING_ZOOKEEPER" ]; then
echo "Starting Zookeeper ..."
Expand Down
8 changes: 4 additions & 4 deletions script/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
# -d : detached 모드. 컨테이너를 백그라운드에서 실행

echo "api-gateway server start..."
docker-compose -f /home/docker-compose.yml up -d api-gateway
docker-compose -f /home/docker-compose.yml up -d api-gateway --build
echo "noti-service server start..."
docker-compose -f /home/docker-compose.yml up -d noti-service
docker-compose -f /home/docker-compose.yml up -d noti-service --build
echo "user-service server start..."
docker-compose -f /home/docker-compose.yml up -d user-service
docker-compose -f /home/docker-compose.yml up -d user-service --build
echo "weather-service server start..."
docker-compose -f /home/docker-compose.yml up -d weather-service
docker-compose -f /home/docker-compose.yml up -d weather-service --build
2 changes: 1 addition & 1 deletion user-service/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ eureka:
register-with-eureka: true # register to eureka server
fetch-registry: true # Getting instances' information from eureka server
service-url:
defaultZone : http://127.0.0.1:8761/eureka #Eureka Server's address
defaultZone : http://localhost:8761/eureka #Eureka Server's address

#management: # Actuator
# endpoints:
Expand Down
2 changes: 2 additions & 0 deletions weather-service/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
*-secret.yml
*.Ds_Store
**/data/mysql/

HELP.md
.gradle
Expand Down
5 changes: 4 additions & 1 deletion weather-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ ext {

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"

testImplementation 'org.springframework.boot:spring-boot-starter-test'
// DB
runtimeOnly 'com.mysql:mysql-connector-j'

//Webflux
implementation 'org.springframework.boot:spring-boot-starter-webflux'
Expand Down
11 changes: 11 additions & 0 deletions weather-service/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
version: '3'

services:
mysql:
image: mysql:latest
container_name: waither
environment:
MYSQL_ROOT_USER: root
MYSQL_ROOT_PASSWORD: root1234!
MYSQL_DATABASE: waither
ports:
- "3306:3306"
volumes:
- ./data/mysql:/var/lib/mysql
redis:
image: redis:latest
ports:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableScheduling
@SpringBootApplication
@EnableRedisRepositories
public class WeatherServiceApplication {
Expand Down
Loading

0 comments on commit 37d7a5d

Please sign in to comment.