Skip to content
Merged
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
29 changes: 28 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
��^�j�W����u�� h�"���ج����K����
# Dependencies
node_modules/

# Git
.git/
.gitignore

# GitHub Actions
.github/

# Environment files
.env
.env.*

# Docker
Dockerfile
docker-compose.yml
.dockerignore

# Build artifacts
dist/
build/
.DS_Store

# Logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
25 changes: 25 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Docker Image Build

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and export
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: false
49 changes: 49 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Stage 1: Build Frontend
FROM node:20-slim AS frontend-builder
WORKDIR /app

# Copy package files and install dependencies
COPY package.json package-lock.json* ./
RUN npm install

# Copy frontend source and build
COPY App.tsx index.html index.tsx vite.config.ts tsconfig.json ./
COPY components ./components
COPY services ./services
COPY constants.ts types.ts ./
RUN npm run build

# Stage 2: Build Backend
FROM node:20-slim AS backend-builder
WORKDIR /app

# Copy package files and install dependencies
COPY package.json package-lock.json* ./
RUN npm install

# Copy backend source and build
COPY backend ./backend
COPY tsconfig.json .
COPY tsconfig.backend.json .
RUN npx tsc --project tsconfig.backend.json

# Stage 3: Production Image
FROM node:20-slim
WORKDIR /app

# Install production dependencies
COPY package.json package-lock.json* ./
RUN npm install --omit=dev

# Copy built frontend and backend
COPY --from=frontend-builder /app/dist ./dist/frontend
COPY --from=backend-builder /app/dist ./dist/backend

# Expose ports
EXPOSE 3000 3001

# Start script to run both servers
COPY start.sh .
RUN chmod +x start.sh

CMD ["./start.sh"]
2 changes: 1 addition & 1 deletion backend/server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import express from 'express';
import { createClient, AuthType } from 'webdav';
import mammoth from 'mammoth';
import pdf from 'pdf-parse';
import * as pdf from 'pdf-parse';

// --- Configuration ---
const PORT = process.env.PORT || 3001;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"pdfjs-dist": "4.0.379",
"express": "^5.2.1",
"pdf-parse": "^2.4.5",
"webdav": "^5.8.0"
"webdav": "^5.8.0",
"serve": "^14.2.1"
},
"devDependencies": {
"@types/node": "^22.14.0",
Expand Down
14 changes: 14 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
set -e

# Start the backend server in the background
node dist/backend/server.js &

# Start a simple server for the frontend
npx serve -s dist/frontend -l 3000

# Wait for any process to exit
wait -n

# Exit with status of process that exited first
exit $?
11 changes: 11 additions & 0 deletions tsconfig.backend.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false,
"outDir": "dist",
"allowImportingTsExtensions": false
},
"include": [
"backend"
]
}
3 changes: 3 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export default defineConfig(({ mode }) => {
port: 3000,
host: '0.0.0.0',
},
build: {
target: 'esnext'
},
plugins: [react()],
define: {
'process.env.API_KEY': JSON.stringify(env.GEMINI_API_KEY),
Expand Down