-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: server download progress + S3 (janhq#1925)
* fix: reduce the number of api call Signed-off-by: James <[email protected]> * fix: download progress Signed-off-by: James <[email protected]> * chore: save blob * fix: server boot up * fix: download state not updating Signed-off-by: James <[email protected]> * fix: copy assets * Add Dockerfile CPU for Jan Server and Jan Web * Add Dockerfile GPU for Jan Server and Jan Web * feat: S3 adapter * Update check find count from ./pre-install and correct copy:asserts command * server add bundleDependencies @janhq/core * server add bundleDependencies @janhq/core * fix: update success/failed download state (janhq#1945) * fix: update success/failed download state Signed-off-by: James <[email protected]> * fix: download model progress and state handling for both Desktop and Web --------- Signed-off-by: James <[email protected]> Co-authored-by: James <[email protected]> Co-authored-by: Louis <[email protected]> * chore: refactor * fix: load models empty first time open * Add Docker compose * fix: assistants onUpdate --------- Signed-off-by: James <[email protected]> Co-authored-by: James <[email protected]> Co-authored-by: Hien To <[email protected]> Co-authored-by: NamH <[email protected]>
- Loading branch information
1 parent
1442479
commit 5890ade
Showing
61 changed files
with
956 additions
and
517 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,58 @@ | ||
FROM node:20-bullseye AS base | ||
FROM node:20-bookworm AS base | ||
|
||
# 1. Install dependencies only when needed | ||
FROM base AS deps | ||
FROM base AS builder | ||
|
||
# Install g++ 11 | ||
RUN apt update && apt install -y gcc-11 g++-11 cpp-11 jq xsel && rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /app | ||
|
||
# Install dependencies based on the preferred package manager | ||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ | ||
RUN yarn install | ||
COPY . ./ | ||
|
||
# # 2. Rebuild the source code only when needed | ||
FROM base AS builder | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
# This will do the trick, use the corresponding env file for each environment. | ||
RUN yarn workspace server install | ||
RUN yarn server:prod | ||
RUN export NITRO_VERSION=$(cat extensions/inference-nitro-extension/bin/version.txt) && \ | ||
jq --arg nitroVersion $NITRO_VERSION '(.scripts."downloadnitro:linux" | gsub("\\${NITRO_VERSION}"; $nitroVersion)) | gsub("\r"; "")' extensions/inference-nitro-extension/package.json > /tmp/newcommand.txt && export NEW_COMMAND=$(sed 's/^"//;s/"$//' /tmp/newcommand.txt) && jq --arg newCommand "$NEW_COMMAND" '.scripts."downloadnitro:linux" = $newCommand' extensions/inference-nitro-extension/package.json > /tmp/package.json && mv /tmp/package.json extensions/inference-nitro-extension/package.json | ||
RUN make install-and-build | ||
RUN yarn workspace jan-web install | ||
|
||
RUN export NODE_ENV=production && yarn workspace jan-web build | ||
|
||
# 3. Production image, copy all the files and run next | ||
# # 2. Rebuild the source code only when needed | ||
FROM base AS runner | ||
|
||
# Install g++ 11 | ||
RUN apt update && apt install -y gcc-11 g++-11 cpp-11 jq xsel && rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /app | ||
|
||
ENV NODE_ENV=production | ||
# Copy the package.json and yarn.lock of root yarn space to leverage Docker cache | ||
COPY --from=builder /app/package.json ./package.json | ||
COPY --from=builder /app/node_modules ./node_modules/ | ||
COPY --from=builder /app/yarn.lock ./yarn.lock | ||
|
||
# Copy the package.json, yarn.lock, and build output of server yarn space to leverage Docker cache | ||
COPY --from=builder /app/server ./server/ | ||
COPY --from=builder /app/docs/openapi ./docs/openapi/ | ||
|
||
# Copy pre-install dependencies | ||
COPY --from=builder /app/pre-install ./pre-install/ | ||
|
||
# Copy the package.json, yarn.lock, and output of web yarn space to leverage Docker cache | ||
COPY --from=builder /app/web/out ./web/out/ | ||
COPY --from=builder /app/web/.next ./web/.next/ | ||
COPY --from=builder /app/web/package.json ./web/package.json | ||
COPY --from=builder /app/web/yarn.lock ./web/yarn.lock | ||
COPY --from=builder /app/models ./models/ | ||
|
||
# RUN addgroup -g 1001 -S nodejs; | ||
COPY --from=builder /app/server/build ./ | ||
RUN npm install -g serve@latest | ||
|
||
# Automatically leverage output traces to reduce image size | ||
# https://nextjs.org/docs/advanced-features/output-file-tracing | ||
COPY --from=builder /app/server/node_modules ./node_modules | ||
COPY --from=builder /app/server/package.json ./package.json | ||
EXPOSE 1337 3000 3928 | ||
|
||
EXPOSE 4000 3928 | ||
ENV JAN_API_HOST 0.0.0.0 | ||
ENV JAN_API_PORT 1337 | ||
|
||
ENV PORT 4000 | ||
ENV APPDATA /app/data | ||
CMD ["sh", "-c", "cd server && node build/main.js & cd web && npx serve out"] | ||
|
||
CMD ["node", "main.js"] | ||
# docker build -t jan . | ||
# docker run -p 1337:1337 -p 3000:3000 -p 3928:3928 jan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
FROM nvidia/cuda:12.0.0-devel-ubuntu22.04 AS base | ||
|
||
# 1. Install dependencies only when needed | ||
FROM base AS builder | ||
|
||
# Install g++ 11 | ||
RUN apt update && apt install -y gcc-11 g++-11 cpp-11 jq xsel curl gnupg && curl -sL https://deb.nodesource.com/setup_20.x | bash - && apt install nodejs -y && rm -rf /var/lib/apt/lists/* | ||
|
||
RUN npm install -g yarn | ||
|
||
WORKDIR /app | ||
|
||
# Install dependencies based on the preferred package manager | ||
COPY . ./ | ||
|
||
RUN export NITRO_VERSION=$(cat extensions/inference-nitro-extension/bin/version.txt) && \ | ||
jq --arg nitroVersion $NITRO_VERSION '(.scripts."downloadnitro:linux" | gsub("\\${NITRO_VERSION}"; $nitroVersion)) | gsub("\r"; "")' extensions/inference-nitro-extension/package.json > /tmp/newcommand.txt && export NEW_COMMAND=$(sed 's/^"//;s/"$//' /tmp/newcommand.txt) && jq --arg newCommand "$NEW_COMMAND" '.scripts."downloadnitro:linux" = $newCommand' extensions/inference-nitro-extension/package.json > /tmp/package.json && mv /tmp/package.json extensions/inference-nitro-extension/package.json | ||
RUN make install-and-build | ||
RUN yarn workspace jan-web install | ||
|
||
RUN export NODE_ENV=production && yarn workspace jan-web build | ||
|
||
# # 2. Rebuild the source code only when needed | ||
FROM base AS runner | ||
|
||
# Install g++ 11 | ||
RUN apt update && apt install -y gcc-11 g++-11 cpp-11 jq xsel curl gnupg && curl -sL https://deb.nodesource.com/setup_20.x | bash - && apt-get install nodejs -y && rm -rf /var/lib/apt/lists/* | ||
|
||
RUN npm install -g yarn | ||
|
||
WORKDIR /app | ||
|
||
# Copy the package.json and yarn.lock of root yarn space to leverage Docker cache | ||
COPY --from=builder /app/package.json ./package.json | ||
COPY --from=builder /app/node_modules ./node_modules/ | ||
COPY --from=builder /app/yarn.lock ./yarn.lock | ||
|
||
# Copy the package.json, yarn.lock, and build output of server yarn space to leverage Docker cache | ||
COPY --from=builder /app/server ./server/ | ||
COPY --from=builder /app/docs/openapi ./docs/openapi/ | ||
|
||
# Copy pre-install dependencies | ||
COPY --from=builder /app/pre-install ./pre-install/ | ||
|
||
# Copy the package.json, yarn.lock, and output of web yarn space to leverage Docker cache | ||
COPY --from=builder /app/web/out ./web/out/ | ||
COPY --from=builder /app/web/.next ./web/.next/ | ||
COPY --from=builder /app/web/package.json ./web/package.json | ||
COPY --from=builder /app/web/yarn.lock ./web/yarn.lock | ||
COPY --from=builder /app/models ./models/ | ||
|
||
RUN npm install -g serve@latest | ||
|
||
EXPOSE 1337 3000 3928 | ||
|
||
ENV LD_LIBRARY_PATH=/usr/local/cuda-12.0/targets/x86_64-linux/lib:/usr/local/cuda-12.0/compat${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} | ||
|
||
ENV JAN_API_HOST 0.0.0.0 | ||
ENV JAN_API_PORT 1337 | ||
|
||
CMD ["sh", "-c", "cd server && node build/main.js & cd web && npx serve out"] | ||
|
||
# pre-requisites: nvidia-docker | ||
# docker build -t jan-gpu . -f Dockerfile.gpu | ||
# docker run -p 1337:1337 -p 3000:3000 -p 3928:3928 --gpus all jan-gpu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,29 @@ | ||
import { FileManagerRoute } from '../../../api' | ||
import { HttpServer } from '../../index' | ||
import { join } from 'path' | ||
|
||
export const fsRouter = async (app: HttpServer) => { | ||
app.post(`/app/${FileManagerRoute.syncFile}`, async (request: any, reply: any) => {}) | ||
export const fileManagerRouter = async (app: HttpServer) => { | ||
app.post(`/fs/${FileManagerRoute.syncFile}`, async (request: any, reply: any) => { | ||
const reflect = require('@alumna/reflect') | ||
const args = JSON.parse(request.body) | ||
return reflect({ | ||
src: args[0], | ||
dest: args[1], | ||
recursive: true, | ||
delete: false, | ||
overwrite: true, | ||
errorOnExist: false, | ||
}) | ||
}) | ||
|
||
app.post(`/app/${FileManagerRoute.getJanDataFolderPath}`, async (request: any, reply: any) => {}) | ||
app.post(`/fs/${FileManagerRoute.getJanDataFolderPath}`, async (request: any, reply: any) => | ||
global.core.appPath() | ||
) | ||
|
||
app.post(`/app/${FileManagerRoute.getResourcePath}`, async (request: any, reply: any) => {}) | ||
app.post(`/fs/${FileManagerRoute.getResourcePath}`, async (request: any, reply: any) => | ||
join(global.core.appPath(), '../../..') | ||
) | ||
|
||
app.post(`/app/${FileManagerRoute.getUserHomePath}`, async (request: any, reply: any) => {}) | ||
|
||
app.post(`/app/${FileManagerRoute.fileStat}`, async (request: any, reply: any) => {}) | ||
app.post(`/fs/${FileManagerRoute.fileStat}`, async (request: any, reply: any) => {}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.