CausalBox / Dockerfile
ShutterStack's picture
Update Dockerfile
847f2c7 verified
Raw
History Blame
1.32 kB
# 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"]