Spaces:
Sleeping
Sleeping
Updating Dockerfile
Browse files- Dockerfile +21 -6
Dockerfile
CHANGED
|
@@ -1,20 +1,35 @@
|
|
| 1 |
# Use Python base image
|
| 2 |
FROM python:3.12-slim-trixie
|
| 3 |
|
|
|
|
|
|
|
|
|
|
| 4 |
# Copy UV directly from official image
|
| 5 |
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
| 6 |
|
| 7 |
# Set working directory
|
| 8 |
WORKDIR /app
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
|
|
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
RUN /
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
#
|
|
|
|
| 17 |
COPY main.py llm_utils.py ./
|
| 18 |
|
| 19 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
CMD ["/bin/uv", "run", "main.py"]
|
|
|
|
| 1 |
# Use Python base image
|
| 2 |
FROM python:3.12-slim-trixie
|
| 3 |
|
| 4 |
+
# Create non-root user
|
| 5 |
+
RUN useradd -m -u 1000 user
|
| 6 |
+
|
| 7 |
# Copy UV directly from official image
|
| 8 |
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
| 9 |
|
| 10 |
# Set working directory
|
| 11 |
WORKDIR /app
|
| 12 |
|
| 13 |
+
# Set UV cache in /tmp and HOME for the user
|
| 14 |
+
ENV UV_CACHE_DIR=/tmp/.cache/uv \
|
| 15 |
+
HOME=/home/user
|
| 16 |
|
| 17 |
+
# Create cache directory with proper permissions
|
| 18 |
+
RUN mkdir -p /tmp/.cache/uv && \
|
| 19 |
+
chown -R user:user /tmp/.cache && \
|
| 20 |
+
chmod -R 777 /tmp/.cache
|
| 21 |
|
| 22 |
+
# Copy files first (as root)
|
| 23 |
+
COPY pyproject.toml ./
|
| 24 |
COPY main.py llm_utils.py ./
|
| 25 |
|
| 26 |
+
# Set proper permissions
|
| 27 |
+
RUN chown -R user:user /app && \
|
| 28 |
+
chmod -R 755 /app
|
| 29 |
+
|
| 30 |
+
# Switch to user and install dependencies
|
| 31 |
+
USER user
|
| 32 |
+
RUN /bin/uv sync
|
| 33 |
+
|
| 34 |
+
# Run the application
|
| 35 |
CMD ["/bin/uv", "run", "main.py"]
|