podcraft_web_app / Dockerfile.spaces
Nagesh Muralidhar
Initial commit of PodCraft application
0d27572
raw
history blame
1.51 kB
FROM python:3.9-slim
WORKDIR /app
# Install system dependencies including ffmpeg
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ffmpeg \
build-essential \
curl \
gnupg \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first to leverage Docker cache
COPY backend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy backend code
COPY backend/app/ /app/app/
# Ensure static directory exists
RUN mkdir -p /app/static
# Copy frontend build to static directory if available
COPY frontend/podcraft/build/ /app/static/
# Install additional packages needed for serving frontend
RUN pip install --no-cache-dir python-multipart
# Create directory for temporary files
RUN mkdir -p /app/temp_audio
# Set environment variables
ENV PYTHONPATH=/app
# Using Secrets from HuggingFace Spaces
# MongoDB_URL is hardcoded to the Atlas URL in this case
ENV MONGODB_URL="mongodb+srv://NageshBM:Nash166^@podcraft.ozqmc.mongodb.net/?retryWrites=true&w=majority&appName=Podcraft"
# Copy the placeholder index.html if the app/static directory is empty
RUN if [ -z "$(ls -A /app/static 2>/dev/null)" ]; then \
echo "<html><body><h1>PodCraft API</h1><p>Frontend not available. Please build the frontend before running.</p></body></html>" > /app/static/index.html; \
fi
# Expose the port the app runs on
EXPOSE 7860
# HuggingFace Spaces expects the app to run on port 7860
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]