Update Dockerfile
Browse files- Dockerfile +19 -11
Dockerfile
CHANGED
|
@@ -1,19 +1,27 @@
|
|
| 1 |
FROM python:3.10
|
| 2 |
|
| 3 |
-
# 1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
RUN useradd -m -u 1000 user
|
|
|
|
|
|
|
| 5 |
USER user
|
| 6 |
-
ENV PATH="/home/user/.local/bin:$PATH"
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
|
| 13 |
-
RUN pip install --user --no-cache-dir -r requirements.txt
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
COPY --chown=user:user .
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
CMD ["
|
|
|
|
| 1 |
FROM python:3.10
|
| 2 |
|
| 3 |
+
# 1. Set a temporary working directory
|
| 4 |
+
WORKDIR /code
|
| 5 |
+
|
| 6 |
+
# 2. Copy just the requirements first and install them GLOBALLY
|
| 7 |
+
COPY ./requirements.txt /code/requirements.txt
|
| 8 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 9 |
+
|
| 10 |
+
# 3. Create the restricted user required by Hugging Face Spaces
|
| 11 |
RUN useradd -m -u 1000 user
|
| 12 |
+
|
| 13 |
+
# 4. Switch to that user
|
| 14 |
USER user
|
|
|
|
| 15 |
|
| 16 |
+
# 5. Set up the user's safe environment variables
|
| 17 |
+
ENV HOME=/home/user
|
| 18 |
+
ENV PATH=/home/user/.local/bin:$PATH
|
| 19 |
|
| 20 |
+
# 6. Set the working directory to the user's safe space
|
| 21 |
+
WORKDIR $HOME/app
|
|
|
|
| 22 |
|
| 23 |
+
# 7. Copy your app.py and images into the container, owned by the safe user
|
| 24 |
+
COPY --chown=user:user . $HOME/app
|
| 25 |
|
| 26 |
+
# 8. Launch Streamlit safely
|
| 27 |
+
CMD ["streamlit", "run", "app.py", "--server.port", "7860", "--server.address", "0.0.0.0"]
|