init: hello-cicd project setup
This commit is contained in:
0
.gitea/workflows/ci.yml
Normal file
0
.gitea/workflows/ci.yml
Normal file
15
Dockerfile
Normal file
15
Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Dockerfile
|
||||||
|
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"]
|
||||||
30
k8s/deployment.yaml
Normal file
30
k8s/deployment.yaml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# k8s/deployment.yaml
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: hello-cicd
|
||||||
|
namespace: student-ivanivso7
|
||||||
|
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/ivanivso7/hello-cicd:latest
|
||||||
|
ports:
|
||||||
|
- containerPort: 8000
|
||||||
|
env:
|
||||||
|
- name: APP_VERSION
|
||||||
|
value: "latest"
|
||||||
|
resources:
|
||||||
|
requests: {cpu: 50m, memory: 64Mi}
|
||||||
|
limits: {cpu: 200m, memory: 128Mi}
|
||||||
|
|
||||||
13
k8s/service.yaml
Normal file
13
k8s/service.yaml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# k8s/service.yaml
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: hello-cicd-svc
|
||||||
|
namespace: student-VAŠ_KORISNIK
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: hello-cicd
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
targetPort: 8000
|
||||||
|
type: NodePort
|
||||||
17
main.py
Normal file
17
main.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# main.py
|
||||||
|
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
2
requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fastapi==0.115.0
|
||||||
|
uvicorn==0.32.0
|
||||||
Reference in New Issue
Block a user