Add Jenkinsfile for CI pipeline
This commit is contained in:
27
Dockerfile
Normal file
27
Dockerfile
Normal file
@@ -0,0 +1,27 @@
|
||||
# Node.js 20 버전 공식 이미지를 기반으로 사용
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
# 작업 디렉토리 설정
|
||||
WORKDIR /app
|
||||
|
||||
# package.json과 package-lock.json 파일 복사
|
||||
COPY package*.json ./
|
||||
|
||||
# 프로젝트 의존성 설치
|
||||
RUN npm install
|
||||
|
||||
# 소스 코드 복사
|
||||
COPY . .
|
||||
|
||||
# 애플리케이션 빌드
|
||||
RUN npm run build
|
||||
|
||||
# 프로덕션 환경을 위한 nginx 설정
|
||||
FROM nginx:alpine
|
||||
COPY --from=builder /app/build /usr/share/nginx/html
|
||||
|
||||
# nginx 포트 노출
|
||||
EXPOSE 80
|
||||
|
||||
# nginx 실행
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
52
Jenkinsfile
vendored
Normal file
52
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
// Jenkinsfile
|
||||
pipeline {
|
||||
// Kubernetes Agent를 사용하여 파이프라인 실행
|
||||
agent {
|
||||
kubernetes {
|
||||
// Kaniko 빌드를 위한 Pod 템플릿 정의
|
||||
yaml '''
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
spec:
|
||||
containers:
|
||||
- name: kaniko
|
||||
image: gcr.io/kaniko-project/executor:debug
|
||||
command: ['sleep']
|
||||
args: ['infinity']
|
||||
volumeMounts:
|
||||
- name: registry-credentials
|
||||
mountPath: /kaniko/.docker
|
||||
volumes:
|
||||
- name: registry-credentials
|
||||
secret:
|
||||
secretName: registry-credentials
|
||||
items:
|
||||
- key: .dockerconfigjson
|
||||
path: config.json
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Checkout Source Code') {
|
||||
steps {
|
||||
// 5.3.2에서 생성한 Gitea 저장소에서 소스를 가져옵니다.
|
||||
// Jenkins Credential에 Gitea 접근 정보를 미리 등록해야 합니다.
|
||||
git branch: 'main', url: 'https://git.123.41.33.73.sslip.io/admin/my-app.git'
|
||||
}
|
||||
}
|
||||
stage('Build and Push with Kaniko') {
|
||||
steps {
|
||||
// kaniko 컨테이너 내에서 이미지 빌드 및 푸시 명령을 실행합니다.
|
||||
container(name: 'kaniko') {
|
||||
sh '''
|
||||
/kaniko/executor \\
|
||||
--context=dir://. \\
|
||||
--dockerfile=Dockerfile \\
|
||||
--destination=hol3imgreg-eilodcty.scr.private.kr-west1.e.samsungsdscloud.com/web-app/my-app:latest
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user