Spaces:
Sleeping
Sleeping
# Use an official Python runtime as a parent image | |
FROM python:3.9-slim | |
# Set working directory in the container | |
WORKDIR /app | |
# Set environment variables | |
ENV PYTHONDONTWRITEBYTECODE=1 \ | |
PYTHONUNBUFFERED=1 \ | |
PORT=8080 | |
# Install dependencies first for better layer caching | |
COPY requirements.txt . | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy project files | |
COPY . . | |
# Make sure templates directory exists | |
RUN mkdir -p templates | |
# Create data directory if it doesn't exist | |
RUN mkdir -p /data && chmod 777 /data | |
# Make port 8080 available to the world outside this container | |
EXPOSE 8080 | |
# Define health check | |
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \ | |
CMD curl -f http://localhost:8080/health || exit 1 | |
# Run the application when the container launches | |
CMD ["python", "app.py"] |