init: FastAPI priprema-za-kolokvij + k8s manifesti (monorepo)

This commit is contained in:
2026-05-26 10:42:29 +02:00
commit 06eede8050
7 changed files with 71 additions and 0 deletions

6
.dockerignore Normal file
View File

@@ -0,0 +1,6 @@
__pycache__/
*.pyc
.env
.git/
*.md
k8s/

14
Dockerfile Normal file
View File

@@ -0,0 +1,14 @@
FROM python:3.12-slim
WORKDIR /app
# Kopiraj ovisnosti PRVO — ako se ne mijenjaju, pip install se preskace (cache hit)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY app/ ./app/
EXPOSE 8000
# OBAVEZNO: --host 0.0.0.0 da Ingress moze pristupiti containeru
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

10
app/main.py Normal file
View File

@@ -0,0 +1,10 @@
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def root():
return {"message": "Pozdrav svijete!", "autor": "VAŠ_KORISNIK"}
@app.get("/health")
def health():
return {"status": "ok"}

27
k8s/deployment.yaml Normal file
View File

@@ -0,0 +1,27 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: priprema-za-kolokvij
namespace: student-petracamber
spec:
replicas: 1
selector:
matchLabels:
app: priprema-za-kolokvij
template:
metadata:
labels:
app: priprema-za-kolokvij
spec:
containers:
- name: priprema-za-kolokvij
image: git.fpmoz.sum.ba/PetraCamber/priprema-za-kolokvij:1.0
ports:
- containerPort: 8000
resources:
requests:
memory: "64Mi"
cpu: "50m"
limits:
memory: "128Mi"
cpu: "200m"

0
k8s/ingress.yaml Normal file
View File

12
k8s/service.yaml Normal file
View File

@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: priprema-svc
namespace: student-petracamber
spec:
selector:
app: priprema-za-kolokvij # spaja Service s Podovima koji imaju ovaj label
ports:
- port: 80 # port koji Service eksponira (Ingress ce slati ovdje)
targetPort: 8000 # port containera (uvicorn slusa na 8000)
type: ClusterIP # samo unutar K8s clustera — Ingress rjesava vanjski pristup

2
requirements.txt Normal file
View File

@@ -0,0 +1,2 @@
fastapi==0.111.0
uvicorn[standard]==0.29.0