Spaces:
Sleeping
Sleeping
File size: 1,322 Bytes
b4cdbd5 ae34495 9c7192b 85fd14e 9c7192b b4cdbd5 85fd14e b4cdbd5 847f2c7 85fd14e 9c7192b 847f2c7 b4cdbd5 847f2c7 ae34495 847f2c7 ae34495 b4cdbd5 b8611e0 9c7192b ae34495 847f2c7 b4cdbd5 85fd14e b4cdbd5 85fd14e b4cdbd5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | # Use a slim Python base image for efficiency
FROM python:3.10-slim-buster
# Set the working directory inside the container
WORKDIR /app
# Copy the requirements.txt file first to leverage Docker's build cache.
COPY requirements.txt .
# Install Python dependencies (ensure gunicorn is listed here)
RUN pip install --no-cache-dir -r requirements.txt
# Install Nginx and other necessary packages
RUN apt-get update && apt-get install -y nginx && \
rm -rf /var/lib/apt/lists/*
# Create and set permissions for all Nginx cache/temp directories needed.
# Nginx typically runs as the 'www-data' user, which needs write access.
RUN mkdir -p /tmp/nginx_cache/client_body && \
mkdir -p /tmp/nginx_cache/proxy && \
chown -R www-data:www-data /tmp/nginx_cache && \
chmod -R 755 /tmp/nginx_cache
# Copy the entire project directory into the container's /app directory.
COPY . .
# Replace the default Nginx configuration with your custom one.
# This nginx.conf MUST be updated as shown in Step 3 to use the new paths and logging.
COPY nginx.conf /etc/nginx/nginx.conf
# Grant execution permissions to the start.sh script
RUN chmod +x start.sh
# Expose the port Nginx is configured to listen on (7860 for Hugging Face Spaces)
EXPOSE 7860
# Define the command to run when the container starts.
CMD ["./start.sh"] |