docker compose file added for deployment

This commit is contained in:
2026-01-22 22:34:12 +05:30
parent 9d7109b60f
commit c76d533783
13 changed files with 267 additions and 4 deletions

36
frontend/Dockerfile Normal file
View File

@@ -0,0 +1,36 @@
# Stage 1: Build the Angular application
FROM node:18 as build
WORKDIR /app
# Install dependencies first (better caching)
COPY package*.json ./
RUN npm install
# Copy source code
COPY . .
# Build for production with specific base-href
RUN npm run build -- --configuration production --base-href /ocrf/
# Stage 2: Serve via Nginx
FROM nginx:alpine
# Remove default nginx static assets
RUN rm -rf /usr/share/nginx/html/*
# Create target directory (since we use /ocrf/ base-href)
RUN mkdir -p /usr/share/nginx/html/ocrf
# Copy built assets from builder stage
# Note: Adjust 'dist/frontend/browser' based on your angular.json output path.
# Angular 17+ creates 'browser' folder.
COPY --from=build /app/dist/frontend/browser /usr/share/nginx/html/ocrf
# Copy custom nginx config
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Expose port 80
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

16
frontend/nginx.conf Normal file
View File

@@ -0,0 +1,16 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html/ocrf;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
# Optional: Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 1y;
add_header Cache-Control "public, no-transform";
}
}

View File

@@ -7,7 +7,7 @@ import { Observable, of, tap } from 'rxjs';
providedIn: 'root'
})
export class AuthService {
private apiUrl = 'http://localhost:8000/api';
private apiUrl = '/ocrb/api';
constructor(private http: HttpClient, private router: Router) { }

View File

@@ -28,8 +28,8 @@ export interface EmailListResponse {
providedIn: 'root'
})
export class MailboxService {
private apiUrl = 'http://localhost:8000/api/emails';
private attachmentUrl = 'http://localhost:8000/api/attachments';
private apiUrl = '/ocrb/api/emails';
private attachmentUrl = '/ocrb/api/attachments';
constructor(private http: HttpClient) {}

View File

@@ -6,7 +6,7 @@ import { Observable } from 'rxjs';
providedIn: 'root'
})
export class OcrService {
private apiUrl = 'http://localhost:8000/api/ocr';
private apiUrl = '/ocrb/api/ocr';
constructor(private http: HttpClient) { }
@@ -15,4 +15,12 @@ export class OcrService {
formData.append('file', file);
return this.http.post(`${this.apiUrl}/extract`, formData);
}
extractWithAI(text: string, filePath: string | null, modelType: string): Observable<any> {
return this.http.post(`/ocrb/api/extract/ai`, { text, file_path: filePath, model_type: modelType });
}
saveDocument(data: any): Observable<any> {
return this.http.post(`/ocrb/api/documents/save`, data);
}
}