Aman045 Claude Opus 4.5 commited on
Commit
cf89d85
·
1 Parent(s): bc8d6ba

fix: simplify Dockerfile for HuggingFace Spaces

Browse files

Use python:3.11-slim base image instead of custom base.
This ensures compatibility with HuggingFace infrastructure.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Files changed (1) hide show
  1. Dockerfile +23 -54
Dockerfile CHANGED
@@ -1,68 +1,37 @@
1
- ARG BASE_IMAGE=ghcr.io/meta-pytorch/openenv-base:latest
2
- FROM ${BASE_IMAGE} AS builder
3
 
4
  WORKDIR /app
5
 
6
- # Ensure git is available (required for installing dependencies from VCS)
7
  RUN apt-get update && \
8
- apt-get install -y --no-install-recommends git && \
9
  rm -rf /var/lib/apt/lists/*
10
 
11
- # Build argument to control whether we're building standalone or in-repo
12
- ARG BUILD_MODE=in-repo
13
- ARG ENV_NAME=search_env
14
 
15
- # Copy environment code (always at root of build context)
16
- COPY . /app/env
 
 
 
 
 
 
17
 
18
- # For in-repo builds, openenv is already vendored in the build context
19
- # For standalone builds, openenv will be installed via pyproject.toml
20
- WORKDIR /app/env
21
 
22
- # Ensure uv is available (for local builds where base image lacks it)
23
- RUN if ! command -v uv >/dev/null 2>&1; then \
24
- curl -LsSf https://astral.sh/uv/install.sh | sh && \
25
- mv /root/.local/bin/uv /usr/local/bin/uv && \
26
- mv /root/.local/bin/uvx /usr/local/bin/uvx; \
27
- fi
28
-
29
- # Install dependencies using uv sync
30
- # If uv.lock exists, use it; otherwise resolve on the fly
31
- RUN --mount=type=cache,target=/root/.cache/uv \
32
- if [ -f uv.lock ]; then \
33
- uv sync --frozen --no-install-project --no-editable; \
34
- else \
35
- uv sync --no-install-project --no-editable; \
36
- fi
37
 
38
- RUN --mount=type=cache,target=/root/.cache/uv \
39
- if [ -f uv.lock ]; then \
40
- uv sync --frozen --no-editable; \
41
- else \
42
- uv sync --no-editable; \
43
- fi
44
-
45
- # Final runtime stage
46
- FROM ${BASE_IMAGE}
47
-
48
- WORKDIR /app
49
-
50
- # Copy the virtual environment from builder
51
- COPY --from=builder /app/env/.venv /app/.venv
52
-
53
- # Copy the environment code
54
- COPY --from=builder /app/env /app/env
55
-
56
- # Set PATH to use the virtual environment
57
- ENV PATH="/app/.venv/bin:$PATH"
58
-
59
- # Set PYTHONPATH so imports work correctly
60
- ENV PYTHONPATH="/app/env:$PYTHONPATH"
61
 
62
  # Health check
63
- HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
64
  CMD curl -f http://localhost:8000/health || exit 1
65
 
66
- # Run the FastAPI server
67
- # The module path is constructed to work with the /app/env structure
68
- CMD ["sh", "-c", "cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 8000"]
 
1
+ FROM python:3.11-slim
 
2
 
3
  WORKDIR /app
4
 
5
+ # Install system dependencies
6
  RUN apt-get update && \
7
+ apt-get install -y --no-install-recommends git curl && \
8
  rm -rf /var/lib/apt/lists/*
9
 
10
+ # Install uv for faster package management
11
+ RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
12
+ mv /root/.local/bin/uv /usr/local/bin/uv
13
 
14
+ # Copy project files
15
+ COPY pyproject.toml uv.lock ./
16
+ COPY searcharena ./searcharena
17
+ COPY sample ./sample
18
+ COPY data ./data
19
+ COPY server ./server
20
+ COPY models.py ./
21
+ COPY inference.py ./
22
 
23
+ # Install dependencies
24
+ RUN uv pip install --system -e .
 
25
 
26
+ # Set environment variables
27
+ ENV PYTHONPATH="/app:$PYTHONPATH"
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
+ # Expose port
30
+ EXPOSE 8000
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  # Health check
33
+ HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
34
  CMD curl -f http://localhost:8000/health || exit 1
35
 
36
+ # Run the server
37
+ CMD ["uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "8000"]