Update Dockerfile
Browse files- Dockerfile +16 -13
Dockerfile
CHANGED
|
@@ -2,26 +2,29 @@ FROM python:3.9-slim
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
# Copy application code
|
| 6 |
COPY ./app.py /app/
|
| 7 |
COPY ./templates/ /app/templates/
|
| 8 |
-
#
|
|
|
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
#
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# Install dependencies
|
| 15 |
-
|
| 16 |
-
# aiofiles is for async file operations
|
| 17 |
-
RUN pip install --no-cache-dir fastapi "uvicorn[standard]" aiofiles Jinja2 python-multipart
|
| 18 |
|
| 19 |
EXPOSE 7860
|
| 20 |
|
| 21 |
-
# Healthcheck (optional but good practice)
|
| 22 |
-
# HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
| 23 |
-
# CMD curl -f http://localhost:7860/ || exit 1
|
| 24 |
-
# Note: curl might not be in python:slim. You might need to install it or use a Python-based healthcheck.
|
| 25 |
-
# For simplicity, I'm omitting a complex healthcheck here.
|
| 26 |
-
|
| 27 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
# Create directories that the application might need to write to or expect to exist.
|
| 6 |
+
# These are created by root during the build.
|
| 7 |
+
RUN mkdir -p /app/templates \
|
| 8 |
+
/app/static \
|
| 9 |
+
/app/uploaded_files
|
| 10 |
+
|
| 11 |
# Copy application code
|
| 12 |
COPY ./app.py /app/
|
| 13 |
COPY ./templates/ /app/templates/
|
| 14 |
+
# If you had local static files, you'd copy them here:
|
| 15 |
+
# COPY ./static/ /app/static/
|
| 16 |
|
| 17 |
+
# Grant write permissions to the 'uploaded_files' directory for the user running the app.
|
| 18 |
+
# Hugging Face Spaces (and many other container platforms) often run containers
|
| 19 |
+
# as a non-root user (e.g., UID 1000).
|
| 20 |
+
# We give ownership to user 1000 and group 1000.
|
| 21 |
+
# You could also use `chmod -R 777 /app/uploaded_files` but chown is more specific.
|
| 22 |
+
RUN chown -R 1000:1000 /app/uploaded_files \
|
| 23 |
+
&& chmod -R u+w /app/uploaded_files # Ensure the owner (user 1000) has write permissions
|
| 24 |
|
| 25 |
# Install dependencies
|
| 26 |
+
RUN pip install --no-cache-dir fastapi "uvicorn[standard]" aiofiles Jinja2
|
|
|
|
|
|
|
| 27 |
|
| 28 |
EXPOSE 7860
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|