# Stage 1: Build the Vite/React frontend FROM node:22-alpine AS frontend-builder WORKDIR /build COPY frontend/package.json ./ RUN npm install COPY frontend/ ./ # Passed in via docker-compose build args so the URL is baked into the bundle. # e.g. VITE_WEBRTC_WS_URL=ws://raspberrypi.local:8443 ARG VITE_WEBRTC_WS_URL ENV VITE_WEBRTC_WS_URL=${VITE_WEBRTC_WS_URL} RUN npm run build # Stage 2: FastAPI + ROS 2 runtime FROM ros:kilted-ros-core ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends \ python3-venv \ && rm -rf /var/lib/apt/lists/* COPY backend/requirements.txt /tmp/requirements.txt RUN python3 -m venv /app/venv && \ /app/venv/bin/pip install --no-cache-dir -r /tmp/requirements.txt COPY --from=frontend-builder /build/dist /app/static COPY backend/ /app/ WORKDIR /app EXPOSE 8080 CMD ["/bin/bash", "-c", "source /opt/ros/$ROS_DISTRO/setup.bash && /app/venv/bin/python3 main.py"]