Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

last changes #2

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
240 changes: 240 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
pipeline {

agent none

stages {

stage('worker-build') {


image 'maven:3.8.5-jdk-11-slim'
args '-v $HOME/.m2:/root/.m2'
}
}
}

when {
changeset '**/worker/**'
}
steps {
echo 'Compiling worker app..'
dir(path: 'worker') {
sh 'mvn compile'
}

}
}

stage('worker test') {
agent {
docker {
image 'maven:3.8.5-jdk-11-slim'
args '-v $HOME/.m2:/root/.m2'
}

}
when {
changeset '**/worker/**'
}
steps {
echo 'Running Unit Tets on worker app.'
dir(path: 'worker') {
sh 'mvn clean test'
}

}
}

stage('worker-package') {
agent {
docker {
image 'maven:3.8.5-jdk-11-slim'
args '-v $HOME/.m2:/root/.m2'
}

}
when {
branch 'master'
changeset '**/worker/**'
}
steps {
echo 'Packaging worker app'
dir(path: 'worker') {
sh 'mvn package -DskipTests'
archiveArtifacts(artifacts: '**/target/*.jar', fingerprint: true)
}

}
}

stage('worker-docker-package') {
agent any
when {
changeset '**/worker/**'
branch 'master'
}
steps {
echo 'Packaging worker app with docker'
script {
docker.withRegistry('https://index.docker.io/v1/', 'dockerlogin') {
def workerImage = docker.build("xxxxx/worker:v${env.BUILD_ID}", './worker')
workerImage.push()
workerImage.push("${env.BRANCH_NAME}")
workerImage.push('latest')
}
}

}
}

stage('result-build') {
agent {
docker {
image 'node:8.16.0-alpine'
}

}
when {
changeset '**/result/**'
}
steps {
echo 'Compiling result app..'
dir(path: 'result') {
sh 'npm install'
}

}
}

stage('result-test') {
agent {
docker {
image 'node:8.16.0-alpine'
}

}
when {
changeset '**/result/**'
}
steps {
echo 'Running Unit Tests on result app..'
dir(path: 'result') {
sh 'npm install'
sh 'npm test'
}

}
}

stage('result-docker-package') {
agent any
when {
changeset '**/result/**'
branch 'master'
}
steps {
echo 'Packaging result app with docker'
script {
docker.withRegistry('https://index.docker.io/v1/', 'dockerlogin') {
def resultImage = docker.build("xxxxx/result:v${env.BUILD_ID}", './result')
resultImage.push()
resultImage.push("${env.BRANCH_NAME}")
resultImage.push('latest')
}
}
}
}

stage('vote-build') {
agent {
docker {
image 'python:2.7.16-slim'
args '--user root'
}

}
when {
changeset '**/vote/**'
}
steps {
echo 'Compiling vote app.'
dir(path: 'vote') {
sh 'pip install -r requirements.txt'
}

}
}

stage('vote-test') {
agent {
docker {
image 'python:2.7.16-slim'
args '--user root'
}

}
when {
changeset '**/vote/**'
}
steps {
echo 'Running Unit Tests on vote app.'
dir(path: 'vote') {
sh 'pip install -r requirements.txt'
sh 'nosetests -v'
}

}
}

stage('vote integration'){
agent any
when{
changeset "**/vote/**"
branch 'master'
}
steps{
echo 'Running Integration Tests on vote app'
dir('vote'){
sh 'sh integration_test.sh'
}
}
}


stage('vote-docker-package') {
agent any
steps {
echo 'Packaging vote app with docker'
script {
docker.withRegistry('https://index.docker.io/v1/', 'dockerlogin') {
// ./vote is the path to the Dockerfile that Jenkins will find from the Github repo
def voteImage = docker.build("xxxxx/vote:${env.GIT_COMMIT}", "./vote")
voteImage.push()
voteImage.push("${env.BRANCH_NAME}")
voteImage.push("latest")
}
}

}
}


stage('deploy to dev') {
agent any
when {
branch 'master'
}
steps {
echo 'Deploy instavote app with docker compose'
sh 'docker-compose up -d'
}
}

}

post {
always {
echo 'Building mono pipeline for voting app is completed.'
}
}

30 changes: 30 additions & 0 deletions Jenkinsfile.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
pipeline {
agent any

stages{
stage("one"){
steps{
echo 'step 1'
sleep 3
}
}
stage("two"){
steps{
echo 'step 2'
sleep 9
}
}
stage("three"){
steps{
echo 'step 3'
sleep 5
}
}
}

post{
always{
echo 'This pipeline is completed.'
}
}
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ Architecture
Note
----

hello i just made a change

The voting application only accepts one vote per client. It does not register votes if a vote has already been submitted from a client.
63 changes: 63 additions & 0 deletions docker-compose1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
version: "3.8"
networks:
vote:
driver: bridge



services:
vote:
image: paulogugas/vote:v1
build:
context: ./vote
dockerfile: Dockerfile.1
ports:
- 80
depends_on:
- redis
networks:
- vote


redis:
image: redis:alpine
networks:
- vote




worker:
image: paulogugas/worker
build:
context: ./worker
dockerfile: Dockerfile.multistage
depends_on:
- redis
- db
networks:
- vote



db:
image: postgres:12-alpine
networks:
- vote
environment:
- POSTGRES_HOST_AUTH_METHOD=trust



result:
image: paulogugas/result
build:
context: ./result
dockerfile: Dockerfile.1
ports:
- 80
depends_on:
- db

networks:
- vote
18 changes: 18 additions & 0 deletions result/Dockerfile.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:8.9-alpine

WORKDIR /app

COPY . .

RUN npm config set registry https://registry.npmjs.org

RUN npm install \
&& npm ls \
&& npm cache clean --force \
&& mv /app/node_modules /node_modules


ENV PORT 80
EXPOSE 80

CMD node server.js
14 changes: 14 additions & 0 deletions vote/Dockerfile.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:2.7-alpine


WORKDIR /app

COPY . .

RUN pip install -r requirements.txt

EXPOSE 80

CMD [ "gunicorn", "app:app", "-b", "0.0.0.0:80" ]


21 changes: 21 additions & 0 deletions worker/Dockerfile.multistage
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM paulogugas/worker-base:latest AS build


WORKDIR /code
COPY . .
RUN mvn package -D SkipTests



FROM openjdk:8-jre-alpine AS run

WORKDIR /run

COPY --from=build /code/target/worker-jar-with-dependencies.jar worker.jar





CMD java -jar worker.jar

Loading