Add Dockerfile and Jenkinsfile
This commit is contained in:
12
platform/Dockerfile
Normal file
12
platform/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM python:3.11-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
CMD ["python", "app.py"]
|
||||
54
platform/Jenkinsfile
vendored
Normal file
54
platform/Jenkinsfile
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
echo 'Code checked out'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Install Dependencies') {
|
||||
steps {
|
||||
sh '''
|
||||
cd platform
|
||||
python3 -m venv venv
|
||||
venv/bin/pip install -r requirements.txt --quiet
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Test') {
|
||||
steps {
|
||||
sh '''
|
||||
cd platform
|
||||
echo "Running basic syntax check..."
|
||||
venv/bin/python -m py_compile app.py && echo "✅ app.py syntax OK"
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy to Server 1') {
|
||||
steps {
|
||||
sh '''
|
||||
cp -r platform/* /root/management-platform/
|
||||
cd /root/management-platform
|
||||
venv/bin/pip install -r requirements.txt --quiet 2>/dev/null || true
|
||||
systemctl restart management-platform
|
||||
sleep 4
|
||||
systemctl is-active --quiet management-platform && echo "✅ Deployed OK" || exit 1
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
success {
|
||||
echo '✅ Pipeline succeeded — platform deployed'
|
||||
}
|
||||
failure {
|
||||
echo '❌ Pipeline failed — old version still running'
|
||||
}
|
||||
}
|
||||
}
|
||||
6
platform/sonar-project.properties
Normal file
6
platform/sonar-project.properties
Normal file
@@ -0,0 +1,6 @@
|
||||
sonar.projectKey=management-platform
|
||||
sonar.projectName=Management Platform
|
||||
sonar.projectVersion=1.0
|
||||
sonar.sources=.
|
||||
sonar.exclusions=**/__pycache__/**,**/venv/**,**/*.pyc
|
||||
sonar.python.version=3
|
||||
Reference in New Issue
Block a user