forked from pipeshub-ai/pipeshub-ai
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.cloud
More file actions
91 lines (77 loc) · 3.46 KB
/
Copy pathDockerfile.cloud
File metadata and controls
91 lines (77 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Stage 1: Base dependencies
FROM python:3.12-slim AS base
ENV DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC
WORKDIR /app
RUN pip install uv
# Install system dependencies and necessary runtime libraries
RUN apt-get update && apt-get install -y \
curl gnupg iputils-ping telnet traceroute dnsutils net-tools wget \
librocksdb-dev libgflags-dev libsnappy-dev zlib1g-dev \
libbz2-dev liblz4-dev libzstd-dev libssl-dev ca-certificates libspatialindex-dev libpq5 && \
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs git && \
apt-get install -y libreoffice && \
apt-get install -y ocrmypdf tesseract-ocr ghostscript unpaper qpdf && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Stage 2: Python dependencies
FROM base AS python-deps
COPY ./backend/python/pyproject.toml /app/python/
WORKDIR /app/python
RUN uv pip install --system -e .
# Download NLTK and spaCy models
RUN python -m spacy download en_core_web_sm && \
python -m nltk.downloader punkt && \
python -c "from langchain_huggingface import HuggingFaceEmbeddings; model = HuggingFaceEmbeddings(model_name='BAAI/bge-large-en-v1.5')" && \
python -c "from langchain_qdrant import FastEmbedSparse; model = FastEmbedSparse(model_name='Qdrant/BM25')" && \
python -c "from sentence_transformers import CrossEncoder; model = CrossEncoder(model_name='BAAI/bge-reranker-base')"
# Stage 3: Node.js backend
FROM base AS nodejs-backend
WORKDIR /app/backend
COPY backend/nodejs/apps/package*.json ./
COPY backend/nodejs/apps/tsconfig.json ./
# Set up architecture detection and conditional handling
RUN set -e; \
# Detect architecture
ARCH=$(uname -m); \
echo "Building for architecture: $ARCH"; \
# Platform-specific handling
if [ "$ARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then \
echo "Detected ARM architecture (M1/Apple Silicon)"; \
# ARM-specific handling: Skip problematic binary or use alternative
npm install --prefix ./ --ignore-scripts && \
npm uninstall jpeg-recompress-bin mozjpeg imagemin-mozjpeg 2>/dev/null || true; \
# Install Sharp AS a better alternative for ARM64
npm install sharp --save || echo "Sharp install failed, continuing without image optimization"; \
else \
echo "Detected x86 architecture"; \
# Standard install for x86 platforms
apt-get update && apt-get install -y libc6-dev-i386 && npm install --prefix ./; \
fi
COPY backend/nodejs/apps/src ./src
RUN npm run build
# Stage 4: Frontend build
FROM base AS frontend-build
WORKDIR /app/frontend
RUN mkdir -p packages
COPY frontend/package*.json ./
COPY frontend/packages ./packages/
RUN npm config set legacy-peer-deps true && npm install
COPY frontend/ ./
RUN npm run build
# Stage 5: Final runtime
FROM python-deps AS runtime
WORKDIR /app
COPY --from=nodejs-backend /app/backend/dist ./backend/dist
COPY --from=nodejs-backend /app/backend/src/modules/mail ./backend/src/modules/mail
COPY --from=nodejs-backend /app/backend/node_modules ./backend/dist/node_modules
COPY --from=frontend-build /app/frontend/dist ./backend/dist/public
COPY backend/python/app/ /app/python/app/
# Expose necessary ports
EXPOSE 3000 8000 8088 8091
# Start all services in development mode
CMD sh -c "cd /app/backend && node dist/index.js & \
cd /app/python && python -m app.connectors_main & \
cd /app/python && python -m app.indexing_main & \
cd /app/python && python -m app.query_main & \
wait"