rag-chat-botapi / Dockerfile
Pamudu13's picture
Update Dockerfile
4707b28 verified
raw
history blame
1.76 kB
# Use an official Python image as a base
FROM python:3.9
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PORT=7860 \
PYTHONPATH=/app \
HOME=/home/chrome \
CHROME_BIN=/usr/bin/google-chrome-stable
# Install system dependencies including Chrome and other utilities
RUN apt-get update && apt-get install -y \
build-essential \
wget \
gnupg \
unzip \
xvfb \
curl \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \
&& apt-get update \
&& apt-get install -y google-chrome-stable \
&& rm -rf /var/lib/apt/lists/*
# Create chrome user and set appropriate permissions
RUN groupadd -r chrome && \
useradd -r -g chrome -G audio,video chrome && \
mkdir -p /home/chrome/Downloads && \
mkdir -p /home/chrome/.cache && \
chown -R chrome:chrome /home/chrome
# Set the working directory
WORKDIR /app
# Copy requirements file
COPY requirements.txt ./
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt \
&& pip install --no-cache-dir hypercorn
# Copy the current directory contents into the container
COPY . /app
# Ensure permissions are correct for the app directory
RUN chown -R chrome:chrome /app
# Ensure .cache directory is accessible for the chrome user
RUN mkdir -p /home/chrome/.cache/huggingface && \
chown -R chrome:chrome /home/chrome/.cache && \
chmod -R 777 /home/chrome/.cache
# Switch to chrome user
USER chrome
# Make port 7860 available to the world outside this container
EXPOSE 7860
# Run the app with Hypercorn
CMD ["hypercorn", "app:app", "--bind", "0.0.0.0:7860"]