epc_only_data_model / Dockerfile
zcemg08's picture
fix docker container port to 7860
e103a30
# ------------------------------------------------------------
# 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"]