pushing python project

This commit is contained in:
lenape
2025-03-04 18:49:45 +00:00
parent 375b13e95e
commit 0d210d0524
5 changed files with 100 additions and 0 deletions

9
Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
FROM python:3.9-slim-buster
RUN apt-get update && apt-get install -y nginx
COPY index.html /usr/share/nginx/html/index.html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

31
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,31 @@
pipeline {
agent any
stages {
stage('Build Docker Image') {
steps {
script {
def imageName = "python-jenkins-project:${BUILD_NUMBER}"
docker.build(imageName, '.')
env.IMAGE_NAME = imageName
}
}
}
stage('Deploy Docker Container') {
steps {
script {
sh "docker stop python-jenkins-container || true"
sh "docker rm python-jenkins-container || true"
sh "docker run -d -p 5555:80 --name python-jenkins-container ${env.IMAGE_NAME}"
}
}
}
stage('Verify Deployment') {
steps {
script {
sh "curl http://38.110.1.139:5555"
}
}
}
}
}

View File

@@ -0,0 +1,35 @@
pipeline {
agent any
environment {
DOCKERHUB_REPO = 'jacqueskingram/python-jenkins-project'
GITEA_REPO = 'code.jacquesingram.online/lenape/python-jenkins-project.git'
}
stages {
stage('Build Docker Image') {
steps {
script {
def imageName = "${env.DOCKERHUB_REPO}:${BUILD_NUMBER}"
docker.build(imageName, '.')
env.IMAGE_NAME = imageName
}
}
}
stage('Push to Gitea') {
steps {
git credentialsId: 'my-gitea-credentials', url: "${env.GITEA_REPO}"
sh 'git push origin main'
}
}
stage('Push to Docker Hub') {
steps {
script {
docker.withRegistry('https://index.docker.io/v1/', 'my-dockerhub-credentials') {
docker.image(env.IMAGE_NAME).push()
}
}
}
}
}
}

1
app.py Normal file
View File

@@ -0,0 +1 @@
print("Hello from Python in Jenkins!")

24
index.html Normal file
View File

@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<title>Hello World from Lenape</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
h1 {
font-family: cursive;
font-size: 3em;
color: #333;
}
</style>
</head>
<body>
<h1>Hello World from Lenape</h1>
</body>
</html>