diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..640adc9fa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM node:4-alpine + + + +WORKDIR /opt/frontend + +COPY . . + +RUN npm install + +EXPOSE 8079 + +CMD npm start + diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..90545f073 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,64 @@ +pipeline { + agent none + stages { + stage('build') { + agent { + docker { + image 'schoolofdevops/node:4-alpine' + } + + } + steps { + echo 'this is the build job' + sh 'npm install' + } + } + + stage('test') { + agent { + docker { + image 'schoolofdevops/node:4-alpine' + } + + } + steps { + echo 'this is the test job' + sh '''npm install +npm test''' + } + } + + stage('package') { + agent { + docker { + image 'schoolofdevops/node:4-alpine' + } + + } + steps { + sh '''npm install +npm run package''' + archiveArtifacts '**/distribution/*.zip' + } + } + + stage('docker build and package') { + steps { + script { + docker.withRegistry('https://index.docker.io/v1/', 'dockerlogin') { + def dockerImage = docker.build("prat91/frontend:v${env.BUILD_ID}", "./") + dockerImage.push() + dockerImage.push("latest") + } + } + + } + } + + } + post { + always { + echo 'this pipeline has completed...' + } + + } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..5f144e88f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +version: "3.6" + +services: + frontend: + build: . + image: prat91/frontend:v1 + ports: + - 8079