CoolFace
Apppublic

1Jayanth/devops-autoheal

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
Dockerfile79 linesDownload Raw Back to root
1# Copyright (c) Meta Platforms, Inc. and affiliates.2# All rights reserved.3#4# This source code is licensed under the BSD-style license found in the5# LICENSE file in the root directory of this source tree.6 7# Multi-stage build using openenv-base8# This Dockerfile is flexible and works for both:9# - In-repo environments (with local OpenEnv sources)10# - Standalone environments (with openenv from PyPI/Git)11# The build script (openenv build) handles context detection and sets appropriate build args.12 13ARG BASE_IMAGE=ghcr.io/meta-pytorch/openenv-base:latest14FROM ${BASE_IMAGE} AS builder15 16WORKDIR /app17 18# Ensure git is available (required for installing dependencies from VCS)19# Install dependencies20RUN apt-get update && \21    apt-get install -y --no-install-recommends git curl && \22    rm -rf /var/lib/apt/lists/*23 24# Build arguments25ARG BUILD_MODE=in-repo26ARG ENV_NAME=my_env27 28# Copy environment code29COPY . /app/env30WORKDIR /app/env31 32# Install uv if missing33RUN if ! command -v uv >/dev/null 2>&1; then \34        curl -LsSf https://astral.sh/uv/install.sh | sh && \35        mv /root/.local/bin/uv /usr/local/bin/uv; \36    fi37 38# Use uv to sync dependencies39RUN --mount=type=cache,target=/root/.cache/uv \40    uv sync --no-install-project --no-editable41 42# Final stage43FROM ${BASE_IMAGE}44 45# Install runtime dependencies (Curl for health check)46USER root47RUN apt-get update && \48    apt-get install -y --no-install-recommends curl && \49    rm -rf /var/lib/apt/lists/*50 51# Add non-root user (Standard for HF Spaces)52RUN useradd -m -u 1000 appuser53 54WORKDIR /app55 56# Copy artifacts from builder57COPY --from=builder /app/env/.venv /app/.venv58COPY --from=builder /app/env /app/env59RUN chmod +x /app/env/server/start.sh60 61# Environment settings62ENV PATH="/app/.venv/bin:$PATH"63ENV PYTHONPATH="/app/env:$PYTHONPATH"64ENV PORT=786065 66# Switch to non-root user67USER appuser68 69# Expose the port70EXPOSE 786071 72# Health check (FastAPI on exposed port)73HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \74    CMD curl -f http://localhost:7860/health || exit 175 76# Start FastAPI server77ENV ENABLE_WEB_INTERFACE=true78CMD ["/app/env/server/start.sh"]79