Spaces:
Sleeping
Sleeping
Commit
·
d46bc4c
1
Parent(s):
f25bfe5
change docker
Browse files- Dockerfile +17 -18
Dockerfile
CHANGED
@@ -1,33 +1,32 @@
|
|
1 |
-
# Base
|
2 |
FROM python:3.10-slim
|
3 |
|
|
|
|
|
|
|
4 |
# Set environment variables
|
5 |
-
ENV
|
6 |
-
|
|
|
7 |
|
8 |
-
#
|
|
|
|
|
|
|
|
|
|
|
9 |
RUN adduser --disabled-password --gecos "" appuser
|
10 |
USER appuser
|
11 |
|
12 |
-
#
|
13 |
-
WORKDIR /home/appuser/app
|
14 |
-
|
15 |
-
# Copy project files
|
16 |
COPY --chown=appuser:appuser . .
|
17 |
|
18 |
-
#
|
19 |
-
RUN pip install --upgrade pip \
|
20 |
-
&& pip install -r requirement.txt
|
21 |
-
|
22 |
-
# If using .env file, install python-dotenv and make sure app reads it
|
23 |
-
RUN pip install python-dotenv
|
24 |
-
|
25 |
-
# Expose FastAPI default port
|
26 |
EXPOSE 8000
|
27 |
-
# Expose Streamlit default port
|
28 |
EXPOSE 8501
|
29 |
|
30 |
-
# Start FastAPI
|
31 |
CMD uvicorn streamlit_app.main_api:app --host 0.0.0.0 --port 8000 & \
|
32 |
streamlit run streamlit_app/app.py --server.port 8501
|
33 |
|
|
|
|
1 |
+
# Base image
|
2 |
FROM python:3.10-slim
|
3 |
|
4 |
+
# Create app directory
|
5 |
+
WORKDIR /home/appuser/app
|
6 |
+
|
7 |
# Set environment variables
|
8 |
+
ENV PATH="/home/appuser/.local/bin:$PATH"
|
9 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
10 |
+
ENV PYTHONUNBUFFERED=1
|
11 |
|
12 |
+
# Install dependencies
|
13 |
+
COPY requirement.txt .
|
14 |
+
RUN pip install --upgrade pip \
|
15 |
+
&& pip install --user -r requirement.txt
|
16 |
+
|
17 |
+
# Add a non-root user
|
18 |
RUN adduser --disabled-password --gecos "" appuser
|
19 |
USER appuser
|
20 |
|
21 |
+
# Copy code
|
|
|
|
|
|
|
22 |
COPY --chown=appuser:appuser . .
|
23 |
|
24 |
+
# Expose ports
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
EXPOSE 8000
|
|
|
26 |
EXPOSE 8501
|
27 |
|
28 |
+
# Start FastAPI then Streamlit
|
29 |
CMD uvicorn streamlit_app.main_api:app --host 0.0.0.0 --port 8000 & \
|
30 |
streamlit run streamlit_app/app.py --server.port 8501
|
31 |
|
32 |
+
|