added required k8s and docker file

This commit is contained in:
tusuii
2026-02-19 18:09:25 +05:30
parent 09ea6d4efb
commit 173293efaa
17 changed files with 405 additions and 0 deletions

87
k8s/base/deployment.yaml Normal file
View File

@@ -0,0 +1,87 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ecommerce-app
namespace: ecommerce
labels:
app: ecommerce-app
spec:
replicas: 1
selector:
matchLabels:
app: ecommerce-app
template:
metadata:
labels:
app: ecommerce-app
spec:
initContainers:
- name: wait-for-postgres
image: postgres:15-alpine
command:
- sh
- -c
- |
until pg_isready -h postgres -p 5432 -U vaishnavi; do
echo "Waiting for PostgreSQL..."; sleep 3
done
- name: wait-for-mongodb
image: mongo:7
command:
- sh
- -c
- |
until mongosh --host mongodb --port 27017 \
--eval "db.adminCommand('ping')" --quiet; do
echo "Waiting for MongoDB..."; sleep 3
done
- name: run-migrations
image: ecommerce-backend:latest
command:
- sh
- -c
- npx prisma migrate deploy
envFrom:
- secretRef:
name: app-secret
env:
- name: NODE_ENV
value: "production"
containers:
- name: ecommerce-app
image: ecommerce-backend:latest
ports:
- containerPort: 3000
name: http
envFrom:
- configMapRef:
name: app-config
- secretRef:
name: app-secret
volumeMounts:
- name: uploads-volume
mountPath: /app/uploads
resources:
requests:
cpu: "250m"
memory: "256Mi"
limits:
cpu: "500m"
memory: "512Mi"
readinessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 15
periodSeconds: 10
failureThreshold: 3
livenessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 30
periodSeconds: 20
failureThreshold: 3
volumes:
- name: uploads-volume
emptyDir: {}