File size: 1,118 Bytes
5347034
dcbf6ec
 
5347034
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

# 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"]