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

Feat/#99/implement cicd(swm 296) #104

Merged
merged 19 commits into from
Sep 27, 2023
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
66 changes: 66 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Java CI with Gradle

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'

## gradlew 의 권한을 줍니다.
- name: Grant execute permission for gradlew
run: chmod +x gradlew

## gradle build
- name: Build with Gradle
run: ./gradlew clean build -x test

## AWS에 로그인
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

## ECR에 로그인
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

## ECR에 이미지 업로드
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: be-repo
IMAGE_TAG: release
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "IMAGE=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_ENV
## ECS task 정의
- name: Push the image ID in the ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: backend-container
image: ${{ env.IMAGE }}
## ECS 실행
- name: Deploy ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: be-service
cluster: be-cluster
wait-for-service-stability: true
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

**❗️❗️매우 중요❗️❗️**

db 접근정보 등 민감정보를 보호하기 위해 gitignore된 파일들이 존재합니다.
sroom 개발자에게 문의한 후 secure.properties, schema.sql를 패키지에 포함시켜야 실행됩니다. 단, 파일이 github에 공개되지 않도록 다음과 같이 캐시를 삭제한 후 커밋해주세요.
gitignore된 파일들이 존재합니다.
sroom 개발자에게 문의한 후 schema.sql를 패키지에 포함시켜야 실행됩니다. 파일이 github에 공개되지 않도록 다음과 같이 캐시를 삭제한 후 커밋해주세요.
```bash
git rm -r --cached .
git add .
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/m9d/sroom/gpt/service/GPTService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
@RequiredArgsConstructor
public class GPTService {

@Value("${gpt.request-url}")
@Value("${ai.request-url}")
private String gptRequestUrl;

@Value("${gpt.result-url}")
@Value("${ai.result-url}")
private String gptResultUrl;

private final WebClient webClient;
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ spring:

youtube:
base-url: https://www.googleapis.com/youtube/v3
gpt:
request-url : http://127.0.0.1:8000
result-url: http://127.0.0.1:8000/results
ai:
request-url : http://43.200.123.116:8000
result-url: http://43.200.123.116:8000/results

aws:
kms:
Expand Down
73 changes: 73 additions & 0 deletions task-definition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"ipcMode": null,
"executionRoleArn": "arn:aws:iam::224066583965:role/AWSECSTaskExecutionRole",
"containerDefinitions": [
{
"dnsSearchDomains": null,
"environmentFiles": null,
"logConfiguration": {
"logDriver": "awslogs",
"secretOptions": null,
"options": {
"awslogs-group": "/ecs/backend-task",
"awslogs-region": "ap-northeast-2",
"awslogs-stream-prefix": "ecs"
}
},
"entryPoint": null,
"portMappings": [
{
"hostPort": 0,
"protocol": "tcp",
"containerPort": 8080
}
],
"command": null,
"linuxParameters": null,
"cpu": 0,
"environment": [],
"resourceRequirements": null,
"ulimits": null,
"dnsServers": null,
"mountPoints": [],
"workingDirectory": null,
"secrets": null,
"dockerSecurityOptions": null,
"memory": null,
"memoryReservation": 500,
"volumesFrom": [],
"stopTimeout": null,
"image": "224066583965.dkr.ecr.ap-northeast-2.amazonaws.com/be-repo:release",
"startTimeout": null,
"firelensConfiguration": null,
"dependsOn": null,
"disableNetworking": null,
"interactive": null,
"healthCheck": null,
"essential": true,
"links": null,
"hostname": null,
"extraHosts": null,
"pseudoTerminal": null,
"user": null,
"readonlyRootFilesystem": null,
"dockerLabels": null,
"systemControls": null,
"privileged": null,
"name": "backend-container"
}
],
"placementConstraints": [],
"memory": null,
"taskRoleArn": "arn:aws:iam::224066583965:role/AWSECSTaskExecutionRole",
"family": "backend-task",
"pidMode": null,
"requiresCompatibilities": [
"EC2"
],
"networkMode": "bridge",
"cpu": null,
"inferenceAccelerators": null,
"proxyConfiguration": null,
"volumes": []
}