Authentica / Dockerfile
MAS-AI-0000's picture
Update Dockerfile (#1)
0e43eb4
# Use official Python base (slim to keep image small)
FROM python:3.11.9
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
libgl1 \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender1 \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y \
libxi6 \
libsm6 \
libxrender1 \
libgl1-mesa-glx \
libglib2.0-0 \
libxkbcommon-x11-0 \
libxxf86vm1 \
libxfixes3 \
libegl1 \
libgomp1 \
# Clean up apt cache to reduce image size
&& rm -rf /var/lib/apt/lists/*
# Create and switch to a non-root user
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# Set working directory
WORKDIR /app
# Copy requirements first (better cache)
COPY --chown=user ./requirements.txt requirements.txt
# Upgrade pip and install deps
RUN python -m pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt \
&& pip list
RUN python -c "import clip; clip.load('ViT-B/32', device = 'cpu', jit=False)"
# Copy app code
COPY --chown=user . /app
# Expose the default Spaces port
EXPOSE 7860
# Run FastAPI server (Spaces sets $PORT, default to 7860)
CMD ["bash", "-lc", "uvicorn app:app --host 0.0.0.0 --port ${PORT:-7860}"]