Skip to content
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
20 changes: 16 additions & 4 deletions result/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
# Base image
FROM node:18-slim

# add curl for healthcheck
# Add curl and tini for health check and process management
RUN apt-get update && \
apt-get install -y --no-install-recommends curl tini && \
rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /usr/local/app

# have nodemon available for local dev use (file watching)
# Install nodemon globally for development use (file watching)
RUN npm install -g nodemon

# Copy package.json and package-lock.json
COPY package*.json ./

# Install dependencies and clean up cache
RUN npm ci && \
npm cache clean --force && \
mv /usr/local/app/node_modules /node_modules
npm cache clean --force && \
mv /usr/local/app/node_modules /node_modules

# Copy application source code
COPY . .

# Set environment variables
ENV PORT 80

# Expose port 80
EXPOSE 80

# Use tini as the init system
ENTRYPOINT ["/usr/bin/tini", "--"]

# Command to run the application
CMD ["node", "server.js"]

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

tools {
nodejs 'NodeJS 22.4.0'
}

stages {
stage("build") {
when {
changeset "**/result/**"
}
steps {
echo 'Compiling result app..'
// Remove 'dir('worker')' if you are not using the worker package anymore.
dir('result') {
sh 'npm install' // Now this will run inside the 'result' directory
}
}
}

stage("test") {
when {
changeset "**/result/**"
}
steps {
echo 'Running Unit Tests on result app..'
dir('result') {
sh 'npm install' // Install dependencies in the 'result' directory
sh 'npm test' // Run tests in the 'result' directory
}
}
}
}
}

5 changes: 5 additions & 0 deletions result/test/mock.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ describe('mock test 6', () => {
});
});

describe('mock test 7', () => {
it('unit test 7', () => {
expect(true).to.be.true;
});
});
23 changes: 12 additions & 11 deletions vote/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
# Define a base stage that uses the official python runtime base image
# Base stage using the official Python runtime base image
FROM python:3.11-slim AS base

# Add curl for healthcheck
# Add curl for health checks
RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
rm -rf /var/lib/apt/lists/*

# Set the application directory
# Set the working directory
WORKDIR /usr/local/app

# Install our requirements.txt
# Install dependencies from requirements.txt
COPY requirements.txt ./requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Define a stage specifically for development, where it'll watch for
# filesystem changes
# Development stage with tools for live file watching
FROM base AS dev
RUN pip install watchdog
ENV FLASK_ENV=development
CMD ["python", "app.py"]

# Define the final stage that will bundle the application for production
# Production stage optimized for deployment
FROM base AS final

# Copy our code from the current folder to the working directory inside the container
# Copy application code to the container
COPY . .

# Make port 80 available for links and/or publish
# Expose port 80 for the application
EXPOSE 80

# Define our command to be run when launching the container
CMD ["gunicorn", "app:app", "-b", "0.0.0.0:80", "--log-file", "-", "--access-logfile", "-", "--workers", "4", "--keep-alive", "0"]
# Define the command to run the application in production
CMD ["gunicorn", "app:app", "-b", "0.0.0.0:80", "--log-file", "-", \
"--access-logfile", "-", "--workers", "4", "--keep-alive", "0"]

1 change: 1 addition & 0 deletions worker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM maven:3.9.8-sapmachine-21

WORKDIR /app
COPY . .
RUN mvn package && \
Expand Down
123 changes: 86 additions & 37 deletions worker/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,41 +1,90 @@
pipeline {
agent{
docker{
image 'maven:3.9.8-sapmachine-21'
args '-v $HOME/.m2:/root/.m2'
}
}
stages{
stage('build'){
steps{
echo 'building worker app'
dir('worker'){
sh 'mvn compile'
}
}
}
stage('test'){
steps{
echo 'running unit tests on worker app'
dir('worker'){
sh 'mvn clean test'
}
}
}
stage('package'){
steps{
echo 'packaging worker app into a jarfile'
dir('worker'){
sh 'mvn package -DskipTests'
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
}
}
}
}
post{
always{
echo 'the job is complete'
pipeline {

agent none

stages{
stage("build"){
when{
changeset "**/worker/**"
}

agent{
docker{
image 'maven:3.9.8-sapmachine-21'
args '-v $HOME/.m2:/root/.m2'
}
}

steps{
echo 'Compiling worker app..'
dir('worker'){
sh 'mvn compile'
}
}
}
stage("test"){
when{
changeset "**/worker/**"
}
agent{
docker{
image 'maven:3.9.8-sapmachine-21'
args '-v $HOME/.m2:/root/.m2'
}
}
steps{
echo 'Running Unit Tets on worker app..'
dir('worker'){
sh 'mvn clean test'
}

}
}
stage("package"){
when{
branch 'master'
changeset "**/worker/**"
}
agent{
docker{
image 'maven:3.9.8-sapmachine-21'
args '-v $HOME/.m2:/root/.m2'
}
}
steps{
echo 'Packaging worker app'
dir('worker'){
sh 'mvn package -DskipTests'
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
}

}
}

stage('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("xmarkus/worker:v${env.BUILD_ID}", "./worker")
workerImage.push()
workerImage.push("${env.BRANCH_NAME}")
workerImage.push("latest")
}
}
}
}
}

post{
always{
echo 'Building multibranch pipeline for worker is completed..'
}
}
}