Skip to content

Commit e970aae

Browse files
committed
test: 배포 테스트
1 parent 5c423e2 commit e970aae

File tree

7 files changed

+77
-15
lines changed

7 files changed

+77
-15
lines changed

.github/workflows/deploy.yml

Lines changed: 71 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,34 @@ jobs:
5555
id: build-image
5656
env:
5757
ECR_REPOSITORY: captioning-service
58+
IMAGE_TAG: ${{ github.sha }}
5859
run: |
59-
docker build -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest ./captioning-service
60-
docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest
60+
docker build -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} ./captioning-service
61+
docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
62+
echo "::set-output name=image::${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}"
6163
62-
- name: Update Amazon ECS service
64+
- name: Download task definition
65+
id: task-def
6366
run: |
64-
aws ecs update-service --cluster ai-services-cluster --service captioning-service --force-new-deployment --region ${{ env.AWS_REGION }}
67+
aws ecs describe-task-definition --task-definition captioning-service --query taskDefinition > task-definition.json
68+
69+
- name: Fill in the new image ID in the Amazon ECS task definition
70+
id: render-task-def
71+
uses: aws-actions/amazon-ecs-render-task-definition@v1
72+
with:
73+
task-definition: task-definition.json
74+
container-name: captioning-service # Task Definition에 정의된 컨테이너 이름
75+
image: ${{ steps.build-image.outputs.image }}
76+
77+
78+
- name: Deploy Amazon ECS task definition
79+
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
80+
with:
81+
task-definition: ${{ steps.render-task-def.outputs.task-definition }}
82+
service: captioning-service # 업데이트할 서비스 이름
83+
cluster: ai-services-cluster # 클러스터 이름
84+
wait-for-service-stability: true # 배포가 안정될 때까지 기다림
85+
6586

6687
deploy-classifying:
6788
name: Deploy Classifying Service
@@ -87,13 +108,32 @@ jobs:
87108
id: build-image
88109
env:
89110
ECR_REPOSITORY: classifying-service
111+
IMAGE_TAG: ${{ github.sha }}
90112
run: |
91-
docker build -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest ./classifying-service
92-
docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest
113+
docker build -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} ./classifying-service
114+
docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
93115
94-
- name: Update Amazon ECS service
116+
- name: Download task definition
117+
id: task-def
95118
run: |
96-
aws ecs update-service --cluster ai-services-cluster --service classifying-service --force-new-deployment --region ${{ env.AWS_REGION }}
119+
aws ecs describe-task-definition --task-definition classifying-service --query taskDefinition > task-definition.json
120+
121+
- name: Fill in the new image ID in the Amazon ECS task definition
122+
id: render-task-def
123+
uses: aws-actions/amazon-ecs-render-task-definition@v1
124+
with:
125+
task-definition: task-definition.json
126+
container-name: classifying-service # Task Definition에 정의된 컨테이너 이름
127+
image: ${{ steps.build-image.outputs.image }}
128+
129+
130+
- name: Deploy Amazon ECS task definition
131+
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
132+
with:
133+
task-definition: ${{ steps.render-task-def.outputs.task-definition }}
134+
service: classifying-service # 업데이트할 서비스 이름
135+
cluster: ai-services-cluster # 클러스터 이름
136+
wait-for-service-stability: true # 배포가 안정될 때까지 기다림
97137

98138
deploy-masking:
99139
name: Deploy Masking Service
@@ -119,10 +159,29 @@ jobs:
119159
id: build-image
120160
env:
121161
ECR_REPOSITORY: masking-service
162+
IMAGE_TAG: ${{ github.sha }}
122163
run: |
123-
docker build -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest ./masking-service
124-
docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest
164+
docker build -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} ./masking-service
165+
docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
125166
126-
- name: Update Amazon ECS service
167+
- name: Download task definition
168+
id: task-def
127169
run: |
128-
aws ecs update-service --cluster ai-services-cluster --service masking-service --force-new-deployment --region ${{ env.AWS_REGION }}
170+
aws ecs describe-task-definition --task-definition masking-service --query taskDefinition > task-definition.json
171+
172+
- name: Fill in the new image ID in the Amazon ECS task definition
173+
id: render-task-def
174+
uses: aws-actions/amazon-ecs-render-task-definition@v1
175+
with:
176+
task-definition: task-definition.json
177+
container-name: masking-service # Task Definition에 정의된 컨테이너 이름
178+
image: ${{ steps.build-image.outputs.image }}
179+
180+
181+
- name: Deploy Amazon ECS task definition
182+
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
183+
with:
184+
task-definition: ${{ steps.render-task-def.outputs.task-definition }}
185+
service: masking-service # 업데이트할 서비스 이름
186+
cluster: ai-services-cluster # 클러스터 이름
187+
wait-for-service-stability: true # 배포가 안정될 때까지 기다림

captioning-service/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ImageReq(BaseModel):
3131
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
3232
captioning_model.to(device)
3333

34-
#
34+
3535
def preproc(image_bytes: bytes) -> Image.Image:
3636
image = Image.open(BytesIO(image_bytes)).convert("RGB")
3737
return image

captioning-service/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ uvicorn
33
requests
44
python-multipart
55
transformers
6+
httpx
67
Pillow
78
--extra-index-url https://download.pytorch.org/whl/cpu
89
torch

classifying-service/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ async def classify_image(request: Request, body: ImageReq):
181181

182182
filename = body.image_url.split("/")[-1]
183183
return {"filename": filename, "result": predictions}
184-
#
184+
185185
@app.get("/health", summary="Health Check", description="Check if the service is running.")
186186
async def health_check():
187187
return {"status": "ok"}

classifying-service/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ requests
44
python-multipart
55
pydantic
66
Pillow
7+
httpx
78
--extra-index-url https://download.pytorch.org/whl/cpu
89
torch
910
torchvision

masking-service/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def mask_image(req: ImageReq):
5252
# return {"error": f"Error processing image: {e}"}
5353

5454
return {"masked_image": "masking completed"}
55-
#
55+
5656
@app.get("/health", summary="Health Check", description="Check if the service is running.")
5757
async def health_check():
5858
return {"status": "ok"}

masking-service/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ easyocr
66
numpy
77
opencv-python-headless
88
Pillow
9+
httpx
910
--extra-index-url https://download.pytorch.org/whl/cpu
1011
torch

0 commit comments

Comments
 (0)