Spaces:
Sleeping
Sleeping
File size: 1,837 Bytes
05a686e | 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 | # Multi-stage build using openenv-base
# This Dockerfile is flexible and works for both:
# - In-repo environments (with local src/core)
# - Standalone environments (with openenv from pip)
ARG BASE_IMAGE=ghcr.io/meta-pytorch/openenv-base:latest
FROM ${BASE_IMAGE} AS builder
WORKDIR /app
# Build arguments for OpenEnv build pipeline compatibility.
ARG BUILD_MODE=in-repo
ARG ENV_NAME=coenv
# Copy environment code from the build context root.
COPY . /app/env
WORKDIR /app/env
# Install dependencies with uv.
# Use pyproject/uv.lock when present, otherwise fall back to requirements.txt
# because submission validators often build from server/ as context.
RUN --mount=type=cache,target=/root/.cache/uv \
if [ -f pyproject.toml ]; then \
if [ -f uv.lock ]; then \
uv sync --frozen --no-install-project --no-editable; \
else \
uv sync --no-install-project --no-editable; \
fi; \
elif [ -f requirements.txt ]; then \
uv venv .venv; \
uv pip install --python .venv/bin/python -r requirements.txt; \
else \
echo "No pyproject.toml or requirements.txt found in build context" >&2; \
exit 2; \
fi
RUN --mount=type=cache,target=/root/.cache/uv \
if [ -f pyproject.toml ]; then \
if [ -f uv.lock ]; then \
uv sync --frozen --no-editable; \
else \
uv sync --no-editable; \
fi; \
else \
true; \
fi
FROM ${BASE_IMAGE}
WORKDIR /app
# Copy runtime virtualenv and environment code from builder.
COPY --from=builder /app/env/.venv /app/.venv
COPY --from=builder /app/env /app/env
ENV PATH="/app/.venv/bin:$PATH"
ENV PYTHONPATH="/app/env:$PYTHONPATH"
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
ENV ENABLE_WEB_INTERFACE=true
CMD ["sh", "-c", "cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 8000"] |