nanoVLM-inference / Dockerfile
vidhanm
some chang
055abc9
raw
history blame
1.28 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
ENV GRADIO_FLAGGING_DIR=/tmp/gradio_flags
# 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.
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"]