project3 / Dockerfile
adaptFast's picture
Upload Dockerfile with huggingface_hub
dcbf6ec verified
Raw
History Blame Contribute Delete
1.12 kB
# Use a specific, slim Python version that satisfies all dependencies
FROM python:3.11-slim
# Create a non-root user for security best practices
# The -m flag creates the user's home directory
RUN useradd -m -u 1000 user
# Switch to the non-root user
USER user
# Set up the environment PATH for the non-root user to find installed packages
ENV PATH="/home/user/.local/bin:${PATH}"
# Set the working directory inside the container
WORKDIR /app
# Copy and install dependencies first to leverage Docker layer caching
# --chown ensures the 'user' owns the copied files, not 'root'
COPY --chown=user:user requirements.txt .
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Copy the rest of the application files, including app.py and the nutritional_db folder
COPY --chown=user:user . .
# Expose the port that Streamlit will run on (this is good practice for documentation)
EXPOSE 7860
# The command to run when the container starts.
# Runs the Streamlit app on the correct port and makes it available to the host.
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]