-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
š ci/cd: ė°°ķ¬ ķź²½ źµ¬ģ¶ (#61)
š ci/cd: ė°°ķ¬ ķź²½ źµ¬ģ¶ (#61)
- Loading branch information
Showing
22 changed files
with
466 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: API Docs Integration | ||
name: api-docs-integration | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
name: Backend CI/CD with Gradle | ||
|
||
on: | ||
# workflow_dispatch: | ||
# inputs: | ||
# service: | ||
# description: 'Choose Service to deploy. Default is all.' | ||
# required: true | ||
# default: 'all' | ||
# type: choice | ||
# options: | ||
# - all | ||
# - api-gateway | ||
# - noti-service | ||
# - user-service | ||
# - weather-service | ||
push: | ||
branches: | ||
- prod | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
#Checkout : ģ½ė ź°ģ øģ¤źø° | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
#Setting JDK | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
#gradlew chmod | ||
- name: Grant execute permission for gradlew | ||
run: | | ||
chmod +x ./apiGateway-service/gradlew | ||
chmod +x ./config-service/gradlew | ||
chmod +x ./Eureka/gradlew | ||
chmod +x ./noti-service/gradlew | ||
chmod +x ./user-service/gradlew | ||
chmod +x ./weather-service/gradlew | ||
# DockerHub Login | ||
- name: Docker Hub Login | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
#Config-Service Build & Docker Push | ||
- name: Build with Gradle - config | ||
run: | | ||
cd config-service | ||
./gradlew clean build -x test | ||
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-config . | ||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/waither-config | ||
env: | ||
CONFIG_GIT_URI: ${{ secrets.CONFIG_GIT_URI }} | ||
CONFIG_PASSPHRASE: ${{ secrets.CONFIG_PASSPHRASE }} | ||
CONFIG_PRIVATE_KEY: ${{ secrets.CONFIG_PRIVATE_KEY }} | ||
|
||
#Config-Service Run | ||
- name: Run config-service | ||
run: | | ||
./gradlew bootRun & | ||
cd .. | ||
#Wait 5 sec | ||
- name: Wait for config-service to start | ||
run: sleep 5 | ||
|
||
#apiGateway-Service Build & Docker Push | ||
- name: Build with Gradle - apiGateway | ||
run: | | ||
cd apiGateway-service | ||
./gradlew clean build -x test | ||
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-gateway . | ||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/waither-gateway | ||
cd .. | ||
#Eureka Build & Docker Push | ||
- name: Build with Gradle - Eureka | ||
run: | | ||
cd Eureka | ||
./gradlew clean build -x test | ||
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-eureka . | ||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/waither-eureka | ||
cd .. | ||
#Noti-Service Build & Docker Push | ||
- name: Build with Gradle - noti-service | ||
run: | | ||
cd noti-service | ||
./gradlew clean build -x test | ||
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-noti . | ||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/waither-noti | ||
cd .. | ||
#User-Service Build & Docker Push | ||
- name: Build with Gradle - user-service | ||
run: | | ||
cd user-service | ||
./gradlew clean build -x test | ||
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-user . | ||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/waither-user | ||
cd .. | ||
#Weather-Service Build & Docker Push | ||
- name: Build with Gradle - weather-service | ||
run: | | ||
cd weather-service | ||
./gradlew clean build -x test | ||
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-weather . | ||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/waither-weather | ||
cd .. | ||
deploy: | ||
name : Connect to EC2 and re-run container | ||
needs : build | ||
runs-on : ubuntu-latest | ||
steps: | ||
- name: Deploy to Server | ||
uses: appleboy/[email protected] | ||
env: | ||
SERVICE_NAME: all | ||
with: | ||
host: ${{ secrets.EC2_HOST }} | ||
username: ${{ secrets.EC2_USERNAME }} | ||
password: ${{ secrets.EC2_PASSWORD }} | ||
port: ${{ secrets.EC2_SSH_PORT }} | ||
timeout: 60s | ||
script: | | ||
export CONFIG_GIT_URI=${{ secrets.CONFIG_GIT_URI }} | ||
export CONFIG_PASSPHRASE=${{ secrets.CONFIG_PASSPHRASE }} | ||
export CONFIG_PRIVATE_KEY=${{ secrets.CONFIG_PRIVATE_KEY_DIR }} | ||
export DOCKERHUB_USERNAME=${{ secrets.DOCKERHUB_USERNAME }} | ||
bash /home/docker_init.sh | ||
bash /home/common.sh | ||
bash /home/deploy.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Backend CI | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- prod | ||
- develop | ||
|
||
jobs: | ||
build-test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: action checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Grant execute permission for gradlew | ||
run: | | ||
chmod +x ./config-service/gradlew | ||
chmod +x ./noti-service/gradlew | ||
chmod +x ./user-service/gradlew | ||
chmod +x ./weather-service/gradlew | ||
- name: Build with Gradle - config | ||
run: | | ||
cd config-service | ||
./gradlew clean build -x test | ||
env: | ||
CONFIG_GIT_URI: ${{ secrets.CONFIG_GIT_URI }} | ||
CONFIG_PASSPHRASE: ${{ secrets.CONFIG_PASSPHRASE }} | ||
CONFIG_PRIVATE_KEY: ${{ secrets.CONFIG_PRIVATE_KEY }} | ||
|
||
- name: Run config-service | ||
run: | | ||
./gradlew bootRun & | ||
cd .. | ||
- name: Wait for config-service to start | ||
run: sleep 5 | ||
|
||
- name: Build with Gradle - noti-service | ||
run: | | ||
cd noti-service | ||
./gradlew clean build -x test | ||
cd .. | ||
- name: Build with Gradle - user-service | ||
run: | | ||
cd user-service | ||
./gradlew clean build -x test | ||
cd .. | ||
- name: Build with Gradle - weather-service | ||
run: | | ||
cd weather-service | ||
./gradlew clean build -x test | ||
cd .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM openjdk:17-jdk | ||
|
||
ARG JAR_FILE=build/libs/*.jar | ||
COPY ${JAR_FILE} app.jar | ||
ENTRYPOINT ["java", "-Dspring.profiles.active=prod", "-Duser.timezone=Asia/Seoul" , "-jar", "app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,10 @@ java { | |
sourceCompatibility = '17' | ||
} | ||
|
||
jar { | ||
enabled = false | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM openjdk:17-jdk | ||
|
||
ARG JAR_FILE=build/libs/*.jar | ||
COPY ${JAR_FILE} app.jar | ||
ENTRYPOINT ["java", "-Dspring.profiles.active=prod", "-Duser.timezone=Asia/Seoul" , "-jar", "app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,10 @@ java { | |
sourceCompatibility = '17' | ||
} | ||
|
||
jar { | ||
enabled = false | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
server: | ||
port: 8000 | ||
port: 80 | ||
|
||
spring: | ||
application: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM openjdk:17-jdk | ||
|
||
ARG JAR_FILE=build/libs/*.jar | ||
COPY ${JAR_FILE} app.jar | ||
ENTRYPOINT ["java", "-Dspring.profiles.active=prod", "-Duser.timezone=Asia/Seoul" , "-jar", "app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,10 @@ java { | |
sourceCompatibility = '17' | ||
} | ||
|
||
jar { | ||
enabled = false | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
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" | ||
restart: always | ||
volumes: | ||
- /home/ec2-user/logs/api-gateway:/logs | ||
|
||
config: | ||
container_name: config | ||
image: ${DOCKERHUB_USERNAME}/waither-config | ||
expose: | ||
- "8888" | ||
environment: | ||
CONFIG_GIT_URI : ${CONFIG_GIT_URI} | ||
CONFIG_PASSPHRASE : ${CONFIG_PASSPHRASE} | ||
CONFIG_PRIVATE_KEY : ${CONFIG_PRIVATE_KEY} | ||
restart: always | ||
volumes: | ||
- /home/ec2-user/logs/config:/logs | ||
|
||
eureka: | ||
container_name: eureka | ||
image: ${DOCKERHUB_USERNAME}/waither-eureka | ||
expose: | ||
- "8761" | ||
restart: always | ||
volumes: | ||
- /home/ec2-user/logs/eureka:/logs | ||
|
||
user-service: | ||
container_name: user-service | ||
image: ${DOCKERHUB_USERNAME}/waither-user | ||
expose: | ||
- "8080" | ||
restart: unless-stopped #ģėģ¼ė” ģ¤ģ§ėģ§ ģė ģ“ģ ķģ ģ¬ģ¤ķ | ||
volumes: | ||
- /home/ec2-user/logs/user-service:/logs | ||
|
||
weather-service: | ||
container_name: weather-service | ||
image: ${DOCKERHUB_USERNAME}/waither-weather | ||
expose: | ||
- "8081" | ||
restart: unless-stopped | ||
volumes: | ||
- /home/ec2-user/logs/weather-service:/logs | ||
|
||
noti-service: | ||
container_name: noti-service | ||
image: ${DOCKERHUB_USERNAME}/waither-noti | ||
expose: | ||
- "8082" | ||
restart: unless-stopped | ||
volumes: | ||
- /home/ec2-user/logs/noti-service:/logs | ||
|
||
zookeeper: | ||
image: wurstmeister/zookeeper:latest | ||
container_name: zookeeper | ||
ports: | ||
- "2181:2181" | ||
- | ||
kafka: | ||
image: wurstmeister/kafka:latest | ||
container_name: kafka | ||
ports: | ||
- "9092:9092" | ||
environment: | ||
KAFKA_ADVERTISED_HOST_NAME: 127.0.0.1 | ||
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM openjdk:17-jdk | ||
|
||
ARG JAR_FILE=build/libs/*.jar | ||
COPY ${JAR_FILE} app.jar | ||
ENTRYPOINT ["java", "-Dspring.profiles.active=prod", "-Duser.timezone=Asia/Seoul" , "-jar", "app.jar"] |
Oops, something went wrong.