mcdosbox-x/Dockerfile
Ryan Malloy 1d826254ba Add QMP control tools, clipboard support, and peripheral configuration
New tools and modules:
- control.py: pause, resume, reset, savestate, loadstate, memdump, query_status
- resources.py: Live screen capture, screenshot management resources
- clipboard_copy/clipboard_paste via DOSBox-X hotkeys (Ctrl+F5/F6)
- screen_text/screen_graphics for text buffer and VGA memory access

Configuration improvements:
- Dynamic QMP/GDB port handling (stored in session state from launch())
- Joystick config: joysticktype, timed options
- Parallel port config: parallel1, parallel2 settings
- Added -hostrun flag for host clipboard integration

Performance and UX:
- Reduced keyboard_send delay from 50ms to 10ms default
- Refactored server.py to use Tool.from_function() pattern
- Screenshot tool now returns MCP resource URIs only

MCP Resources:
- dosbox://screen - live screen capture (no tool call needed)
- dosbox://screenshots - list available screenshots
- dosbox://screenshots/{filename} - get specific screenshot
- dosbox://screenshots/latest - get most recent screenshot
2026-01-27 23:54:12 -07:00

146 lines
4.0 KiB
Docker

# DOSBox-X with GDB stub support
# Multi-stage build for minimal final image
# =============================================================================
# Stage 1: Build DOSBox-X with GDB support
# =============================================================================
FROM debian:bookworm-slim AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
build-essential \
automake \
autoconf \
libtool \
pkg-config \
libsdl2-dev \
libsdl2-net-dev \
libsdl2-image-dev \
libpng-dev \
libpcap-dev \
libslirp-dev \
libfluidsynth-dev \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libswscale-dev \
libncurses-dev \
nasm \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Clone DOSBox-X with remote debugging support (GDB server + QMP)
# This fork adds --enable-remotedebug which compiles in gdbserver.cpp and qmp.cpp
# Using rsp2k fork with GDB breakpoint address fix (uses physical addresses correctly)
# See: https://github.com/joncampbell123/dosbox-x/issues/752
#
# IMPORTANT: Clone and build MUST be in the same RUN to prevent BuildKit from
# caching the build step separately from the git clone step.
ARG CACHE_BUST=2026-01-27-v19-add-ncurses-for-debug
WORKDIR /build
# Configure and build with GDB server support
# --enable-remotedebug: Enables C_REMOTEDEBUG flag for GDB/QMP servers
# --enable-debug: Enables internal debugger (Alt+Pause)
RUN echo "Cache bust: ${CACHE_BUST}" && \
git clone --branch remotedebug --depth 1 https://github.com/rsp2k/dosbox-x-remotedebug.git dosbox-x && \
cd dosbox-x && \
./autogen.sh && \
./configure \
--prefix=/opt/dosbox-x \
--enable-remotedebug \
--enable-debug \
--enable-sdl2 \
--disable-printer && \
make -j$(nproc) && \
make install
# =============================================================================
# Stage 2: Runtime image
# =============================================================================
FROM debian:bookworm-slim
# Install runtime dependencies only
RUN apt-get update && apt-get install -y --no-install-recommends \
libsdl2-2.0-0 \
libsdl2-net-2.0-0 \
libsdl2-image-2.0-0 \
libpng16-16 \
libpcap0.8 \
libslirp0 \
libfluidsynth3 \
libavcodec59 \
libavformat59 \
libavutil57 \
libswscale6 \
libgl1 \
libx11-6 \
libncurses6 \
libxkbcommon0 \
libxrandr2 \
libxi6 \
netcat-openbsd \
&& rm -rf /var/lib/apt/lists/*
# Copy DOSBox-X from builder
COPY --from=builder /opt/dosbox-x /opt/dosbox-x
# Create symlink in PATH
RUN ln -s /opt/dosbox-x/bin/dosbox-x /usr/local/bin/dosbox-x
# Create directories for config and DOS files
RUN mkdir -p /config /dos
# Default configuration for DOSBox-X
# Note: --enable-remotedebug compiles in the code, but these runtime settings enable the servers
RUN cat > /config/dosbox.conf << 'EOF'
[log]
logfile = /tmp/dosbox.log
[sdl]
fullscreen=false
windowresolution=800x600
output=opengl
[cpu]
# CRITICAL: Must use "normal" core for GDB breakpoints to work!
# Dynamic cores (auto/dynamic/dynamic_x86) bypass DEBUG_Breakpoint()
core=normal
cputype=auto
cycles=auto
[dosbox]
memsize=16
# Enable GDB remote debug server
gdbserver = true
gdbserver port = 1234
# Enable QMP (QEMU Machine Protocol) server for control
qmpserver = true
qmpserver port = 4444
[serial]
serial1=disabled
serial2=disabled
[autoexec]
# Mount /dos as C:
MOUNT C /dos
C:
EOF
# Expose ports:
# - 1234: GDB server (standard GDB remote protocol)
# - 4444: QMP server (QEMU Machine Protocol for control)
EXPOSE 1234 4444
# Set working directory
WORKDIR /dos
# Environment for X11 forwarding
ENV DISPLAY=:0
# Entry point
# Note: GDB/QMP servers are enabled via config file [dosbox] section
ENTRYPOINT ["dosbox-x", "-conf", "/config/dosbox.conf"]
CMD []