Skip to content

Commit

Permalink
added multistage docker file
Browse files Browse the repository at this point in the history
Signed-off-by: SarveshAtawane <[email protected]>
  • Loading branch information
SarveshAtawane committed Aug 16, 2024
1 parent 618b3d1 commit 5b826c8
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 11 deletions.
46 changes: 46 additions & 0 deletions src/DockerFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM node:20-alpine AS frontend-build
WORKDIR /app/frontend
COPY frontend .
RUN yarn install && yarn build


FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04 AS backend-build
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV PATH="/usr/local/bin:${PATH}"
RUN apt-get update && \
apt-get install -y python3-pip python3-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app/core
COPY core/requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu118


FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV PATH="/usr/local/bin:${PATH}"
ENV NODE_VERSION=20.x
RUN apt-get update && apt-get install -y \
python3-pip \
wget \
curl \
&& curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - \
&& apt-get install -y nodejs \
&& npm install -g yarn \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY --from=backend-build /usr/local/lib/python3.10/dist-packages /usr/local/lib/python3.10/dist-packages
COPY core ./core
COPY --from=frontend-build /app/frontend ./frontend
COPY frontend/package.json frontend/yarn.lock ./frontend/
WORKDIR /app/frontend
RUN yarn install --production
WORKDIR /app
COPY entrypoint.sh .
RUN chmod +x entrypoint.sh
EXPOSE 3000 8080
ENTRYPOINT ["./entrypoint.sh"]
7 changes: 7 additions & 0 deletions src/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```bash
docker build -t aifaq .
```
Now run this image from this command
```bash
docker run --gpus all -p 3000:3000 -p 8080:8080 aifaq
```
23 changes: 12 additions & 11 deletions src/core/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ def get_conversation():

# build huggingface pipeline for using zephyr-7b-beta
llm_pipeline = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
use_cache=True,
device_map="auto",
max_length=4096, # 4096
do_sample=True,
top_k=5,
num_return_sequences=1,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.eos_token_id,
"text-generation",
model=model,
tokenizer=tokenizer,
use_cache=True,
device_map="auto",
max_length=4096, # 4096
truncation=True,
do_sample=True,
top_k=5,
num_return_sequences=1,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.eos_token_id,
)

# specify the llm
Expand Down
8 changes: 8 additions & 0 deletions src/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

cd /app/core
python3 fetch_and_organize_data.py
python3 api.py &

cd /app/frontend
yarn start

0 comments on commit 5b826c8

Please sign in to comment.