File size: 1,047 Bytes
c832f76 748cd96 c832f76 748cd96 c832f76 748cd96 c832f76 537868a 748cd96 16067a8 748cd96 16067a8 c832f76 16067a8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# Use an official Python runtime as a parent image
FROM python:3.9
# Set the working directory in the container
WORKDIR /app
# Create a group and user for running the application
RUN groupadd mygroup && useradd -ms /bin/bash -G mygroup appuser
# Copy the current directory contents into the container at /app
# Use --chown to set the ownership and --chmod to set the permissions
COPY --chown=appuser:mygroup . /app
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Make port 7860 available to the world outside this container
EXPOSE 7860
# Define environment variable for Gradio server port
ENV GRADIO_SERVER_PORT=7860
# Set the HF_HOME environment variable to a writable directory
ENV HF_HOME=/app/.cache/huggingface
# Create the cache directory if it doesn't exist and set its ownership
RUN mkdir -p $HF_HOME && chown -R appuser:mygroup $HF_HOME
# Switch to the appuser to run the application
USER appuser
# Run app.py when the container launches
CMD ["python", "app.py"]
|