Spaces:
Runtime error
Runtime error
File size: 2,543 Bytes
d11b44e 7fee472 d11b44e 7fee472 d11b44e e103a30 d11b44e 7fee472 d11b44e 7fee472 d11b44e 7fee472 d11b44e 7fee472 d11b44e 7fee472 d11b44e 7fee472 d11b44e e103a30 d11b44e 7fee472 d11b44e 7fee472 | 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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | # ------------------------------------------------------------
# Effici EPC Energy Prediction API (HF Spaces / Docker safe)
# ------------------------------------------------------------
FROM python:3.12-slim
# ------------------------------------------------------------
# Python runtime hygiene
# ------------------------------------------------------------
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PORT=7860
# ------------------------------------------------------------
# Working directory
# ------------------------------------------------------------
WORKDIR /app
# ------------------------------------------------------------
# System dependencies (minimal)
# ------------------------------------------------------------
RUN apt-get update && apt-get install -y \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# ------------------------------------------------------------
# Python dependencies
# ------------------------------------------------------------
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# ------------------------------------------------------------
# Application code
# ------------------------------------------------------------
COPY app ./app
COPY src ./src
# ------------------------------------------------------------
# Credential bootstrap + server start
# ------------------------------------------------------------
RUN printf '%s\n' \
'#!/bin/sh' \
'set -e' \
'' \
'echo "🚀 Starting Effici API"' \
'' \
'# -------------------------------' \
'# GCP credentials bootstrap' \
'# -------------------------------' \
'if [ -n "$GOOGLE_APPLICATION_CREDENTIALS_JSON" ]; then' \
' echo "$GOOGLE_APPLICATION_CREDENTIALS_JSON" > /tmp/gcp-creds.json' \
' export GOOGLE_APPLICATION_CREDENTIALS=/tmp/gcp-creds.json' \
' export CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=/tmp/gcp-creds.json' \
' echo "✅ GCP credentials written to /tmp/gcp-creds.json"' \
'else' \
' echo "⚠️ GOOGLE_APPLICATION_CREDENTIALS_JSON not set"' \
'fi' \
'' \
'exec uvicorn app.main:app --host 0.0.0.0 --port ${PORT}' \
> /app/start.sh && chmod +x /app/start.sh
# ------------------------------------------------------------
# Expose API port
# ------------------------------------------------------------
EXPOSE 7860
# ------------------------------------------------------------
# Launch
# ------------------------------------------------------------
CMD ["/app/start.sh"]
|