Spaces:
Runtime error
Runtime error
File size: 2,115 Bytes
8957d2b f74625a 8957d2b f74625a ac73c0d f74625a ac73c0d e4b5600 af222d3 e4b5600 ac73c0d f74625a 8957d2b 51ffe8b 8957d2b 51ffe8b 037d483 8957d2b e4b5600 8957d2b f74625a 8957d2b f74625a 8957d2b f74625a 8957d2b f74625a e4b5600 f74625a 8957d2b f74625a af222d3 f74625a 8957d2b f74625a 8957d2b f74625a 8957d2b f74625a | 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 | # --- STAGE 1: SYSTEM SETUP ---
FROM ros:humble-ros-base
USER root
ENV PATH="/root/.bun/bin:${PATH}"
ENV DEBIAN_FRONTEND=noninteractive
# Install core tools and ROS 2 Navigation stack
RUN apt-get update && apt-get install -y \
curl \
gnupg \
python3-pip \
unzip \
ros-humble-navigation2 \
ros-humble-nav2-bringup \
ros-humble-nav2-controller \
ros-humble-nav2-planner \
ros-humble-nav2-lifecycle-manager \
python3-colcon-common-extensions \
&& curl -fsSL https://bun.sh/install | bash \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# --- STAGE 2: DEPENDENCY CACHING ---
# Copy ONLY the package configuration to cache the install layer
COPY package.json bun.lock ./
# Copy whatever workspaces exist (resilient to pruning)
COPY apps/ ./apps/
COPY packages/ ./packages/
# Filter out the source code but keep package.jsons and lockfiles for caching
# This maximizes caching while being monorepo friendly
RUN find . -maxdepth 4 -type f -not -name 'package.json' -not -name 'bun.lock' -not -name 'Dockerfile' -delete || true
# Use BUN for ultra-fast multi-workspace installation
# We source ROS setup to ensure rclnodejs builds against the installed ROS libraries
RUN /bin/bash -c "source /opt/ros/humble/setup.bash && bun install"
# --- STAGE 3: BUILD ---
# Now copy the rest of the source
COPY . .
# Build Shared Packages using Bun
WORKDIR /app/packages/shared-types
RUN bun run build
# Prepare Backend (Fix port for HF Spaces)
WORKDIR /app/apps/backend
ENV PORT=7860
# Build ROS 2 Workspaces
WORKDIR /app/robotics/ros2_ws
RUN /bin/bash -c "source /opt/ros/humble/setup.bash && colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-select simulation_manager amr_navigation"
# --- STAGE 4: RUNTIME ---
WORKDIR /app
COPY hf_entrypoint.sh .
RUN chmod +x hf_entrypoint.sh
# Expose HF Spaces default port
EXPOSE 7860
# Healthcheck to help HF monitor the space
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/api/robots || exit 1
CMD ["./hf_entrypoint.sh"]
|