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

Swagger Deployment #84

Merged
merged 7 commits into from
May 27, 2024
Merged
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
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
1 change: 1 addition & 0 deletions apiGateway-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ FROM openjdk:17-jdk

ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
COPY src/main/resources/static /app/static
ENTRYPOINT ["java", "-Dspring.profiles.active=prod", "-Duser.timezone=Asia/Seoul" , "-jar", "app.jar"]
2 changes: 2 additions & 0 deletions apiGateway-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
testImplementation 'org.springframework.security:spring-security-test'

// Swagger
implementation 'org.springdoc:springdoc-openapi-starter-webflux-ui:2.1.0'

// //Spring Boot Actuator
// implementation 'org.springframework.boot:spring-boot-starter-actuator'
Expand Down
28 changes: 24 additions & 4 deletions apiGateway-service/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
server:
port: 80
port: 443

spring:
application:
Expand All @@ -8,10 +8,10 @@ spring:
active: dev
cloud:
config:
uri: http://config:8888
uri: http://localhost:8888
name: database-apiGateway, redis, jwt
kafka:
bootstrap-servers: "localhost:9092"
bootstrap-servers: "http://localhost:9092"
consumer:
group-id: "GroupId"

Expand All @@ -22,8 +22,28 @@ eureka:
service-url:
defaultZone: http://localhost:8761/eureka


springdoc:
# api-docs:
# enabled: true
# version: openapi_3_0
swagger-ui:
use-root-path: true
urls:
- url: /noti/v3/api-docs
name: Notification Service
- url: /weather/v3/api-docs
name: Weather Service
- url: /user/v3/api-docs
name: User Service
# path: /swagger-ui.html
# version: 3.0.0



#management: # Actuator Settings
# endpoints:
# web:
# exposure:
# include: refresh, health, beans, httptrace
# include: refresh, health, beans, httptrace

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,58151ECC53694263F35EEA88FBFA6406

2cstlc5/bYHUAJWg0PL7UbGksDp1okrJXqgBWcTqrH5qQm/iSk/LhYxF1JxGqPwt
fEWmuoGJgcJzaW80ivkBUbWUPdO5V9WHebynjFO5xUWJssGvmV4TEPGmLEKGpDSr
t1ae00AO/2YsyqTrCffDzu3S8R6A4IOSYE17Yx6P4z9xnnBJ4IG6d5Q6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pTh8Y1mnIH6r
bLa2wnmWeolxtm4D/TSTxOEedvlKqubADxgOs1lfBwuPXMHJBQurRgiYiTEtBOFK
j0pHK85nXHTuPAYyGjZTf5q4+XHLeInqOgvFJBkfzj+7aQ5NnFzA4KDHJWp+Cjsi
45get7THkze1+8oEDI1i9CFR4lAl9aTnsoPJLG4ufKE6HZ/gM8jwbOgxUM9fzv1O
3Jrr6Fjz7QSKajZGgJg4gzBVfhI7qMLuCYpIYb/tJ3Piwe9SjTMfJxQ02n1w9vu6
FvWasxcPAfhf5lKRc1cojg9w+E37G9qdwWYRAKWXiL4Fctfd05uLorXDLed16Cji
bK6/6X1xyH8o7uzxQigzct1TGk/rgaONMSv3fO+8vWJ0bj+TZOMwl4IAMD/QnR6a
Hkr5T8KjSeytETyoCRHcn3rUSX7SW9EPKxfI805SvkmETl5gtCWh1Ebj8KlO8KG/
riReQi9WCOII3v4d8+m3PgDODG7uu49zKYUnnbABqER2ONp3W4IkQXUfJbY1vmZW
XvyYMOEW42ZXs58groe299LNdUG02etMPyU6vfRaFJbAWx6cv9cUuw90A2I1I9RD
CEmp0e4aLr2JHZxuCp2sR8F2he5JEMawWgwrdp+YNkeJMLq1UEgzX7pqkpvxa06a
JS3AF8O2A++BkxE8toSQb95arbaAWC0G+ZR26FwSuMVSR2SYsyPv/72CRmuLROyG
wFwfI0YMgWCHWGli8L7Nzae/aVnPpM8rxj2QXGjcN/sdUWdGDfps63/ZDLRUuUD5
nfTYJLdW2wN67cExKjVOEJRJ01l75sCoqlZWtjuzTdoS7uFEgw9avZYtu8dqE7+R
-----END RSA PRIVATE KEY-----
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:
- "443:443"
# 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"
22 changes: 11 additions & 11 deletions noti-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.2.3'
id 'io.spring.dependency-management' version '1.1.4'
id "org.springdoc.openapi-gradle-plugin" version '1.8.0'
// id "org.springdoc.openapi-gradle-plugin" version '1.8.0'
}

group = 'com.waither'
Expand Down Expand Up @@ -62,16 +62,16 @@ dependencies {
testImplementation 'org.assertj:assertj-core:3.23.1'
}

openApi {
apiDocsUrl.set("http://localhost:80") // Document URL
outputDir.set(file("$rootDir/build/docs")) // Build Result Path
outputFileName.set("noti.json") // Build Result File Name
groupedApiMappings.set(Map.of("http://localhost:8082/noti/api-docs", "noti.json"))
waitTimeInSeconds.set(60) // Timeout
customBootRun {
args.add("--spring.profiles.active=dev")
}
}
//openApi {
// apiDocsUrl.set("http://localhost:80") // Document URL
// outputDir.set(file("$rootDir/build/docs")) // Build Result Path
// outputFileName.set("noti.json") // Build Result File Name
// groupedApiMappings.set(Map.of("http://localhost:8082/noti/api-docs", "noti.json"))
// waitTimeInSeconds.set(60) // Timeout
// customBootRun {
// args.add("--spring.profiles.active=dev")
// }
//}

dependencyManagement {
imports {
Expand Down
Loading
Loading