Spaces:
Runtime error
Runtime error
# Use an official Python runtime as a parent image | |
FROM python:3.10-slim | |
# Set the working directory in the container | |
WORKDIR /app | |
# Define an argument for the data directory name (for flexibility) | |
ARG APP_TEMPLATE_DIR_NAME=app_template_storage | |
# Create the specific data directory for templates AND set permissions. | |
# The './' ensures it's relative to WORKDIR (/app). | |
# This command runs as root during the image build. | |
RUN mkdir -p ./${APP_TEMPLATE_DIR_NAME} && \ | |
chmod -R 777 ./${APP_TEMPLATE_DIR_NAME} | |
# IMPORTANT on chmod 777: | |
# This gives read, write, and execute permissions to everyone (owner, group, others). | |
# While it solves permission issues, it's very open. | |
# For production, you'd ideally find the UID your app runs as on Hugging Face | |
# and chown the directory to that user, or use more restrictive permissions (e.g., 755, 775). | |
# However, for troubleshooting and typical Hugging Face Space usage, 777 is a common fix. | |
# Copy the requirements file into the container | |
COPY requirements.txt . | |
# Install Python dependencies | |
# --no-cache-dir reduces image size | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy the rest of your application code (e.g., main.py) into the container | |
COPY . . | |
# Command to run your Python application | |
CMD ["python", "main.py"] | |