hello-api: platform se scaffold
All checks were successful
Tests / Test passed: 2
hello-api-mb/pipeline/head This commit looks good

This commit is contained in:
devops 2026-09-16 16:26:15 +00:00
parent 75708a518e
commit 36a504077d
9 changed files with 64 additions and 0 deletions

2
.trivyignore Normal file
View File

@ -0,0 +1,2 @@
# Yahan sirf wo CVE daalo jinka business ne risk accept kiya hai.
# Format: CVE-2024-XXXXX

19
Dockerfile Normal file
View File

@ -0,0 +1,19 @@
FROM python:3.12-slim
# Base image purana ho sakta hai. Security updates yahin lagao warna
# pipeline ka Trivy gate HIGH/CRITICAL par build rok dega.
RUN apt-get update && apt-get upgrade -y \
&& apt-get autoremove -y --purge \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /srv
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY app/ ./app/
ARG APP_VERSION=dev
ENV APP_VERSION=${APP_VERSION}
RUN useradd -r -u 1001 appuser
USER appuser
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=3s CMD python -c "import urllib.request;urllib.request.urlopen('http://127.0.0.1:8000/health')"
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "2", "app.main:app"]

9
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,9 @@
// Poori pipeline devops-platform shared library me hai.
@Library('devops-platform') _
devopsPipeline(
module: 'hello-api',
gitops: true,
deployVM: false,
k8sVerifyUrl: 'http://192.168.124.179:30894/version'
)

0
app/__init__.py Normal file
View File

15
app/main.py Normal file
View File

@ -0,0 +1,15 @@
import os
from flask import Flask, jsonify
app = Flask(__name__)
@app.get("/health")
def health():
return jsonify(status="ok")
@app.get("/version")
def version():
# Pipeline ka verify stage isi field ko check karta hai.
return jsonify(app="hello-api", version=os.environ.get("APP_VERSION", "dev"))

2
requirements-dev.txt Normal file
View File

@ -0,0 +1,2 @@
pytest
flask

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
flask
gunicorn

4
sonar-project.properties Normal file
View File

@ -0,0 +1,4 @@
sonar.projectKey=swim-hello-api
sonar.sources=app
sonar.tests=tests
sonar.python.version=3.12

11
tests/test_app.py Normal file
View File

@ -0,0 +1,11 @@
from app.main import app
def test_health():
c = app.test_client()
assert c.get("/health").status_code == 200
def test_version():
c = app.test_client()
assert c.get("/version").get_json()["app"] == "hello-api"