Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +8 -2
Dockerfile
CHANGED
@@ -25,7 +25,8 @@ RUN apt-get update && \
|
|
25 |
WORKDIR /app
|
26 |
|
27 |
# Create a non-root user and group for better security
|
28 |
-
|
|
|
29 |
|
30 |
# Create necessary application directories before copying and set ownership
|
31 |
# Ensures the user 'appuser' can write to generated_images
|
@@ -33,6 +34,7 @@ RUN mkdir -p /app/templates /app/generated_images && \
|
|
33 |
chown -R appuser:appuser /app
|
34 |
|
35 |
# Copy the requirements file first for layer caching
|
|
|
36 |
COPY --chown=appuser:appuser requirements.txt .
|
37 |
|
38 |
# Install Python dependencies specified in requirements.txt
|
@@ -41,8 +43,12 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
41 |
# Copy the rest of the application files into the container
|
42 |
# Ensure 'app.py', 'arial.ttf', and the 'templates' directory exist in your repo root
|
43 |
COPY --chown=appuser:appuser app.py .
|
44 |
-
|
|
|
|
|
45 |
COPY --chown=appuser:appuser arial.ttf .
|
|
|
|
|
46 |
# Copy the entire templates directory
|
47 |
COPY --chown=appuser:appuser templates ./templates
|
48 |
|
|
|
25 |
WORKDIR /app
|
26 |
|
27 |
# Create a non-root user and group for better security
|
28 |
+
# Using user ID 1000 as is common in HF Spaces
|
29 |
+
RUN groupadd -g 1000 appuser && useradd --no-log-init -u 1000 -g appuser appuser
|
30 |
|
31 |
# Create necessary application directories before copying and set ownership
|
32 |
# Ensures the user 'appuser' can write to generated_images
|
|
|
34 |
chown -R appuser:appuser /app
|
35 |
|
36 |
# Copy the requirements file first for layer caching
|
37 |
+
# Ensure ownership is set correctly during copy
|
38 |
COPY --chown=appuser:appuser requirements.txt .
|
39 |
|
40 |
# Install Python dependencies specified in requirements.txt
|
|
|
43 |
# Copy the rest of the application files into the container
|
44 |
# Ensure 'app.py', 'arial.ttf', and the 'templates' directory exist in your repo root
|
45 |
COPY --chown=appuser:appuser app.py .
|
46 |
+
|
47 |
+
# ---- IMPORTANT ----
|
48 |
+
# The following line requires 'arial.ttf' to be present in the root of your repository
|
49 |
COPY --chown=appuser:appuser arial.ttf .
|
50 |
+
# ---- IMPORTANT ----
|
51 |
+
|
52 |
# Copy the entire templates directory
|
53 |
COPY --chown=appuser:appuser templates ./templates
|
54 |
|