From ae1536768abe40ce4cdef86b574b13b8edd53cb1 Mon Sep 17 00:00:00 2001 From: Marcus Schiesser <mail@marcusschiesser.de> Date: Thu, 28 Mar 2024 16:06:22 +0800 Subject: [PATCH] fix: Dockerfile for express and improve READMEs --- .../components/deployments/typescript/Dockerfile | 12 +++--------- .../types/streaming/express/README-template.md | 15 ++++++++------- .../types/streaming/fastapi/README-template.md | 13 +++++++------ .../types/streaming/nextjs/README-template.md | 6 +++--- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/templates/components/deployments/typescript/Dockerfile b/templates/components/deployments/typescript/Dockerfile index b9b28f2d..5c738ab4 100644 --- a/templates/components/deployments/typescript/Dockerfile +++ b/templates/components/deployments/typescript/Dockerfile @@ -3,8 +3,8 @@ FROM node:20-alpine as build WORKDIR /app # Install dependencies -COPY package.json pnpm-lock.yaml* /app/ -RUN npm install +COPY package.json package-lock.* ./ +RUN npm install # Build the application COPY . . @@ -13,10 +13,4 @@ RUN npm run build # ==================================== FROM build as release -# Copy built output from the previous stage -COPY --from=build /app/.next* ./.next -COPY --from=build /app/public* ./public -COPY --from=build /app/package.json ./package.json -COPY --from=build /app/node_modules ./node_modules - -CMD ["npm", "start"] \ No newline at end of file +CMD ["npm", "run", "start"] \ No newline at end of file diff --git a/templates/types/streaming/express/README-template.md b/templates/types/streaming/express/README-template.md index 61e164bf..8ec04664 100644 --- a/templates/types/streaming/express/README-template.md +++ b/templates/types/streaming/express/README-template.md @@ -62,32 +62,33 @@ NODE_ENV=production npm run start ## Using Docker -1. Build an image for Express app: +1. Build an image for the Express API: ``` docker build -t <your_backend_image_name> . ``` -2. Start the app: +2. Generate embeddings: -- Generate index data: +Parse the data and generate the vector embeddings if the `./data` folder exists - otherwise, skip this step: ``` docker run --rm \ - --v $(pwd)/.env:/app/.env \ # Use ENV variables and configuration from your file-system + -v $(pwd)/.env:/app/.env \ # Use ENV variables and configuration from your file-system -v $(pwd)/config:/app/config \ - -v $(pwd)/cache:/app/cache \ # Use your file system to store gea vector database + -v $(pwd)/data:/app/data \ + -v $(pwd)/cache:/app/cache \ # Use your file system to store the vector database <your_backend_image_name> npm run generate ``` -- Start the API: +3. Start the API: ``` docker run \ -v $(pwd)/.env:/app/.env \ # Use ENV variables and configuration from your file-system -v $(pwd)/config:/app/config \ - -v $(pwd)/cache:/app/cache \ # Use your file system to store gea vector database + -v $(pwd)/cache:/app/cache \ # Use your file system to store the vector database -p 8000:8000 \ <your_backend_image_name> ``` diff --git a/templates/types/streaming/fastapi/README-template.md b/templates/types/streaming/fastapi/README-template.md index 33dbeba6..2ea07212 100644 --- a/templates/types/streaming/fastapi/README-template.md +++ b/templates/types/streaming/fastapi/README-template.md @@ -64,29 +64,30 @@ The API allows CORS for all origins to simplify development. You can change this ENVIRONMENT=prod python main.py ``` -## Using docker +## Using Docker -1. Build an image for FastAPI app: +1. Build an image for the FastAPI app: ``` docker build -t <your_backend_image_name> . ``` -2. Start the app: +2. Generate embeddings: -- Generate embedding for index data: +Parse the data and generate the vector embeddings if the `./data` folder exists - otherwise, skip this step: ``` docker run \ --rm \ -v $(pwd)/.env:/app/.env \ # Use ENV variables and configuration from your file-system -v $(pwd)/config:/app/config \ - -v $(pwd)/storage:/app/storage \ # Use your file system to store gea vector database + -v $(pwd)/data:/app/data \ # Use your local folder to read the data + -v $(pwd)/storage:/app/storage \ # Use your file system to store the vector database <your_backend_image_name> \ python app/engine/generate.py ``` -- Start the API: +3. Start the API: ``` docker run \ diff --git a/templates/types/streaming/nextjs/README-template.md b/templates/types/streaming/nextjs/README-template.md index c522d311..d2eb1eb8 100644 --- a/templates/types/streaming/nextjs/README-template.md +++ b/templates/types/streaming/nextjs/README-template.md @@ -43,13 +43,13 @@ docker run \ --rm \ -v $(pwd)/.env:/app/.env \ # Use ENV variables and configuration from your file-system -v $(pwd)/config:/app/config \ - -v $(pwd)/cache:/app/cache \ # Use your file system to store gea vector database - -p 3000:3000 \ + -v $(pwd)/data:/app/data \ + -v $(pwd)/cache:/app/cache \ # Use your file system to store the vector database <your_app_image_name> \ npm run generate ``` -3. Start the API +3. Start the app: ``` docker run \ -- GitLab