SwarmChat / Dockerfile
InventorsHub's picture
Update Dockerfile
5d55ef2 verified
# Use a slim Python base image
FROM python:3.10-slim
# Create a non-root user (UID 1000) to match Spaces runtime
RUN useradd -m -u 1000 user
# Set environment vars for the non-root user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Set working directory
WORKDIR /home/user/app
# Copy only requirements first (for layer caching)
COPY --chown=user requirements.txt ./
# Switch to root to install system build dependencies
USER root
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
python3-dev \
libffi-dev \
&& rm -rf /var/lib/apt/lists/*
# Switch back to non-root user for pip install
USER user
RUN pip install --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# Copy the rest of your application code
COPY --chown=user . ./
# Expose the port your app runs on
EXPOSE 7860
# Launch the Gradio app on 0.0.0.0 so it's reachable externally
CMD ["python", "app.py", "--server_port", "7860", "--server_name", "0.0.0.0"]