pushing python project
This commit is contained in:
9
Dockerfile
Normal file
9
Dockerfile
Normal 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
31
Jenkinsfile
vendored
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
35
Jenkinsfile-push-gitea-dockerhub
Normal file
35
Jenkinsfile-push-gitea-dockerhub
Normal 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
24
index.html
Normal file
24
index.html
Normal 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>
|
Reference in New Issue
Block a user