diff --git a/jenkins/Jenkinsfile-dev b/jenkins/Jenkinsfile-dev new file mode 100644 index 0000000..7ae4287 --- /dev/null +++ b/jenkins/Jenkinsfile-dev @@ -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!' + } + } +} diff --git a/Jenkinsfile b/jenkins/Jenkinsfile-prod similarity index 91% rename from Jenkinsfile rename to jenkins/Jenkinsfile-prod index 4f033c2..14052ce 100644 --- a/Jenkinsfile +++ b/jenkins/Jenkinsfile-prod @@ -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}" } @@ -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' } } diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 42fd33a..2792971 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -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, diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 39260ab..c8253c9 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -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 @@ -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,