Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
25 changes: 25 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: 'Feature'
labels:
- 'enhancement'
- title: 'Bug Fixes'
labels:
- 'bug'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
template: |
## Changes
$CHANGES
130 changes: 130 additions & 0 deletions .github/workflows/ci-java.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: CI (Java)

on:
push:
branches:
- main
paths:
- "apps/user-service/**"
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- main
- develop
- release/**
paths:
- "apps/user-service/**"

permissions:
contents: read
packages: write
security-events: write
checks: write
pull-requests: write

jobs:
spotless-check:
name: Lint Check
runs-on: ubuntu-latest

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

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: 'gradle'

- name: Grant execute permission for Gradle wrapper
run: chmod +x ./gradlew
working-directory: apps/user-service

- name: Run Spotless Check
run: ./gradlew spotlessCheck
working-directory: apps/user-service

build:
name: Build
runs-on: ubuntu-latest
needs: spotless-check
strategy:
matrix:
java-version: [ "21" ]

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

- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
java-version: '${{ matrix.java-version }}'
distribution: 'temurin'
cache: 'gradle'

- name: Grant execute permission for Gradle wrapper
run: chmod +x ./gradlew
working-directory: apps/user-service

- name: Run Gradle Build
run: ./gradlew build -x test
working-directory: apps/user-service

# - name: Run Tests
# run: |
# if [ "${{ github.base_ref }}" == "main" ]; then
# ./gradlew test
# else
# ./gradlew prTest
# fi
# working-directory: apps/user-service
- name: Upload build artifacts
if: matrix.java-version == '21' && github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: apps/user-service/build/libs/

docker:
name: Build Spring Boot Docker Image and push to registry
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
needs:
- build

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

- name: Download build artifacts (JAR)
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: apps/user-service/build/libs/

- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set repo lowercase
run: echo "REPO_LC=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./apps/user-service
push: true
tags: |
ghcr.io/${{ env.REPO_LC }}/user-service:latest
ghcr.io/${{ env.REPO_LC }}/user-service:${{ github.sha }}

- name: Analyze image layers
run: |
echo "=== Image Layer Analysis ==="
docker history ghcr.io/${{ env.REPO_LC }}/user-service:latest --human --no-trunc
74 changes: 74 additions & 0 deletions .github/workflows/deploy-java.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Deploy

on:
workflow_dispatch:
push:
tags:
- 'v*'

jobs:
deploy:
name: Deploy to AWS EC2
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set repo lowercase
run: echo "REPO_LC=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV

- name: Copy docker compose files to EC2
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
source: "docker/production/docker-compose.yml"
target: "~/app"

- name: Deploy on EC2
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.SERVER_HOST }}
# username: ${{ secrets.SERVER_USER }}
username: ubuntu
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
cd ~/app/docker/production
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

docker pull ghcr.io/${{ env.REPO_LC }}/user-service:latest

docker compose down
docker compose up -d

sleep 10
docker compose ps

docker image prune -f

# - name: Send Discord notification - Success
# if: success()
# uses: Ilshidur/action-discord@master
# env:
# DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
# with:
# args: |
# **배포 성공**
# **Repository:** ${{ env.REPO_LC }}
# **Tag:** ${{ github.ref_name }}
# **Server:** ${{ secrets.SERVER_HOST }}
# **Status:** Success!
#
# - name: Send Discord notification - Failure
# if: failure()
# uses: Ilshidur/action-discord@master
# env:
# DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
# with:
# args: |
# **배포 실패**
# **Repository:** ${{ env.REPO_LC }}
# **Tag:** ${{ github.ref_name }}
# **Error:** 배포 중 오류가 발생했습니다.
# **Check:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
34 changes: 34 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release Drafter

on:
push:
branches:
- main
pull_request:
types: [opened, reopened, synchronize]
permissions:
contents: read

jobs:
update_release_draft:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
# (Optional) GitHub Enterprise requires GHE_HOST variable set
#- name: Set GHE_HOST
# run: |
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV

# Drafts your next Release notes as Pull Requests are merged into "main"
- uses: release-drafter/release-drafter@v5
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
# with:
# config-name: my-config.yml
# disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.idea
.idea
logs
*.log
Empty file.
Empty file.
Empty file.
12 changes: 12 additions & 0 deletions apps/pre-processing-service/app/api/endpoints/embedding.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# app/api/endpoints/embedding.py
from fastapi import APIRouter
from app.decorators.logging import log_api_call
from ...errors.CustomException import *
from fastapi import APIRouter

# 이 파일만의 독립적인 라우터를 생성합니다.
router = APIRouter()

@router.get("/")
async def root():
return {"message": "Items API"}
12 changes: 12 additions & 0 deletions apps/pre-processing-service/app/api/endpoints/processing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# app/api/endpoints/embedding.py
from fastapi import APIRouter
from app.decorators.logging import log_api_call
from ...errors.CustomException import *
from fastapi import APIRouter

# 이 파일만의 독립적인 라우터를 생성합니다.
router = APIRouter()

@router.get("/")
async def root():
return {"message": "사용자API"}
35 changes: 35 additions & 0 deletions apps/pre-processing-service/app/api/endpoints/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# app/api/endpoints/embedding.py
from fastapi import APIRouter
from app.decorators.logging import log_api_call
from ...errors.CustomException import *
from fastapi import APIRouter

# 이 파일만의 독립적인 라우터를 생성합니다.
router = APIRouter()

@router.get("/")
async def root():
return {"message": "테스트 API"}


@router.get("/hello/{name}" , tags=["hello"])
# @log_api_call
async def say_hello(name: str):
return {"message": f"Hello {name}"}


# 특정 경로에서 의도적으로 에러 발생
#커스텀에러 테스터 url
@router.get("/error/{item_id}")
async def trigger_error(item_id: int):
if item_id == 0:
raise InvalidItemDataException()

if item_id == 404:
raise ItemNotFoundException(item_id=item_id)

if item_id == 500:
raise ValueError("이것은 테스트용 값 오류입니다.")


return {"result": item_id}
29 changes: 29 additions & 0 deletions apps/pre-processing-service/app/api/router.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# app/api/router.py
from fastapi import APIRouter
from .endpoints import embedding, processing,test
from ..core.config import settings

api_router = APIRouter()

# embedding API URL
api_router.include_router(embedding.router, prefix="/emb", tags=["Embedding"])

# processing API URL
api_router.include_router(processing.router, prefix="/prc", tags=["Processing"])

#모듈 테스터를 위한 endpoint
api_router.include_router(test.router, prefix="/test", tags=["Test"])

@api_router.get("/")
async def root():
return {"message": "서버 실행중입니다."}

@api_router.get("/db")
def get_settings():
"""
환경 변수가 올바르게 로드되었는지 확인하는 엔드포인트
"""
return {
"환경": settings.env_name,
"데이터베이스 URL": settings.db_url
}
Empty file.
Loading
Loading