Skip to content

Commit 7c7a861

Browse files
SRTP-769-implement-api-send-gpd-message
1 parent 4665b9c commit 7c7a861

File tree

5 files changed

+101
-27
lines changed

5 files changed

+101
-27
lines changed

.github/workflows/docker-publish.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,51 @@ jobs:
2929
file: gpd-test/Dockerfile
3030
push: true
3131
tags: ghcr.io/${{ github.repository_owner }}/gpd-test:latest
32+
33+
34+
35+
36+
#jobs:
37+
# build-and-push:
38+
# runs-on: ubuntu-latest
39+
# permissions:
40+
# id-token: write
41+
# contents: read
42+
# packages: write
43+
#
44+
# steps:
45+
# - name: Checkout code
46+
# uses: actions/checkout@v4
47+
#
48+
# - name: Log in to GitHub Container Registry
49+
# uses: docker/login-action@v3
50+
# with:
51+
# registry: ghcr.io
52+
# username: ${{ github.actor }}
53+
# password: ${{ secrets.GITHUB_TOKEN }}
54+
#
55+
# - name: Build and push Docker image
56+
# uses: docker/build-push-action@v5
57+
# with:
58+
# context: .
59+
# file: gpd-test/Dockerfile
60+
# push: true
61+
# tags: ghcr.io/${{ github.repository_owner }}/gpd-test:latest
62+
#
63+
# - name: Azure login via OIDC
64+
# uses: azure/login@v1
65+
# with:
66+
# client-id: ${{ secrets.AZURE_CLIENT_ID }}
67+
# tenant-id: ${{ secrets.AZURE_TENANT_ID }}
68+
# subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
69+
#
70+
# - name: Set AKS context
71+
# uses: azure/aks-set-context@v3
72+
# with:
73+
# resource-group: your-rg
74+
# cluster-name: your-cluster
75+
# subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
76+
#
77+
# - name: Restart deployment
78+
# run: kubectl rollout restart deployment srtp-itn-d-gpd -n srtp
79+

gpd-test/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ COPY requirements.txt /app/
1212
RUN pip install --no-cache-dir -r requirements.txt
1313

1414
# Start the FastAPI app using uvicorn
15-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
15+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]
1616

gpd-test/deploy/deploy-dev.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ spec:
1919
- name: gpd-producer
2020
image: ghcr.io/pagopa/gpd-test:latest
2121
ports:
22-
- containerPort: 8000
22+
- containerPort: 8080
2323
readinessProbe:
2424
httpGet:
2525
path: /health
26-
port: 8000
26+
port: 8080
2727
initialDelaySeconds: 10
2828
periodSeconds: 5
2929
livenessProbe:
3030
httpGet:
3131
path: /health
32-
port: 8000
32+
port: 8080
3333
initialDelaySeconds: 15
3434
periodSeconds: 10
3535
env:
@@ -53,7 +53,7 @@ spec:
5353
ports:
5454
- protocol: TCP
5555
port: 80
56-
targetPort: 8000
56+
targetPort: 8080
5757
---
5858
apiVersion: networking.k8s.io/v1
5959
kind: Ingress

gpd-test/deploy/deploy-uat.yaml

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,19 @@ spec:
1919
- name: gpd-producer
2020
image: ghcr.io/pagopa/gpd-test:latest
2121
ports:
22-
- containerPort: 8000
22+
- containerPort: 8080
23+
readinessProbe:
24+
httpGet:
25+
path: /health
26+
port: 8080
27+
initialDelaySeconds: 10
28+
periodSeconds: 5
29+
livenessProbe:
30+
httpGet:
31+
path: /health
32+
port: 8080
33+
initialDelaySeconds: 15
34+
periodSeconds: 10
2335
env:
2436
- name: KEYVAULT_NAME
2537
value: cstar-u-itn-srtp-kv
@@ -28,4 +40,37 @@ spec:
2840
- name: EVENTHUB_NAMESPACE
2941
value: pagopa-u-itn-gps-rtp-integration-evh
3042
- name: EVENTHUB_TOPIC
31-
value: rtp-events
43+
value: rtp-events
44+
---
45+
apiVersion: v1
46+
kind: Service
47+
metadata:
48+
name: srtp-itn-u-gpd-service
49+
namespace: srtp
50+
spec:
51+
selector:
52+
app: srtp-itn-u-gpd
53+
ports:
54+
- protocol: TCP
55+
port: 80
56+
targetPort: 8080
57+
---
58+
apiVersion: networking.k8s.io/v1
59+
kind: Ingress
60+
metadata:
61+
name: srtp-itn-u-gpd-ingress
62+
namespace: srtp
63+
annotations:
64+
nginx.ingress.kubernetes.io/ssl-redirect: "false"
65+
spec:
66+
rules:
67+
- host: gpd-uat.srtp.dev.pagopa.it
68+
http:
69+
paths:
70+
- path: /
71+
pathType: Prefix
72+
backend:
73+
service:
74+
name: srtp-itn-u-gpd-service
75+
port:
76+
number: 80

gpd-test/main.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,6 @@ async def app_lifespan(fastapi_app: FastAPI):
3535

3636
app = FastAPI(lifespan=app_lifespan)
3737

38-
39-
@app.get("/health")
40-
async def health_check():
41-
"""Health check endpoint for Kubernetes probes"""
42-
return {"status": "healthy", "service": "gpd-producer"}
43-
44-
45-
@app.get("/")
46-
async def root():
47-
"""Root endpoint"""
48-
return {"message": "GPD Service is running", "status": "ok"}
49-
50-
5138
@app.post("/send/gpd/message")
5239
async def send_msg(message: RTPMessage, request: Request):
5340
try:
@@ -62,10 +49,4 @@ async def send_msg(message: RTPMessage, request: Request):
6249
return {"status": "ok"}
6350
except Exception as e:
6451
logger.error(f"Error sending message: {e}")
65-
raise HTTPException(status_code=500, detail=str(e))
66-
67-
68-
if __name__ == "__main__":
69-
import uvicorn
70-
71-
uvicorn.run(app, host="0.0.0.0", port=8000)
52+
raise HTTPException(status_code=500, detail=str(e))

0 commit comments

Comments
 (0)