Update Dockerfile
Browse files- Dockerfile +19 -21
Dockerfile
CHANGED
@@ -1,36 +1,34 @@
|
|
|
|
1 |
FROM python:3.10-slim
|
2 |
|
|
|
3 |
WORKDIR /app
|
4 |
|
5 |
-
# Copy
|
6 |
-
COPY requirements.txt
|
|
|
|
|
7 |
RUN pip install --no-cache-dir -r requirements.txt
|
8 |
|
9 |
-
# Copy
|
10 |
-
COPY
|
11 |
|
12 |
-
# Expose the port Streamlit will run on
|
13 |
EXPOSE 8501
|
14 |
|
15 |
-
#
|
16 |
RUN useradd -m -u 1000 user
|
17 |
|
18 |
-
#
|
19 |
-
RUN mkdir -p /
|
20 |
-
|
21 |
-
/tmp/.cache/xdg \
|
22 |
-
/tmp/.streamlit && \
|
23 |
-
chown -R user:user /tmp/.cache
|
24 |
|
25 |
-
#
|
26 |
USER user
|
27 |
|
28 |
-
#
|
29 |
-
ENV TRANSFORMERS_CACHE=/
|
30 |
-
HF_HOME=/
|
31 |
-
XDG_CACHE_HOME=/tmp/.cache/xdg \
|
32 |
-
STREAMLIT_CONFIG_DIR=/tmp/.streamlit
|
33 |
|
34 |
-
#
|
35 |
-
ENTRYPOINT ["streamlit", "run", "
|
36 |
-
"--server.port=8501", "--server.address=0.0.0.0"]
|
|
|
1 |
+
# Use the official Python 3.10 slim image as a base
|
2 |
FROM python:3.10-slim
|
3 |
|
4 |
+
# Set the working directory inside the container
|
5 |
WORKDIR /app
|
6 |
|
7 |
+
# Copy the requirements file into the container
|
8 |
+
COPY requirements.txt ./requirements.txt
|
9 |
+
|
10 |
+
# Install the Python dependencies
|
11 |
RUN pip install --no-cache-dir -r requirements.txt
|
12 |
|
13 |
+
# Copy your Streamlit application file into the container
|
14 |
+
COPY streamlit_app.py ./streamlit_app.py
|
15 |
|
16 |
+
# Expose the port that Streamlit will run on
|
17 |
EXPOSE 8501
|
18 |
|
19 |
+
# Create a non-root user for security
|
20 |
RUN useradd -m -u 1000 user
|
21 |
|
22 |
+
# Set up writable cache directories and give the new user ownership
|
23 |
+
RUN mkdir -p /home/user/.cache && \
|
24 |
+
chown -R user:user /home/user/.cache
|
|
|
|
|
|
|
25 |
|
26 |
+
# Switch to the non-root user
|
27 |
USER user
|
28 |
|
29 |
+
# Set environment variables to point to the new cache directories
|
30 |
+
ENV TRANSFORMERS_CACHE=/home/user/.cache/transformers \
|
31 |
+
HF_HOME=/home/user/.cache/huggingface
|
|
|
|
|
32 |
|
33 |
+
# The command to run your Streamlit application when the container starts
|
34 |
+
ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
|