Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@ dist-ssr/
*.sw?

# Ignore pnpm lock file
pnpm-lock.yaml
pnpm-lock.yaml

# ignore the temp folder
vision/temp
45 changes: 45 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: "3.8"
services:
backend:
build:
context: .
dockerfile: vision/Dockerfile
volumes:
- .:/app
- temp-data:/app/vision/temp
env_file:
- .env
ports:
- "8000:8000"
depends_on:
- redis

worker:
build:
context: .
dockerfile: vision/Dockerfile
command: celery -A vision.config.celery_worker.celery_app worker --loglevel=info
env_file:
- .env
depends_on:
- redis
volumes:
- .:/app
- temp-data:/app/vision/temp

frontend:
build:
context: ./frontend
dockerfile: Dockerfile
ports:
- "3000:80"
depends_on:
- backend

redis:
image: redis:7
# ports:
# - "6379:6379"

volumes:
temp-data:
14 changes: 14 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Build stage
FROM node:18 AS build
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN npm install -g pnpm && pnpm install
COPY . .
RUN pnpm run build

# Serve with nginx
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
14 changes: 14 additions & 0 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;

location / {
try_files $uri $uri/ /index.html;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
22 changes: 22 additions & 0 deletions k8s/backend-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend
spec:
replicas: 1
selector:
matchLabels:
app: backend
template:
metadata:
labels:
app: backend
spec:
containers:
- name: backend
image: sumansahoo/qualiscan-backend:latest
ports:
- containerPort: 8000
envFrom:
- secretRef:
name: backend-env
12 changes: 12 additions & 0 deletions k8s/backend-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: backend
spec:
selector:
app: backend
ports:
- protocol: TCP
port: 8000
targetPort: 8000
type: ClusterIP
19 changes: 19 additions & 0 deletions k8s/frontend-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend
spec:
replicas: 1
selector:
matchLabels:
app: frontend
template:
metadata:
labels:
app: frontend
spec:
containers:
- name: frontend
image: sumansahoo/qualiscan-frontend:latest
ports:
- containerPort: 80
12 changes: 12 additions & 0 deletions k8s/frontend-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: frontend
spec:
selector:
app: frontend
ports:
- protocol: TCP
port: 80
targetPort: 80
type: ClusterIP
25 changes: 25 additions & 0 deletions k8s/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: qualiscan-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- host: qualiscan.local
http:
paths:
- pathType: Prefix
path: /api/(.*)
backend:
service:
name: backend
port:
number: 8000
- pathType: Prefix
path: /(.*)
backend:
service:
name: frontend
port:
number: 80
19 changes: 19 additions & 0 deletions k8s/redis-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
spec:
replicas: 1
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:7
ports:
- containerPort: 6379
12 changes: 12 additions & 0 deletions k8s/redis-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: redis
spec:
selector:
app: redis
ports:
- protocol: TCP
port: 6379
targetPort: 6379
type: ClusterIP
21 changes: 21 additions & 0 deletions k8s/worker-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: worker
spec:
replicas: 1
selector:
matchLabels:
app: worker
template:
metadata:
labels:
app: worker
spec:
containers:
- name: worker
image: sumansahoo/qualiscan-backend:latest
command: ["celery", "-A", "vision.config.celery_worker.celery_app", "worker", "--loglevel=info"]
envFrom:
- secretRef:
name: backend-env
21 changes: 20 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
fastapi
uvicorn
opencv-python
numpy
pillow
python-dotenv
requests
google-generativeai
langchain-core
dataclasses-json
google-ai-generativelanguage
requests
charset-normalizer
backoff
supervision
pymongo
langchain-google-genai
aiohttp
celery[redis]
redis
inference-sdk
python-multipart
15 changes: 15 additions & 0 deletions vision/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.10-slim

WORKDIR /app

# Install system dependencies for OpenCV and threading
RUN apt-get update && apt-get install -y libgl1 libglib2.0-0 && rm -rf /var/lib/apt/lists/*

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 8000

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
4 changes: 2 additions & 2 deletions vision/config/celery_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

celery_app = Celery(
"vision",
broker="redis://localhost:6379/0", # or your Redis/RabbitMQ URL
backend="redis://localhost:6379/0"
broker="redis://redis:6379/0", # or your Redis/RabbitMQ URL
backend="redis://redis:6379/0"
)

# Include tasks modules
Expand Down