Farzad-R / LLM-Zero-to-Hundred

This repository contains different LLM chatbot projects (RAG, LLM agents, etc.) and well-known techniques for training and fine tuning LLMs.
193 stars 105 forks source link

Any Idea how to create Docker file for RAG-GPT Application #12

Closed itzkunalsatpute closed 2 months ago

itzkunalsatpute commented 2 months ago

Hi Farzad,

I just wanted to know how to create docker image for RAG-GPT Application. I tried creating image but it gives error. Any Idea how to deploy this app on Azure?

''' Use Python runtime as a parent image FROM python:3.11.9-slim

Setting the working directory inside the container WORKDIR /app

# Copy the dependencies file to the working directory COPY requirements.txt .

# Install any dependencies RUN pip install --no-cache-dir -r requirements.txt --default-timeout=100 future

# Copy the current directory contents into the container at /app COPY . .

# Change the working directory to /app/src WORKDIR /app/src

# Make ports available to the world outside this container EXPOSE 7860 EXPOSE 8000

# Install Supervisor and create directory structure RUN apt-get update && \ apt-get install -y supervisor && \ mkdir -p /app/src/logs

# Copy the supervisord.conf file COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

Start Supervisor service

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

'''

Supervisord

''' [supervisord] nodaemon=true

[program:serve] command=python serve.py autostart=true autorestart=true directory=/app/src

user=root ; Change this to the appropriate user if needed

[program:gradio] command=python raggpt_app.py autostart=true autorestart=true directory=/app/src

user=root ; Change this to the appropriate user if needed '''

Farzad-R commented 2 months ago

Hi. What error do you get?

itzkunalsatpute commented 2 months ago

Hi Farzad: I want to deploy RAG-GPT app on Azure Web APP. Below are the steps which i performed ON mac m1

  1. RAG-GPT app is running fine on local machine
  2. Created Docker file
  3. Created Resource group on Azure
  4. Uploaded docker image on Azure container registry
  5. Created Azure webapp and liked above container registry
  6. After deployment when i click on default domain my app is getting" Application Error"

Changes which I made in app.py or raggpt_app.py file

Screenshot 2024-04-13 at 2 07 26 PM

my docker file

Screenshot 2024-04-13 at 2 06 54 PM

Did some configuration changes on webapp

Screenshot 2024-04-13 at 2 06 30 PM Screenshot 2024-04-13 at 2 06 15 PM

Azure startup command python app.py

Can you tell when where I am going wrong?

below are logs

2024-04-13T09:59:34.272Z INFO - docker run -d --expose=7860 --name chatbot_0_ace8904f -e WEBSITE_USE_DIAGNOSTIC_SERVER=false -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITES_PORT=7860 -e WEBSITE_SITE_NAME=chatbot -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=chatbot.azurewebsites.net -e WEBSITE_INSTANCE_ID=9480f1b3aea41281b02d48f3129dccfd2f31e69b8bdcefabb76bd8b5a937796 chatbot.azurecr.io/images:latest python src/raggpt_app.py 2024-04-13T09:59:34.272Z INFO - Logging is not enabled for this container.Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here. 2024-04-13T09:59:39.991Z INFO - Initiating warmup request to container chatbot_0_ace8904f_msiProxy for site chatbot 2024-04-13T09:59:40.052Z INFO - Container chatbot_0_ace8904f_msiProxy for site chatbot initialized successfully and is ready to serve requests. 2024-04-13T09:59:40.053Z INFO - Initiating warmup request to container chatbot_0_ace8904f for site chatbot 2024-04-13T09:59:55.465Z ERROR - Container chatbot_0_ace8904f for site chatbot has exited, failing site start 2024-04-13T09:59:55.472Z ERROR - Container chatbot_0_ace8904f didn't respond to HTTP pings on port: 7860, failing site start. See container logs for debugging. 2024-04-13T09:59:55.732Z INFO - Stopping site chatbot because it failed during startup.Ending Log Tail of existing logs ---Starting Live Log Stream ---

itzkunalsatpute commented 2 months ago

This has been resolved, just a quick note for all mac silicon users when deploying it to azure you need to create a docker compatible file

docker file before: FROM python:3.9-slim #for windows machine after: FROM --platform=linux/amd64 python:3.9-slim #for m1 silicon machine

also while building image below is the command sudo docker build --no-cache --platform linux/amd64 -t app .

this resolved the issue

Farzad-R commented 2 months ago

Happy to hear it. Great job. I'll close the issue then.