Skip to content

Commit

Permalink
Create Jenkinsfile
Browse files Browse the repository at this point in the history
Update deploy.yml
Update Jenkinsfile
Update Jenkinsfile
Update Jenkinsfile
Update Jenkinsfile
Update deploy.yml
Update Dockerfile
  • Loading branch information
Miensoap committed May 24, 2024
1 parent d38ff9c commit 262d393
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 4 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: CD with Gradle
on:
push:
branches: [ "Deploy" ]
pull_request:
branches: [ "Deploy" ]

permissions:
contents: read
Expand Down
55 changes: 55 additions & 0 deletions be/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
pipeline {
agent any

environment {
DOCKERHUB_CREDENTIALS = credentials('docker-hub-credentials')
DOCKER_IMAGE = 'miensoap/issue-tracker'
}

stages {

stage('github-clone') {
steps {
git branch: 'Deploy',
credentialsId: 'github-token',
url: 'https://github.com/codesquad-masters2024-team01/issue-tracker'
}
}

stage('build-docker-image') {
steps {
script {
dir('be/issue_tracker') {
// Bash 사용하여 Docker 이미지 빌드
sh 'docker build -t ${DOCKER_IMAGE}:${BUILD_ID} . '
}
}
}
}

stage('docker-login') {
steps {
script {
// Docker Hub 로그인
sh "echo ${DOCKERHUB_CREDENTIALS_PSW} | docker login -u ${DOCKERHUB_CREDENTIALS_USR} --password-stdin"
}
}
}

stage('push-docker-image') {
steps {
script {
// Docker 이미지 푸시
sh 'docker push ${DOCKER_IMAGE}:${env.BUILD_ID}'
}
}
}
}

post {
always {
// Clean up Docker images after the build
sh 'docker rmi ${DOCKER_IMAGE}:${env.BUILD_ID}'
}
}
}
4 changes: 2 additions & 2 deletions be/issue_tracker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar

EXPOSE 8080

ENTRYPOINT ["java","-jar","/app.jar"]
ENV TZ Asia/Seoul
ENTRYPOINT ["java","-jar","/app.jar"]

0 comments on commit 262d393

Please sign in to comment.