Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-cp-testing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vinod Bangera
python-cp-testing
Commits
4fc29ff4
Commit
4fc29ff4
authored
1 year ago
by
Vinod Bangera
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit by containerization
parent
1d6e1f01
Branches
devops
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
Dockerfile
+1
-14
1 addition, 14 deletions
Dockerfile
Jenkinsfile
+89
-0
89 additions, 0 deletions
Jenkinsfile
Procfile
+1
-0
1 addition, 0 deletions
Procfile
k8/deployment.yaml
+19
-0
19 additions, 0 deletions
k8/deployment.yaml
k8/service.yaml
+12
-0
12 additions, 0 deletions
k8/service.yaml
with
122 additions
and
14 deletions
Dockerfile
+
1
−
14
View file @
4fc29ff4
# Use the official Python base image
FROM
python:3.9-slim
FROM
python:3.9-slim
# Set the working directory in the container
WORKDIR
/app
WORKDIR
/app
# Copy the requirements file into the container at /app
COPY
requirements.txt /app/
COPY
requirements.txt /app/
# Install dependencies
RUN
pip
install
--no-cache-dir
-r
requirements.txt
RUN
pip
install
--no-cache-dir
-r
requirements.txt
# Copy the current directory contents into the container at /app
COPY
. /app/
COPY
. /app/
# Expose port 8000 to the outside world
EXPOSE
8000
EXPOSE
8000
CMD
uvicorn main:app --host 0.0.0.0 --port 8000
# Command to run the FastAPI application
CMD
["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
This diff is collapsed.
Click to expand it.
Jenkinsfile
0 → 100644
+
89
−
0
View file @
4fc29ff4
pipeline
{
agent
any
// tools {
// nodejs 'NodeJS'
// }
environment
{
PROJECT_ID
=
"tech-rnd-project"
CLUSTER_NAME
=
"python-cluster"
LOCATION
=
"us-central1-a"
CREDENTIALS_ID
=
"335fefa0-0089-4fe2-994c-fd3bd9e2ab2b"
}
stages
{
stage
(
'Scm Checkout'
)
{
steps
{
checkout
scm
}
}
stage
(
'Build'
)
{
steps
{
echo
'building the software'
// sh 'npm install --force'
}
}
stage
(
'Test'
)
{
steps
{
//add steps here
echo
'testing'
}
}
stage
(
'Build Docker Image'
)
{
steps
{
script
{
sh
'whoami'
sh
'sudo chmod 777 /var/run/docker.sock'
sh
"docker build -t python-postgress ."
}
}
}
// stage('Image Scan') {
// steps {
// //add steps here
// echo 'image scanning'
// sh 'trivy image --no-progress --exit-code 1 --severity CRITICAL python-postgress'
// }
// }
stage
(
'Push Docker Image'
)
{
steps
{
script
{
echo
'Push Docker Image'
sh
"docker tag python-postgress asia-south1-docker.pkg.dev/tech-rnd-project/container-python/python"
sh
'gcloud auth configure-docker asia-south1-docker.pkg.dev'
sh
'docker push asia-south1-docker.pkg.dev/tech-rnd-project/container-python/python'
// sh 'curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl'
// sh 'chmod +x kubectl'
// sh "sudo mv kubectl \$(which kubectl)"
}
}
}
stage
(
'Deploy to K8s'
)
{
steps
{
echo
'Deployment started ...'
sh
'ls -ltr'
sh
'pwd'
echo
'Start deployment of deployment.yaml'
step
([
$class
:
'KubernetesEngineBuilder'
,
projectId:
env
.
PROJECT_ID
,
clusterName:
env
.
CLUSTER_NAME
,
location:
env
.
LOCATION
,
manifestPattern:
'k8'
,
credentialsId:
env
.
CREDENTIALS_ID
,
verifyDeployments:
true
])
echo
'Deployment Finished ...'
sh
'''
'''
}
}
}
post
{
always
{
emailext
to:
'vinod.bangera@niveussolutions.com'
,
subject:
"jenkins build:${currentBuild.currentResult}: ${env.JOB_NAME}"
,
body:
"${currentBuild.currentResult}: Job ${env.JOB_NAME}\nMore Info can be found in the attached log"
,
attachLog:
true
}
}
}
This diff is collapsed.
Click to expand it.
Procfile
0 → 100644
+
1
−
0
View file @
4fc29ff4
web: uvicorn main:app --reload
This diff is collapsed.
Click to expand it.
k8/deployment.yaml
0 → 100644
+
19
−
0
View file @
4fc29ff4
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
name
:
python-app
spec
:
replicas
:
1
selector
:
matchLabels
:
app
:
python-app
template
:
metadata
:
labels
:
app
:
python-app
spec
:
containers
:
-
name
:
python-app
image
:
asia-south1-docker.pkg.dev/tech-rnd-project/container-python/python
ports
:
-
containerPort
:
8000
This diff is collapsed.
Click to expand it.
k8/service.yaml
0 → 100644
+
12
−
0
View file @
4fc29ff4
apiVersion
:
v1
kind
:
Service
metadata
:
name
:
node-app
name
:
python-app
spec
:
ports
:
-
port
:
8000
targetPort
:
8000
type
:
LoadBalancer
selector
:
app
:
python-app
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment