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
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# ----- BUILD -----
FROM node:18-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

# ----- PRODUCTION -----
FROM nginx:alpine
COPY --from=build /app/build /usr/share/nginx/html

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
80 changes: 80 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
pipeline {
agent any
options { timestamps() }

environment {
IMAGE = "safarebaei/monapp"
TAG = "build-${BUILD_NUMBER}"
}

stages {

stage('Checkout') {
steps {
checkout scm
}
}

stage('Docker Build') {
steps {
bat 'docker version'
bat "docker build -t %IMAGE%:%TAG% ."
}
}

stage('Run (Docker)') {
steps {
bat """
docker rm -f monapp_test 2>nul || exit 0
docker run -d --name monapp_test -p 8082:80 %IMAGE%:%TAG%
"""
}
}

stage('Smoke Test') {
steps {
bat """
ping -n 5 127.0.0.1 > nul
curl -I http://localhost:8082 | find "200 OK"
"""
}
}

stage('Cleanup') {
steps {
bat "docker rm -f monapp_test 2>nul || exit 0"
}
}

stage('Push (Docker Hub)') {
steps {
withCredentials([
usernamePassword(
credentialsId: 'react_id',
usernameVariable: 'DOCKER_USER',
passwordVariable: 'DOCKER_PASS'
)
]) {
bat """
echo %DOCKER_PASS% | docker login -u %DOCKER_USER% --password-stdin
docker tag %IMAGE%:%TAG% %IMAGE%:latest
docker push %IMAGE%:%TAG%
docker push %IMAGE%:latest
"""
}
}
}
}

post {
success {
echo '✅ Build + Smoke Test + Push Docker Hub OK'
}
failure {
echo '❌ Pipeline FAILED'
}
always {
bat "docker rm -f monapp_test 2>nul || exit 0"
}
}
}
2 changes: 1 addition & 1 deletion node_modules/.cache/.eslintcache

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Loading