fix: Jenkinsfile 프론트 빌드 소스 복사 방식 수정
Some checks failed
SPMS_BO/pipeline/head There was a failure building this commit
Some checks failed
SPMS_BO/pipeline/head There was a failure building this commit
정지된 컨테이너에 docker cp하면 바인드 마운트에 반영되지 않아 호스트 볼륨의 옛날 소스로 빌드되는 문제 해결. 임시 alpine 컨테이너를 통해 호스트 볼륨에 직접 복사하도록 변경. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e8edbb528c
commit
bb82846d59
30
Jenkinsfile
vendored
30
Jenkinsfile
vendored
|
|
@ -1,6 +1,6 @@
|
|||
def TARGET_FRONT_BUILD = ''
|
||||
def TARGET_RUN_SERVER = ''
|
||||
def CONTAINER_SRC_PATH = '/src'
|
||||
def FRONT_HOST_PATH = '/volume1/SPMS/PROJECT/Application/Front'
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
|
|
@ -13,7 +13,6 @@ pipeline {
|
|||
echo "Current Branch: ${branchName}"
|
||||
|
||||
if (branchName == 'develop') {
|
||||
// develop 브랜치 -> Debug 컨테이너
|
||||
TARGET_FRONT_BUILD = 'spms-front-build-debug'
|
||||
TARGET_RUN_SERVER = 'spms-run-debug'
|
||||
echo "[DEV Mode] Target: DEBUG Container"
|
||||
|
|
@ -38,19 +37,26 @@ pipeline {
|
|||
}
|
||||
}
|
||||
|
||||
// [3단계] 컨테이너로 소스 복사
|
||||
stage('Copy to Container') {
|
||||
// [3단계] 실행 중인 임시 컨테이너를 통해 호스트 볼륨에 소스 복사
|
||||
// (정지된 컨테이너에 docker cp하면 바인드 마운트에 반영 안 됨)
|
||||
stage('Copy to Host Volume') {
|
||||
steps {
|
||||
script {
|
||||
def sourcePath = "${WORKSPACE}/react/."
|
||||
echo "Copying from ${sourcePath} to ${TARGET_FRONT_BUILD}"
|
||||
def containerId = sh(script: "docker ps -aqf 'name=${TARGET_FRONT_BUILD}'", returnStdout: true).trim()
|
||||
echo "Copying source to host volume (${FRONT_HOST_PATH})..."
|
||||
|
||||
if (containerId) {
|
||||
sh "docker cp ${sourcePath} ${TARGET_FRONT_BUILD}:${CONTAINER_SRC_PATH}"
|
||||
} else {
|
||||
error "Container ${TARGET_FRONT_BUILD} not found!"
|
||||
}
|
||||
sh """
|
||||
docker rm -f spms-source-copy 2>/dev/null || true
|
||||
docker run -d --name spms-source-copy \
|
||||
-v ${FRONT_HOST_PATH}:/target \
|
||||
alpine sleep 30
|
||||
docker exec spms-source-copy sh -c \
|
||||
'find /target -mindepth 1 -maxdepth 1 ! -name node_modules -exec rm -rf {} +'
|
||||
docker cp ${sourcePath} spms-source-copy:/target/
|
||||
docker rm -f spms-source-copy
|
||||
"""
|
||||
|
||||
echo "Source copy complete."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -58,7 +64,7 @@ pipeline {
|
|||
stage('Build Frontend') {
|
||||
steps {
|
||||
script {
|
||||
echo "Starting React Build..."
|
||||
echo "Starting React Build (npm install + build + deploy)..."
|
||||
sh "docker start -a ${TARGET_FRONT_BUILD}"
|
||||
echo "React Build Complete."
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user