File size: 1,066 Bytes
6ffd709
aa965c9
2a8700a
6ffd709
4470d30
bcdc1fa
6ffd709
 
 
 
bcdc1fa
 
6ffd709
 
bcdc1fa
6ffd709
4470d30
bcdc1fa
6ffd709
2a8700a
 
6ffd709
 
 
2a8700a
6ffd709
2a8700a
59f13db
6ffd709
 
 
59f13db
6ffd709
 
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 the official Python 3.10 slim image as a base
FROM python:3.10-slim

# Set the working directory inside the container
WORKDIR /app

# Copy the requirements file into the container
COPY requirements.txt ./requirements.txt

# Install the Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy your Streamlit application file into the container
COPY streamlit_app.py ./streamlit_app.py

# Expose the port that Streamlit will run on
EXPOSE 8501

# Create a non-root user for security
RUN useradd -m -u 1000 user

# Set up writable cache directories and give the new user ownership
RUN mkdir -p /home/user/.cache && \
    chown -R user:user /home/user/.cache

# Switch to the non-root user
USER user

# Set environment variables to point to the new cache directories
ENV TRANSFORMERS_CACHE=/home/user/.cache/transformers \
    HF_HOME=/home/user/.cache/huggingface

# The command to run your Streamlit application when the container starts
ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]