-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
79 lines (61 loc) · 2.87 KB
/
Copy pathDockerfile
File metadata and controls
79 lines (61 loc) · 2.87 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
# OpenCastor — The Universal Runtime for Embodied AI
# Multi-stage build for x86_64 and arm64
# For GPU acceleration (NVIDIA Jetson/Desktop), swap base image accordingly.
# ── Stage 1: Builder ─────────────────────────────────────────────
FROM python:3.12-slim-bookworm AS builder
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libgl1-mesa-glx \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
# Install deps first (layer caching)
COPY pyproject.toml requirements.txt ./
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
# Copy source and install package
COPY . .
RUN pip install --no-cache-dir --prefix=/install .
# ── Stage 2: Runtime ─────────────────────────────────────────────
FROM python:3.12-slim-bookworm
LABEL org.opencontainers.image.title="OpenCastor"
LABEL org.opencontainers.image.description="The Universal Runtime for Embodied AI"
LABEL org.opencontainers.image.source="https://github.com/craigm26/OpenCastor"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.vendor="OpenCastor Contributors"
# Runtime system deps only (no build-essential)
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1-mesa-glx \
libglib2.0-0 \
usbutils \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd --system castor && \
useradd --system --gid castor --create-home --home-dir /home/castor --shell /bin/bash castor
WORKDIR /app
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV HOME=/home/castor
ENV OPENCASTOR_DIR=/home/castor/.opencastor
ENV CASTOR_CONFIG=/app/config/robot.rcan.yaml
# Copy installed packages from builder
COPY --from=builder /install /usr/local
# Copy source (for streamlit dashboard, configs, etc.)
COPY --from=builder /build/castor ./castor
COPY --from=builder /build/pyproject.toml ./
# Create config mount point and writable home dirs
RUN mkdir -p /app/config && chown castor:castor /app/config && \
mkdir -p /home/castor/.opencastor && chown -R castor:castor /home/castor
# Copy entrypoint script (needs root for chmod)
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Switch to non-root user
USER castor
# Expose API + Dashboard ports
EXPOSE 8000 8501
# Health check — hit the gateway's /health endpoint
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health')" || exit 1
# Default: run with config from volume mount
# entrypoint.sh auto-generates robot.rcan.yaml on first run if missing
ENTRYPOINT ["/entrypoint.sh"]
CMD ["castor", "run", "--config", "/app/config/robot.rcan.yaml"]