# 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 \ patch \ 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-28-v23-git-only 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) # Note: Removed --disable-printer to enable parallel port support # All patches are now committed to the rsp2k fork (joystick, parport, logging) 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 && \ 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 []