This supplements to CAAI_AI repository
Dockerfile you can use to dockerize your FastAPI backend (main.py
). I’ll assume your project structure looks like this:
project-root/
│── main.py
│── requirements.txt
│── Dockerfile
✅ Dockerfile.txt
# Use an official lightweight Python image
FROM python:3.11-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# Set work directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential curl git && \
rm -rf /var/lib/apt/lists/*
# Copy requirements first for efficient caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the entire project
COPY . .
# Expose FastAPI port
EXPOSE 8000
# Run the FastAPI app with uvicorn
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
✅ requirements.txt
If you don’t already have one, here’s what your requirements.txt
should contain based on your code:
fastapi
uvicorn[standard]
pydantic
langchain
langchain-community
langgraph
(If you know extra versions you want pinned, you can add ==
versions.)
✅ Build & Run Docker Container
From your project root:
# Build the image
docker build -t company-recommender-backend .
# Run the container
docker run -d -p 8000:8000 company-recommender-backend
⚡ Your FastAPI backend will now be available at:
http://localhost:8000
Response :
No comments:
Post a Comment