Spaces:
Sleeping
Sleeping
chore: Standardize Dockerfile user to UID 1000 and set HOME to /app for improved platform compatibility.
Browse files- Dockerfile +9 -7
Dockerfile
CHANGED
|
@@ -5,8 +5,10 @@ FROM mcr.microsoft.com/playwright/python:v1.49.0-noble
|
|
| 5 |
# Set non-interactive mode for apt
|
| 6 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
|
|
|
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
# Set working directory
|
|
@@ -36,24 +38,24 @@ RUN playwright install chromium
|
|
| 36 |
# Copy application code
|
| 37 |
COPY . .
|
| 38 |
|
| 39 |
-
# Adjust permissions for the user
|
| 40 |
-
RUN chown -R
|
| 41 |
|
| 42 |
# Create necessary directories for the app (data, cache) and ensure permission
|
| 43 |
# HF Spaces likes /data for persistent storage if configured, but we map it in code.
|
| 44 |
# Here we just make sure our app directories are writable
|
| 45 |
RUN mkdir -p /app/data /app/memory /tmp/cache /tmp/hf && \
|
| 46 |
-
chown -R
|
| 47 |
|
| 48 |
# Switch to the non-root user
|
| 49 |
-
USER
|
| 50 |
|
| 51 |
# Expose the port
|
| 52 |
EXPOSE 7860
|
| 53 |
|
| 54 |
# Define environment variables
|
| 55 |
ENV PYTHONUNBUFFERED=1
|
| 56 |
-
ENV HOME=/
|
| 57 |
|
| 58 |
# Start the application
|
| 59 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 5 |
# Set non-interactive mode for apt
|
| 6 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 7 |
|
| 8 |
+
# The base image already has a user with UID 1000 (likely 'pwuser' or 'ubuntu').
|
| 9 |
+
# We will check or just use it ensuring permissions.
|
| 10 |
+
# HF Spaces expects the app to run as user 1000.
|
| 11 |
+
|
| 12 |
|
| 13 |
|
| 14 |
# Set working directory
|
|
|
|
| 38 |
# Copy application code
|
| 39 |
COPY . .
|
| 40 |
|
| 41 |
+
# Adjust permissions for the user (using UID 1000)
|
| 42 |
+
RUN chown -R 1000:1000 /app
|
| 43 |
|
| 44 |
# Create necessary directories for the app (data, cache) and ensure permission
|
| 45 |
# HF Spaces likes /data for persistent storage if configured, but we map it in code.
|
| 46 |
# Here we just make sure our app directories are writable
|
| 47 |
RUN mkdir -p /app/data /app/memory /tmp/cache /tmp/hf && \
|
| 48 |
+
chown -R 1000:1000 /app/data /app/memory /tmp/cache /tmp/hf
|
| 49 |
|
| 50 |
# Switch to the non-root user
|
| 51 |
+
USER 1000
|
| 52 |
|
| 53 |
# Expose the port
|
| 54 |
EXPOSE 7860
|
| 55 |
|
| 56 |
# Define environment variables
|
| 57 |
ENV PYTHONUNBUFFERED=1
|
| 58 |
+
ENV HOME=/app
|
| 59 |
|
| 60 |
# Start the application
|
| 61 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|