Switch Docker to Alpine and build kge.

Update build environment to Alpine, enable GUI support, and refine developer guide

- Migrated Dockerfile base image from Ubuntu 22.04 to Alpine 3.19 for a smaller and faster container.
- Added dependencies for GUI support (SDL2, OpenGL/Mesa, Freetype, etc.) and updated CMake options.
- Enhanced `DEVELOPER_GUIDE.md` with new instructions for GUI builds, updated dependencies, and simplified custom build workflows.
- Addressed Alpine-specific ncurses library path issues in CMake configuration.
This commit is contained in:
2026-02-17 16:53:12 -08:00
parent 422b27b1ba
commit b0b5b55dce
3 changed files with 35 additions and 23 deletions

View File

@@ -68,15 +68,17 @@ if (BUILD_GUI)
endif ()
# NCurses for terminal mode
set(CURSES_NEED_NCURSES)
set(CURSES_NEED_WIDE)
set(CURSES_NEED_NCURSES TRUE)
set(CURSES_NEED_WIDE TRUE)
find_package(Curses REQUIRED)
include_directories(${CURSES_INCLUDE_DIR})
# On Linux, explicitly link ncursesw for wide-character support
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_library(NCURSESW_LIBRARY NAMES ncursesw REQUIRED)
set(CURSES_LIBRARIES ${NCURSESW_LIBRARY})
# On Alpine Linux, CMake's FindCurses looks in wrong paths
# Manually find the correct ncurses library
if (EXISTS "/etc/alpine-release")
find_library(NCURSESW_LIB NAMES ncursesw PATHS /usr/lib /lib REQUIRED)
set(CURSES_LIBRARIES ${NCURSESW_LIB})
message(STATUS "Alpine Linux detected, using ncurses at: ${NCURSESW_LIB}")
endif ()
set(SYNTAX_SOURCES

View File

@@ -1,20 +1,23 @@
# Minimal Dockerfile for building and testing kte on Linux
# This container provides a build environment with all dependencies.
# Mount the source tree at /kte when running the container.
FROM ubuntu:22.04
# Avoid interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
FROM alpine:3.19
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
RUN apk add --no-cache \
g++ \
cmake \
libncursesw5-dev \
&& rm -rf /var/lib/apt/lists/*
make \
ncurses-dev \
sdl2-dev \
mesa-dev \
freetype-dev \
libx11-dev \
libxext-dev
# Set working directory where source will be mounted
WORKDIR /kte
# Default command: build and run tests
CMD ["sh", "-c", "cmake -B build -DBUILD_GUI=OFF -DBUILD_TESTS=ON && cmake --build build --target kte && cmake --build build --target kte_tests && ./build/kte_tests"]
# Add DirectFB include path for SDL2 compatibility on Alpine
CMD ["sh", "-c", "cmake -B build -DBUILD_GUI=ON -DBUILD_TESTS=ON -DCMAKE_CXX_FLAGS='-I/usr/include/directfb' && cmake --build build --target kte && cmake --build build --target kge && cmake --build build --target kte_tests && ./build/kte_tests"]

View File

@@ -309,7 +309,7 @@ This is particularly useful for:
- **macOS/Windows developers** testing Linux compatibility
- **CI/CD pipelines** ensuring cross-platform builds
- **Reproducible builds** with a known Ubuntu 22.04 environment
- **Reproducible builds** with a known Alpine Linux 3.19 environment
#### Prerequisites
@@ -328,8 +328,9 @@ podman machine start
#### Building the Docker Image
The Dockerfile only installs build dependencies (g++ 11.4.0, CMake 3.22,
libncursesw5-dev). It does not copy or build the source code.
The Dockerfile installs all build dependencies including GUI support (
g++ 13.2.1, CMake 3.27.8, ncurses-dev, SDL2, OpenGL/Mesa, Freetype). It
does not copy or build the source code.
From the project root:
@@ -352,8 +353,9 @@ docker run --rm -v "$(pwd):/kte" kte-linux
# Expected output: "98 tests passed, 0 failed"
```
The default command builds kte in terminal-only mode (`-DBUILD_GUI=OFF`)
and runs the full test suite.
The default command builds both `kte` (terminal) and `kge` (GUI)
executables with full GUI support (`-DBUILD_GUI=ON`) and runs the
complete test suite.
#### Custom Build Commands
@@ -362,13 +364,18 @@ and runs the full test suite.
docker run --rm -it -v "$(pwd):/kte" kte-linux /bin/bash
# Then inside the container:
cmake -B build -DBUILD_GUI=OFF -DBUILD_TESTS=ON
cmake --build build --target kte
cmake -B build -DBUILD_GUI=ON -DBUILD_TESTS=ON
cmake --build build --target kte # Terminal version
cmake --build build --target kge # GUI version
cmake --build build --target kte_tests
./build/kte_tests
# Or run kte directly
./build/kte --help
# Terminal-only build (smaller, faster)
cmake -B build -DBUILD_GUI=OFF -DBUILD_TESTS=ON
cmake --build build --target kte
```
#### Running kte Interactively
@@ -408,7 +415,7 @@ sudo usermod -aG docker $USER
```
**Build fails with ncurses errors**:
The Dockerfile explicitly installs `libncursesw5-dev` (wide-character
The Dockerfile explicitly installs `ncurses-dev` (wide-character
ncurses). If you modify the Dockerfile, ensure this dependency remains.
**"No such file or directory" errors**: