CodexPilot / Dockerfile
SharathReddy's picture
Update Dockerfile
89ed536 verified
# Use a specific, stable version of the slim image
FROM python:3.10.13-slim-bullseye
# Set environment variables to prevent interactive prompts during build
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
# Install git and other system dependencies as root
RUN apt-get update && apt-get install -y --no-install-recommends git curl && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Create a non-root user and its home directory
RUN useradd -m -u 1000 user
WORKDIR /home/user/code
# Set the cache directory for Hugging Face libraries
# This directory will be created with the correct ownership later
ENV HF_HOME=/home/user/code/.cache
ENV PATH="/home/user/.local/bin:${PATH}"
# Copy requirements file and install dependencies as the new user
# First, change ownership of the destination directory
RUN chown -R user:user /home/user/code
USER user
COPY --chown=user:user ./requirements.txt .
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Copy the rest of the application code
COPY --chown=user:user ./app.py .
# Expose the port
EXPOSE 7860
# Run the application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]