Spaces:
Sleeping
Sleeping
File size: 1,538 Bytes
edc02c6 | 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 39 40 41 42 43 44 45 46 47 48 | FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application files
COPY app.py .
COPY ocr_invoice.py .
COPY cost_tracker.py .
COPY static/ ./static/
# Create necessary directories with proper permissions
RUN mkdir -p /tmp/uploads && chmod 777 /tmp/uploads
RUN mkdir -p /app/credentials && chmod 777 /app/credentials
# Expose port
EXPOSE 7860
# Set environment variables
ENV PYTHONUNBUFFERED=1
# Create startup script that handles credentials
RUN echo '#!/bin/bash\n\
if [ ! -z "$GOOGLE_APPLICATION_CREDENTIALS_JSON" ]; then\n\
echo "$GOOGLE_APPLICATION_CREDENTIALS_JSON" > /app/credentials/credentials.json\n\
export GOOGLE_APPLICATION_CREDENTIALS=/app/credentials/credentials.json\n\
echo "✓ Created credentials file from environment variable"\n\
elif [ ! -z "$GOOGLE_APPLICATION_CREDENTIALS" ]; then\n\
if [ ! -f "$GOOGLE_APPLICATION_CREDENTIALS" ]; then\n\
echo "$GOOGLE_APPLICATION_CREDENTIALS" > /app/credentials/credentials.json\n\
export GOOGLE_APPLICATION_CREDENTIALS=/app/credentials/credentials.json\n\
echo "✓ Created credentials file from GOOGLE_APPLICATION_CREDENTIALS"\n\
fi\n\
fi\n\
exec uvicorn app:app --host 0.0.0.0 --port 7860' > /app/start.sh && chmod +x /app/start.sh
# Run the application via startup script
CMD ["/bin/bash", "/app/start.sh"]
|