Skip to content

Commit

Permalink
[hotfix] Prod/Dev 배포 설정 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
JeongSangByuk committed Sep 8, 2024
1 parent b332466 commit 9f2f503
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 10 deletions.
77 changes: 77 additions & 0 deletions jenkins/Jenkinsfile-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
pipeline {
agent any

tools {
jdk 'JDK21'
}

environment {
DOCKERHUB_CREDENTIALS = credentials('dockerhub-credentials-id')
DOCKER_IMAGE = credentials('docker-image-dev')
K8S_URL = credentials('k8s-url')
K8S_NAMESPACE = credentials('k8s-namespace')
K8S_DEPLOY_NAME = credentials('k8s-deploy-name-dev')
JAVA_HOME = "${tool 'JDK21'}"
PATH = "${env.JAVA_HOME}/bin:${env.PATH}"
}

stages {
stage('Checkout') {
steps {
checkout scm
}
}

stage('Build & Test') {
steps {
script {
sh 'mkdir -p $WORKSPACE/src/main/resources/static/docs && touch $WORKSPACE/src/main/resources/static/docs/open-api-3.0.1.json'
sh './gradlew clean build -x test'
sh './gradlew openapi3'
}
}
post {
failure {
error 'Deployment failed!'
}
}
}

stage('Login'){
steps{
sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin' // docker hub 로그인
}
}

stage('Build & Push Docker Image') {
steps {
script {
sh 'docker buildx build --push --platform linux/amd64 --build-arg PROFILE=dev -t $DOCKER_IMAGE .'
}
}
}

stage('ssh-test') {
steps{
script{
sshagent (credentials: ['ncp-key']) {
sh """
ssh -o StrictHostKeyChecking=no ${K8S_URL} << EOF
microk8s kubectl rollout restart deploy ${K8S_DEPLOY_NAME} -n=${K8S_NAMESPACE}
"""
}
}
}
}

}

post {
success {
echo 'Deployment was successful!'
}
failure {
error 'Deployment failed!'
}
}
}
6 changes: 3 additions & 3 deletions Jenkinsfile → jenkins/Jenkinsfile-prod
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ pipeline {

environment {
DOCKERHUB_CREDENTIALS = credentials('dockerhub-credentials-id')
DOCKER_IMAGE = credentials('docker-image')
DOCKER_IMAGE = credentials('docker-image-prod')
K8S_URL = credentials('k8s-url')
K8S_NAMESPACE = credentials('k8s-namespace')
K8S_DEPLOY_NAME = credentials('k8s-deploy-name')
K8S_DEPLOY_NAME = credentials('k8s-deploy-name-prod')
JAVA_HOME = "${tool 'JDK21'}"
PATH = "${env.JAVA_HOME}/bin:${env.PATH}"
}
Expand All @@ -26,7 +26,7 @@ pipeline {
steps {
script {
sh 'mkdir -p $WORKSPACE/src/main/resources/static/docs && touch $WORKSPACE/src/main/resources/static/docs/open-api-3.0.1.json'
sh './gradlew clean build'
sh './gradlew clean build -x test'
sh './gradlew openapi3'
}
}
Expand Down
16 changes: 14 additions & 2 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@ spring:

logging:
level:
org.springframework.orm.jpa: INFO
org.springframework.transaction: INFO
root: info
org.springframework.security: info

server:
forward-headers-strategy: framework

management:
endpoints:
enabled-by-default: false
web:
base-path: /api/health-check
endpoint:
health:
enabled: true

cors-allowed-origins:
http://localhost:8080,
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ spring:
activate:
on-profile: prod
jpa:
properties:
hibernate:
show_sql: true
format_sql: true
use_sql_comments: true
hibernate:
ddl-auto: update

Expand All @@ -23,6 +18,11 @@ management:
health:
enabled: true

logging:
level:
root: error
org.springframework.security: error

cors-allowed-origins:
https://bbogak.com,
https://www.bbogak.com,
Expand Down

0 comments on commit 9f2f503

Please sign in to comment.