ecommerce_bot / Dockerfile
thisisgini's picture
Update Dockerfile
b53e040 verified
Raw History Blame
1.94 kB
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
ARG BASE_IMAGE=ghcr.io/meta-pytorch/openenv-base:latest
FROM ${BASE_IMAGE} AS builder
WORKDIR /app
# Ensure git is available
RUN apt-get update && \
apt-get install -y --no-install-recommends git && \
rm -rf /var/lib/apt/lists/*
ARG BUILD_MODE=in-repo
ARG ENV_NAME=ecommerce_bot
# Copy environment code to the builder
COPY . /app/env
WORKDIR /app/env
# Ensure uv is available for dependency management
RUN if ! command -v uv >/dev/null 2>&1; then \
curl -LsSf https://astral.sh/uv/install.sh | sh && \
mv /root/.local/bin/uv /usr/local/bin/uv && \
mv /root/.local/bin/uvx /usr/local/bin/uvx; \
fi
# Install dependencies using uv
RUN --mount=type=cache,target=/root/.cache/uv \
if [ -f uv.lock ]; then \
uv sync --frozen --no-install-project --no-editable; \
else \
uv sync --no-install-project --no-editable; \
fi
RUN --mount=type=cache,target=/root/.cache/uv \
if [ -f uv.lock ]; then \
uv sync --frozen --no-editable; \
else \
uv sync --no-editable; \
fi
# --- FINAL RUNTIME STAGE ---
FROM ${BASE_IMAGE}
WORKDIR /app
# Copy the virtual environment and code from builder
COPY --from=builder /app/env/.venv /app/.venv
COPY --from=builder /app/env /app/env
# Set PATH and PYTHONPATH for the app to find your modules
ENV PATH="/app/.venv/bin:$PATH"
ENV PYTHONPATH="/app/env:$PYTHONPATH"
# Inform Hugging Face about the correct port
EXPOSE 7860
# Updated Health check for Port 7860
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
# THE FINAL FIX:
# 1. We use 'app:app' because your files are in the root (no 'server' folder).
# 2. We force '--port 7860' so the Hugging Face Load Balancer can find you.
CMD ["sh", "-c", "cd /app/env && uvicorn app:app --host 0.0.0.0 --port 7860"]