diff --git a/Jenkinsfile b/Jenkinsfile index 8ec90bcff..795c7f68f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,16 +8,6 @@ node { checkout scm sh './jenkins/scripts/test.sh' } - stage('Build image') { - checkout scm - docker.image('ubuntu:alpine') { - withCredentials([usernamePassword(credentialsId: 'docker-hub-creds', usernameVariable: 'USER', passwordVariable: 'PASS')]) { - sh 'docker build -t slehmadi/react-app-cicd-dicoding .' - sh 'docker login -u $USER -p $PASS' - sh 'docker push slehmadi/react-app-cicd-dicoding' - } - } - } stage('Manual Approval') { checkout scm input message: 'Lanjutkan ke tahap Deploy?' @@ -29,4 +19,15 @@ node { sh './jenkins/scripts/kill.sh' } } + docker.image('ubuntu:alpine').inside('-p 3000:3000') { + stage('Build Image') { + checkout scm + sh 'apt update && apt install docker.io -y' + withCredentials([usernamePassword(credentialsId: 'docker-hub-creds', usernameVariable: 'USER', passwordVariable: 'PASS')]) { + sh 'docker build -t slehmadi/react-app-cicd-dicoding .' + sh 'docker login -u $USER -p $PASS' + sh 'docker push slehmadi/react-app-cicd-dicoding' + } + } + } } \ No newline at end of file