From 45deb10a4fd797e0182ebbda9c2e7929ae09a408 Mon Sep 17 00:00:00 2001 From: Ishlah Muhammadi Date: Fri, 28 Jul 2023 13:35:49 +0700 Subject: [PATCH] Edit Build Image stage #5 --- Jenkinsfile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) 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