init: hello-cicd project setup

This commit is contained in:
2026-04-14 10:37:31 +02:00
parent fcab094566
commit 10e9d8ca26
5 changed files with 70 additions and 0 deletions

14
Dockerfile Normal file
View File

@@ -0,0 +1,14 @@
FROM python:3.12-slim
WORKDIR /app
# Kopiraj requirements PRIJE koda — cache trick!
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
ENV APP_VERSION=dev
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

25
k8s/deployment.yaml Normal file
View File

@@ -0,0 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-cicd
namespace: student-sz11zs
spec:
replicas: 1
selector:
matchLabels:
app: hello-cicd
template:
metadata:
labels:
app: hello-cicd
spec:
imagePullSecrets:
- name: gitea-creds
containers:
- name: hello-cicd
image: git.fpmoz.sum.ba/sz11zs/hello-cicd:latest
ports:
- containerPort: 8000
env:
- name: APP_VERSION
value: "latest"

13
k8s/service.yaml Normal file
View File

@@ -0,0 +1,13 @@
# k8s/service.yaml
apiVersion: v1
kind: Service
metadata:
name: hello-cicd-svc
namespace: student-sz11zs
spec:
selector:
app: hello-cicd
ports:
- port: 80
targetPort: 8000
type: NodePort

16
main.py Normal file
View File

@@ -0,0 +1,16 @@
from fastapi import FastAPI
import os, datetime
app = FastAPI()
@app.get("/health")
def health():
return {
"status": "ok",
"version": os.getenv("APP_VERSION", "dev"),
"timestamp": datetime.datetime.utcnow().isoformat()
}
@app.get("/")
def root():
return {"poruka": "Zdravo s k3s!", "host": os.uname().nodename}

2
requirements.txt Normal file
View File

@@ -0,0 +1,2 @@
fastapi==0.115.0
uvicorn==0.32.0