Skip to content
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
59 changes: 59 additions & 0 deletions .aws/ecs-task-definition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"containerDefinitions": [
{
"name": "xrpedia-ai-proxy",
"image": "864981757354.dkr.ecr.ap-northeast-2.amazonaws.com/xrpedia/ai-proxy:prod",
"cpu": 0,
"portMappings": [
{
"name": "xrpedia-ai-proxy-http",
"containerPort": 8080,
"hostPort": 8080,
"protocol": "tcp",
"appProtocol": "http"
}
],
"essential": true,
"environment": [
],
"environmentFiles": [],
"mountPoints": [],
"volumesFrom": [],
"secrets": [
],
"ulimits": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/xrpedia-ai-proxy",
"mode": "non-blocking",
"awslogs-create-group": "true",
"max-buffer-size": "25m",
"awslogs-region": "ap-northeast-2",
"awslogs-stream-prefix": "ecs"
},
"secretOptions": []
},
"systemControls": []
}
],
"family": "xrpedia-ai-proxy",
"executionRoleArn": "arn:aws:iam::864981757354:role/ecsTaskExecutionRole",
"networkMode": "awsvpc",
"volumes": [],
"placementConstraints": [],
"compatibilities": [
"EC2",
"FARGATE"
],
"requiresCompatibilities": [
"FARGATE"
],
"cpu": "256",
"memory": "512",
"runtimePlatform": {
"cpuArchitecture": "X86_64",
"operatingSystemFamily": "LINUX"
},
"tags": []
}
22 changes: 22 additions & 0 deletions .github/issue_template/chore-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: chore Template
about: chore Template 입니다
title: "[Chore] "
labels: ""
assignees: ""
---

## 🫶🏻 Description

**_해당 이슈에 대한 설명을 작성해주세요._**

## 🧑🏻‍💻 Tasks

**_해당 이슈 해결을 위해 해야할 작업들 목록을 작성해주세요._**

- [ ] 예시1
- [ ] 예시2

## 🐳 ETC

**_기타 특이사항을 작성해주세요._**
22 changes: 22 additions & 0 deletions .github/issue_template/feature-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Feature Template
about: Feature Template 입니다
title: "[Feat] "
labels: ""
assignees: ""
---

## 🫶🏻 Description

**_해당 이슈에 대한 설명을 작성해주세요._**

## 🧑🏻‍💻 Tasks

**_해당 이슈 해결을 위해 해야할 작업들 목록을 작성해주세요._**

- [ ] 예시1
- [ ] 예시2

## 🐳 ETC

**_기타 특이사항을 작성해주세요._**
5 changes: 5 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## 작업 내역 (관련 이슈)
-

## 특이 사항
-
81 changes: 81 additions & 0 deletions .github/workflows/cd-ecs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Deploy to Amazon ECS

on:
push:
branches: [ "main" ]

env:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ROLE: ${{ secrets.AWS_ROLE }}
ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }}
ECS_SERVICE: ${{ vars.ECS_SERVICE }}
ECS_CLUSTER: ${{ vars.ECS_CLUSTER }}
ECS_TASK_DEFINITION: ${{ vars.ECS_TASK_DEFINITION }}
CONTAINER_NAME: ${{ vars.CONTAINER_NAME }}
TEST_IMAGE_NAME: xrpedia-ai-proxy-test
permissions:
contents: read
id-token: write

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
environment: development

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ env.AWS_ROLE }}
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'

- name: Build the Docker image for Test
id: build-test-image
env:
TEST_IMAGE_NAME: ${{ env.TEST_IMAGE_NAME }}
run: docker build --target tester -t ${{ env.TEST_IMAGE_NAME }} .

- name: Run Test
id: run-test
run: |
docker run --rm \
${{ env.TEST_IMAGE_NAME }}

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: prod
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build --platform=linux/amd64 --target runner -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT

- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true
25 changes: 25 additions & 0 deletions .github/workflows/ci-pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI with Pytest in Docker

on:
pull_request:
branches: [ "develop", "main" ]

env:
TEST_IMAGE_NAME: xrpedia-ai-proxy-test

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Build the Docker image for Test
id: build-test-image
run: docker build --target tester -t ${{ env.TEST_IMAGE_NAME }} .

- name: Run Test
id: run-test
run: |
docker run --rm \
${{ env.TEST_IMAGE_NAME }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,5 @@ cython_debug/

# PyPI configuration file
.pypirc

.DS_Store
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# TESTER
FROM python:3.13-alpine AS tester

RUN ln -snf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
RUN echo Asia/Seoul > /etc/timezone

WORKDIR /app
COPY src ./src
COPY pyproject.toml poetry.lock README.md ./

RUN pip install poetry
RUN poetry config virtualenvs.in-project true
RUN poetry config virtualenvs.path "./.venv"

RUN poetry install

ENTRYPOINT ["poetry", "run", "pytest", "/app/src/tests", "-v"]


# RUNNER
FROM python:3.13-alpine AS runner

RUN ln -snf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
RUN echo Asia/Seoul > /etc/timezone

WORKDIR /app
COPY --from=tester /app .

RUN pip install poetry
RUN poetry config virtualenvs.in-project true
RUN poetry config virtualenvs.path "./.venv"

RUN poetry install

ENTRYPOINT ["poetry", "run", "uvicorn", "src.app:app", "--host", "0.0.0.0", "--port", "8080"]
Loading