Skip to content

Commit

Permalink
🖼️ feat: Implement Lite Image for Smaller Footprint (#10)
Browse files Browse the repository at this point in the history
* feat: lite image for smaller image footprint

* chore: remove unused import

* chore: add back permissions to workflow

fix(Dockerfile.lite): add `lite` target stage

fix: declare target stage outright for Dockerfiles
  • Loading branch information
danny-avila committed Mar 25, 2024
1 parent 5190969 commit 8201302
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 9 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/images.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
name: Docker Dev Images Build



on:
workflow_dispatch:
push:
Expand All @@ -16,6 +14,16 @@ jobs:
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- target: main
file: Dockerfile
image_name: librechat-rag-api-dev
- target: lite
file: Dockerfile.lite
image_name: librechat-rag-api-dev-lite

steps:
# Check out the repository
- name: Checkout
Expand All @@ -37,14 +45,15 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Build and push Docker image
- name: Build and push Docker image
# Build and push Docker images for each target
- name: Build and push Docker images
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
file: ${{ matrix.file }}
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/librechat-rag-api-dev:${{ github.sha }}
ghcr.io/${{ github.repository_owner }}/librechat-rag-api-dev:latest
ghcr.io/${{ github.repository_owner }}/${{ matrix.image_name }}:${{ github.sha }}
ghcr.io/${{ github.repository_owner }}/${{ matrix.image_name }}:latest
platforms: linux/amd64,linux/arm64
target: ${{ matrix.target }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10
FROM python:3.10 AS main

WORKDIR /app

Expand Down
15 changes: 15 additions & 0 deletions Dockerfile.lite
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.10 AS lite

WORKDIR /app

# Install pandoc and netcat
RUN apt-get update \
&& apt-get install -y pandoc netcat-openbsd \
&& rm -rf /var/lib/apt/lists/*

COPY requirements.lite.txt .
RUN pip install --no-cache-dir -r requirements.lite.txt

COPY . .

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
1 change: 0 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from shutil import copyfileobj
from langchain.schema import Document
from contextlib import asynccontextmanager
from fastapi.responses import JSONResponse
from dotenv import find_dotenv, load_dotenv
from fastapi.middleware.cors import CORSMiddleware
from langchain_core.runnables.config import run_in_executor
Expand Down
22 changes: 22 additions & 0 deletions requirements.lite.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
langchain==0.1.12
langchain_community==0.0.28
langchain_openai==0.0.8
langchain_core==0.1.32
sqlalchemy==2.0.28
python-dotenv==1.0.1
fastapi==0.110.0
psycopg2-binary==2.9.9
pgvector==0.2.5
uvicorn==0.28.0
pypdf==4.1.0
unstructured==0.12.6
markdown==3.6
networkx==3.2.1
pandas==2.2.1
openpyxl==3.1.2
docx2txt==0.8
pypandoc==1.13
python-jose==3.3.0
asyncpg==0.29.0
python-multipart==0.0.9
aiofiles==23.2.1

0 comments on commit 8201302

Please sign in to comment.