I made a pipeline script to be able to run a project that I pulled from github but somehow dockerfile is not working properly and after I build the project successfully I can just see the nginx screen and nothing beyond that. Here is my script : any help is highly appreciated!
def cal = Calendar.instance
def dateFormat = 'YYYYMMDD-hhmmss'
def timeZone = TimeZone.getTimeZone('GMT+03:00')
def timeStamp = Calendar.getInstance().getTime().format('YYYYMMDD-hhmmss',TimeZone.getTimeZone('GMT+03:00'))
pipeline {
agent {
node {
label 'master'
customWorkspace "${params.workingDir}"
}
}
stages {
stage('removeOldFiles') {
steps {
powershell " Remove-Item * -Recurse -Force"
}
}
stage('gitClone') {
steps {
powershell "git clone https://github.com/formio/angular.git ./"
}
}
stage('removeUnnecessaryFiles') {
steps {
powershell "Remove-Item Dockerfile -Recurse -Force"
}
}
stage('createDockerFile') {
steps {
powershell """
echo 'FROM nginx:latest' > Dockerfile.tmp
echo 'COPY ./dist/angular-formio/ /usr/share/nginx/html' >> Dockerfile.tmp
echo 'EXPOSE ${params.exposePort}' >> Dockerfile.tmp
"""
powershell "Get-Content .\\Dockerfile.tmp | Set-Content -Encoding utf8 Dockerfile"
}
}
stage('buildProject') {
steps {
powershell """
Remove-Item package-lock.json -Recurse -Force
npm install
npm run ng build
"""
}
}
stage('buildImage') {
steps {
powershell "docker image build -t ${params.imageName}${timeStamp} ."
}
}
stage('runContainer') {
steps {
powershell "docker container run -d -it --name ${params.containerName} -p 22900:${params.exposePort} ${params.imageName}${timeStamp}"
}
}
}
}