Spaces:
Sleeping
Sleeping
UPDATE:
Browse files- Dockerfile +6 -28
Dockerfile
CHANGED
|
@@ -1,41 +1,19 @@
|
|
| 1 |
-
# 1. Start from a slim, official Python base image
|
| 2 |
FROM python:3.12-slim
|
| 3 |
|
| 4 |
-
|
| 5 |
-
# - Prevents Python from writing .pyc files
|
| 6 |
-
# - Prevents Python from buffering stdout and stderr
|
| 7 |
-
# - Sets the location for uv's cache to a user-owned directory
|
| 8 |
-
ENV PYTHONDONTWRITEBYTECODE 1
|
| 9 |
-
ENV PYTHONUNBUFFERED 1
|
| 10 |
|
| 11 |
-
# 3. Set the working directory
|
| 12 |
WORKDIR /app
|
| 13 |
|
| 14 |
-
|
| 15 |
-
# This is a critical security best practice.
|
| 16 |
-
RUN useradd --create-home --shell /bin/bash appuser
|
| 17 |
|
| 18 |
-
# 5. Install uv globally (as root, which is fine for this step)
|
| 19 |
RUN pip install uv
|
| 20 |
|
| 21 |
-
|
| 22 |
-
COPY pyproject.toml ./
|
| 23 |
|
| 24 |
-
|
| 25 |
-
# We also ensure the virtual environment is created with correct ownership.
|
| 26 |
-
RUN uv sync --system-site-packages && chown -R appuser:appuser /app/.venv
|
| 27 |
|
| 28 |
-
|
| 29 |
-
COPY . .
|
| 30 |
|
| 31 |
-
|
| 32 |
-
RUN chown -R appuser:appuser /app
|
| 33 |
|
| 34 |
-
# 10. Switch to the non-root user
|
| 35 |
-
USER appuser
|
| 36 |
-
|
| 37 |
-
# 11. Expose the correct port that the application runs on
|
| 38 |
-
EXPOSE 8000
|
| 39 |
-
|
| 40 |
-
# 12. Define the command to run the application
|
| 41 |
CMD ["uv", "run", "main.py"]
|
|
|
|
|
|
|
| 1 |
FROM python:3.12-slim
|
| 2 |
|
| 3 |
+
COPY . /app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
|
|
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
USER root
|
|
|
|
|
|
|
| 8 |
|
|
|
|
| 9 |
RUN pip install uv
|
| 10 |
|
| 11 |
+
RUN uv sync
|
|
|
|
| 12 |
|
| 13 |
+
RUN chmod -R 777 /app
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
RUN chmod -R u+rwX,go+rX /app
|
|
|
|
| 16 |
|
| 17 |
+
EXPOSE 7860
|
|
|
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
CMD ["uv", "run", "main.py"]
|