# Run with:
# docker compose -f examples/libero/compose.yml up --build
services:
  runtime:
    image: libero
    depends_on:
      - openpi_server
    build:
      context: ../..
      dockerfile: examples/libero/Dockerfile
    init: true
    tty: true
    network_mode: host
    privileged: true
    volumes:
      - $PWD:/app
      - ../../data:/data
      - /tmp/.X11-unix:/tmp/.X11-unix:ro
    environment:
      - CLIENT_ARGS
      - DISPLAY=$DISPLAY
      - MUJOCO_GL=${MUJOCO_GL:-egl}
      - MUJOCO_EGL_DEVICE_ID=0
      - NVIDIA_DRIVER_CAPABILITIES=all
      - PYOPENGL_PLATFORM=egl
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]

  openpi_server:
    image: openpi_server
    build:
      context: ../..
      dockerfile: scripts/docker/serve_policy.Dockerfile
    init: true
    tty: true
    network_mode: host
    volumes:
      - $PWD:/app
      - ${OPENPI_DATA_HOME:-~/.cache/openpi}:/openpi_assets
    environment:
      - SERVER_ARGS
      - OPENPI_DATA_HOME=/openpi_assets
      - IS_DOCKER=true

    # Comment out this block if not running on a machine with GPUs.
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]
