nanoVLM-inference / Dockerfile
vidhanm
some changes
1792bb4
raw
history blame
1.51 kB
# Use a slim Python base image.
FROM python:3.9-slim
# Set the working directory in the container
WORKDIR /app
# Set Hugging Face cache directory and Gradio temp/flagging dir
# These will be within /app or /tmp, which we can make writable.
ENV HF_HOME=/app/.cache/huggingface
ENV GRADIO_TEMP_DIR=/tmp/gradio_tmp # For Gradio's own temp files
ENV GRADIO_FLAGGING_DIR=/tmp/gradio_flags # For Gradio flagging data
# Install git and build-essential (good practice for some pip installs)
RUN apt-get update && apt-get install -y \
git \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Create the cache and temp directories and make them writable by any user.
# The user running the app inside the container (often root by default in simple Dockerfiles,
# or a non-root user in managed environments like Spaces) needs to write here.
RUN mkdir -p $HF_HOME $GRADIO_TEMP_DIR $GRADIO_FLAGGING_DIR && \
chmod -R 777 $HF_HOME $GRADIO_TEMP_DIR $GRADIO_FLAGGING_DIR
# Copy the requirements file first to leverage Docker layer caching
COPY requirements.txt requirements.txt
# Install Python dependencies
# --no-cache-dir reduces image size
RUN pip install --no-cache-dir --prefer-binary -r requirements.txt
# Copy the application code into the container
COPY app.py app.py
# Expose the port Gradio will run on (default is 7860)
EXPOSE 7860
# Set the default command to run the Gradio application
# Using `python -u` for unbuffered output, which is good for logging
CMD ["python", "-u", "app.py"]