Update Dockerfile
Browse files- Dockerfile +28 -51
Dockerfile
CHANGED
@@ -1,58 +1,35 @@
|
|
1 |
-
# Use
|
2 |
-
FROM python:3.
|
3 |
|
4 |
-
# Set environment variables
|
5 |
-
ENV
|
6 |
-
|
7 |
-
LC_ALL=C.UTF-8 \
|
8 |
-
PIP_NO_CACHE_DIR=1 \
|
9 |
-
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
|
10 |
|
11 |
-
#
|
12 |
WORKDIR /app
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
apt-get update && apt-get install -y \
|
17 |
build-essential \
|
18 |
curl \
|
19 |
git \
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
34 |
-
|
35 |
-
# Switch to non-root user for safety
|
36 |
-
USER appuser
|
37 |
-
|
38 |
-
# Copy requirement files and install dependencies
|
39 |
-
COPY --chown=appuser:appuser requirements.txt /app/
|
40 |
-
RUN pip install --upgrade pip && pip install -r requirements.txt
|
41 |
-
|
42 |
-
# Copy rest of the application code
|
43 |
-
COPY --chown=appuser:appuser . /app
|
44 |
-
|
45 |
-
# Streamlit config
|
46 |
-
RUN echo "\
|
47 |
-
[server]\n\
|
48 |
-
headless = true\n\
|
49 |
-
port = 8501\n\
|
50 |
-
enableCORS = false\n\
|
51 |
-
\n\
|
52 |
-
[theme]\n\
|
53 |
-
base = 'light'\n\
|
54 |
-
" > /home/appuser/.streamlit/config.toml
|
55 |
-
|
56 |
-
# Default command
|
57 |
EXPOSE 8501
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use an official Python runtime as a parent image
|
2 |
+
FROM python:3.9-slim
|
3 |
|
4 |
+
# Set environment variables to prevent Python from writing .pyc files and to buffer outputs
|
5 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
6 |
+
ENV PYTHONUNBUFFERED=1
|
|
|
|
|
|
|
7 |
|
8 |
+
# Set the working directory in the container
|
9 |
WORKDIR /app
|
10 |
+
|
11 |
+
# Install system dependencies
|
12 |
+
RUN apt-get update && apt-get install -y \
|
|
|
13 |
build-essential \
|
14 |
curl \
|
15 |
git \
|
16 |
+
&& rm -rf /var/lib/apt/lists/*
|
17 |
+
|
18 |
+
# Copy the requirements file into the container
|
19 |
+
COPY requirements.txt .
|
20 |
+
|
21 |
+
# Install Python dependencies
|
22 |
+
RUN pip install --upgrade pip && \
|
23 |
+
pip install --no-cache-dir -r requirements.txt
|
24 |
+
|
25 |
+
# Copy the rest of the application code into the container
|
26 |
+
COPY . .
|
27 |
+
|
28 |
+
# Expose the port that Streamlit uses
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
EXPOSE 8501
|
30 |
+
|
31 |
+
# Set the entry point to run the Streamlit application
|
32 |
+
ENTRYPOINT ["streamlit", "run"]
|
33 |
+
|
34 |
+
# Specify the default command to run the app
|
35 |
+
CMD ["app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|