Spaces:
Running
Running
FROM python:3.8-slim | |
# Install Dependencies | |
RUN apt-get update -q \ | |
&& apt-get install -qy --no-install-recommends wget git libopencv-dev python3-opencv \ | |
&& apt-get autoremove -y \ | |
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Set up a non-root user | |
RUN useradd -m -u 1000 user \ | |
&& mkdir /app \ | |
&& chown -R user /app | |
# Switch to the "user" user | |
USER user | |
# Set the working directory to the user's home directory | |
WORKDIR /app | |
ENV PYTHONUNBUFFERED=True \ | |
VITH_CHECKPOINT=/app/models/sam_vit_h_4b8939.pth \ | |
MOBILESAM_CHECKPOINT=/app/models/mobile_sam.pt \ | |
ONNX_CHECKPOINT=/app/models/sam_onnx_quantized_example.onnx \ | |
PORT=7860 | |
# Copy and run the model download script | |
COPY download_models.sh . | |
RUN bash /app/download_models.sh | |
# Install Python dependencies | |
COPY requirements.txt . | |
RUN pip install --user --no-cache-dir -r requirements.txt | |
COPY . ./ | |
EXPOSE 7860 | |
CMD ["/app/start.sh"] | |