Skip to content

Commit

Permalink
fix: FastAPI 마이그레이션 및 BellSoft JDK 환경에서의 파이썬 스크립트 실행 오류 해결 완료 (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
limehee committed Jan 4, 2025
1 parent 648959e commit 2f2e5a0
Show file tree
Hide file tree
Showing 20 changed files with 1,118 additions and 351 deletions.
2 changes: 2 additions & 0 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ object Dependencies {
const val owaspJavaHtmlSanitizer =
"com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:${Versions.owaspJavaHtmlSanitizer}"
const val googleAuthenticator = "com.warrenstrange:googleauth:${Versions.googleAuthenticator}"
const val apacheHttpClient = "org.apache.httpcomponents.client5:httpclient5:${Versions.apacheHttpClient}"

// Test dependencies
const val springBootStarterTest = "org.springframework.boot:spring-boot-starter-test"
const val springSecurityTest = "org.springframework.security:spring-security-test"
const val mockWebServer = "com.squareup.okhttp3:mockwebserver:${Versions.mockWebServer}"
}
2 changes: 2 additions & 0 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ object Versions {
const val sonarQube = "6.0.1.5171"
const val checkStyle = "10.20.2"
const val jacoco = "0.8.12"
const val apacheHttpClient = "5.2.3"
const val mockWebServer = "4.12.0"
}
File renamed without changes.
24 changes: 24 additions & 0 deletions cd/Dockerfile.rhythm
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Python 3.9 slim 베이스
FROM python:3.9-slim

# ffmpeg 설치 (pydub 라이브러리 의존성)
RUN apt-get update \
&& apt-get install -y ffmpeg \
&& rm -rf /var/lib/apt/lists/*

# 작업 디렉터리 지정
WORKDIR /app

# 파이썬 패키지 설치
COPY stempo-rhythm/requirements.txt /app/
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt

# 소스 복사
COPY stempo-rhythm/main.py /app/

# FastAPI 서버를 위한 포트 노출
EXPOSE 5000

# Uvicorn으로 FastAPI 서버 실행
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "5000"]
57 changes: 35 additions & 22 deletions jenkins/Jenkinsfile → cd/Jenkinsfile.core
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,28 @@ pipeline {
}

stages {
stage('Check for Python-only Changes') {
steps {
script {
def changedFiles = sh(script: "git diff --name-only HEAD~1..HEAD", returnStdout: true).trim().split('\n')
def hasNonPythonChange = changedFiles.any {
!it.startsWith("stempo-rhythm/")
}

if (!hasNonPythonChange) {
echo "Only Python code changed. Skipping pipeline."
error("Aborting pipeline because only Python code changed.")
}
}
}
}

stage('Load Environment Variables') {
steps {
script {
FAILED_STAGE = env.STAGE_NAME
}
withCredentials([file(credentialsId: 'stempo_prod_config_yml', variable: 'CONFIG_FILE')]) {
withCredentials([file(credentialsId: 'stempo_prod_core_config_yml', variable: 'CONFIG_FILE')]) {
script {
loadEnvironmentVariables(env.CONFIG_FILE)
}
Expand All @@ -25,7 +41,7 @@ pipeline {
stage('Configure Centralized Spring Profiles') {
steps {
script {
configureModuleProfile('stempo_prod_yml', env.RESOURCES_PATH, env.PROFILE_FILE_NAME)
configureModuleProfile('stempo_prod_core_yml', env.RESOURCES_PATH, env.PROFILE_FILE_NAME)
}
}
}
Expand Down Expand Up @@ -134,7 +150,7 @@ def sendSlackBuildNotification(String message, String color) {

def createSlackPayload(String message, String color, String jobUrl, String consoleOutputUrl) {
return [
blocks: [
blocks : [
[
type: "section",
text: [
Expand All @@ -145,7 +161,7 @@ def createSlackPayload(String message, String color, String jobUrl, String conso
],
attachments: [
[
color: color,
color : color,
blocks: [
[
type: "section",
Expand All @@ -155,26 +171,26 @@ def createSlackPayload(String message, String color, String jobUrl, String conso
]
],
[
type: "actions",
type : "actions",
elements: [
[
type: "button",
text: [
type: "plain_text",
text: "Job",
type : "button",
text : [
type : "plain_text",
text : "Job",
emoji: true
],
url: jobUrl,
url : jobUrl,
value: "click_job"
],
[
type: "button",
text: [
type: "plain_text",
text: "Console Output",
type : "button",
text : [
type : "plain_text",
text : "Console Output",
emoji: true
],
url: consoleOutputUrl,
url : consoleOutputUrl,
value: "click_console_output"
]
]
Expand Down Expand Up @@ -212,12 +228,10 @@ def loadEnvironmentVariables(String configFile) {

env.DOCKER_HUB_REPO = config.dockerhub.repo

env.HOST_CONFIG_PATH = config.host.'config-path'
env.HOST_CLOUD_PATH = config.host.'cloud-path'
env.HOST_DEFAULT_PATH = config.host.'default-path'
env.HOST_LOGS_PATH = config.host.'logs-path'

env.CONTAINER_CONFIG_PATH = config.container.'config-path'
env.CONTAINER_CLOUD_PATH = config.container.'cloud-path'
env.CONTAINER_DEFAULT_PATH = config.container.'default-path'
env.CONTAINER_LOGS_PATH = config.container.'logs-path'

env.BLUE_CONTAINER = config.containers.blue
Expand Down Expand Up @@ -336,8 +350,7 @@ def deployNewInstance() {
docker run -d --name ${env.DEPLOY_CONTAINER} \\
-p ${env.NEW_PORT}:8080 \\
--network ${env.APPLICATION_NETWORK} \\
-v ${env.HOST_CONFIG_PATH}:${env.CONTAINER_CONFIG_PATH} \\
-v ${env.HOST_CLOUD_PATH}:${env.CONTAINER_CLOUD_PATH} \\
-v ${env.HOST_DEFAULT_PATH}:${env.CONTAINER_DEFAULT_PATH} \\
-v ${env.HOST_LOGS_PATH}:${env.CONTAINER_LOGS_PATH} \\
-e LOG_PATH=${env.CONTAINER_LOGS_PATH} \\
-e SPRING_PROFILES_ACTIVE=${env.PROFILE} \\
Expand Down Expand Up @@ -371,7 +384,7 @@ def performHealthCheck() {
echo "Checking health... ${elapsed} seconds elapsed."
def status = sh(
script: """curl -s -u ${env.WHITELIST_ADMIN_USERNAME}:${env.WHITELIST_ADMIN_PASSWORD} \
http://${PUBLIC_IP}:${env.NEW_PORT}/actuator/health | grep 'UP'""",
http://${PUBLIC_IP}:${env.NEW_PORT}${env.ACTUATOR_PATH} | grep 'UP'""",
returnStatus: true
)
if (status == 0) {
Expand Down
Loading

0 comments on commit 2f2e5a0

Please sign in to comment.