Skip to content

Commit 542b458

Browse files
committed
Add root Dockerfile for direct Space builds
1 parent 234c915 commit 542b458

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

Dockerfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
ARG BASE_IMAGE=ghcr.io/meta-pytorch/openenv-base:latest
2+
FROM ${BASE_IMAGE} AS builder
3+
4+
WORKDIR /app
5+
6+
RUN apt-get update && \
7+
apt-get install -y --no-install-recommends git && \
8+
rm -rf /var/lib/apt/lists/*
9+
10+
ARG BUILD_MODE=in-repo
11+
ARG ENV_NAME=code_review_env
12+
13+
COPY . /app/env
14+
WORKDIR /app/env
15+
16+
RUN if ! command -v uv >/dev/null 2>&1; then \
17+
curl -LsSf https://astral.sh/uv/install.sh | sh && \
18+
mv /root/.local/bin/uv /usr/local/bin/uv && \
19+
mv /root/.local/bin/uvx /usr/local/bin/uvx; \
20+
fi
21+
22+
RUN --mount=type=cache,target=/root/.cache/uv \
23+
if [ -f uv.lock ]; then \
24+
uv sync --frozen --no-install-project --no-editable; \
25+
else \
26+
uv sync --no-install-project --no-editable; \
27+
fi
28+
29+
RUN --mount=type=cache,target=/root/.cache/uv \
30+
if [ -f uv.lock ]; then \
31+
uv sync --frozen --no-editable; \
32+
else \
33+
uv sync --no-editable; \
34+
fi
35+
36+
FROM ${BASE_IMAGE}
37+
38+
WORKDIR /app
39+
40+
COPY --from=builder /app/env/.venv /app/.venv
41+
COPY --from=builder /app/env /app/env
42+
43+
ENV PATH="/app/.venv/bin:$PATH"
44+
ENV PYTHONPATH="/app/env:$PYTHONPATH"
45+
46+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
47+
CMD curl -f http://localhost:8000/health || exit 1
48+
49+
CMD ["sh", "-c", "cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 8000 --ws-ping-interval 300 --ws-ping-timeout 300"]

0 commit comments

Comments
 (0)