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:
@@ -68,15 +68,17 @@ if (BUILD_GUI)
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# NCurses for terminal mode
|
# NCurses for terminal mode
|
||||||
set(CURSES_NEED_NCURSES)
|
set(CURSES_NEED_NCURSES TRUE)
|
||||||
set(CURSES_NEED_WIDE)
|
set(CURSES_NEED_WIDE TRUE)
|
||||||
find_package(Curses REQUIRED)
|
find_package(Curses REQUIRED)
|
||||||
include_directories(${CURSES_INCLUDE_DIR})
|
include_directories(${CURSES_INCLUDE_DIR})
|
||||||
|
|
||||||
# On Linux, explicitly link ncursesw for wide-character support
|
# On Alpine Linux, CMake's FindCurses looks in wrong paths
|
||||||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
# Manually find the correct ncurses library
|
||||||
find_library(NCURSESW_LIBRARY NAMES ncursesw REQUIRED)
|
if (EXISTS "/etc/alpine-release")
|
||||||
set(CURSES_LIBRARIES ${NCURSESW_LIBRARY})
|
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 ()
|
endif ()
|
||||||
|
|
||||||
set(SYNTAX_SOURCES
|
set(SYNTAX_SOURCES
|
||||||
|
|||||||
21
Dockerfile
21
Dockerfile
@@ -1,20 +1,23 @@
|
|||||||
# Minimal Dockerfile for building and testing kte on Linux
|
# Minimal Dockerfile for building and testing kte on Linux
|
||||||
# This container provides a build environment with all dependencies.
|
# This container provides a build environment with all dependencies.
|
||||||
# Mount the source tree at /kte when running the container.
|
# Mount the source tree at /kte when running the container.
|
||||||
FROM ubuntu:22.04
|
FROM alpine:3.19
|
||||||
|
|
||||||
# Avoid interactive prompts during package installation
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
|
||||||
|
|
||||||
# Install build dependencies
|
# Install build dependencies
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apk add --no-cache \
|
||||||
build-essential \
|
g++ \
|
||||||
cmake \
|
cmake \
|
||||||
libncursesw5-dev \
|
make \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
ncurses-dev \
|
||||||
|
sdl2-dev \
|
||||||
|
mesa-dev \
|
||||||
|
freetype-dev \
|
||||||
|
libx11-dev \
|
||||||
|
libxext-dev
|
||||||
|
|
||||||
# Set working directory where source will be mounted
|
# Set working directory where source will be mounted
|
||||||
WORKDIR /kte
|
WORKDIR /kte
|
||||||
|
|
||||||
# Default command: build and run tests
|
# 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"]
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ This is particularly useful for:
|
|||||||
|
|
||||||
- **macOS/Windows developers** testing Linux compatibility
|
- **macOS/Windows developers** testing Linux compatibility
|
||||||
- **CI/CD pipelines** ensuring cross-platform builds
|
- **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
|
#### Prerequisites
|
||||||
|
|
||||||
@@ -328,8 +328,9 @@ podman machine start
|
|||||||
|
|
||||||
#### Building the Docker Image
|
#### Building the Docker Image
|
||||||
|
|
||||||
The Dockerfile only installs build dependencies (g++ 11.4.0, CMake 3.22,
|
The Dockerfile installs all build dependencies including GUI support (
|
||||||
libncursesw5-dev). It does not copy or build the source code.
|
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:
|
From the project root:
|
||||||
|
|
||||||
@@ -352,8 +353,9 @@ docker run --rm -v "$(pwd):/kte" kte-linux
|
|||||||
# Expected output: "98 tests passed, 0 failed"
|
# Expected output: "98 tests passed, 0 failed"
|
||||||
```
|
```
|
||||||
|
|
||||||
The default command builds kte in terminal-only mode (`-DBUILD_GUI=OFF`)
|
The default command builds both `kte` (terminal) and `kge` (GUI)
|
||||||
and runs the full test suite.
|
executables with full GUI support (`-DBUILD_GUI=ON`) and runs the
|
||||||
|
complete test suite.
|
||||||
|
|
||||||
#### Custom Build Commands
|
#### Custom Build Commands
|
||||||
|
|
||||||
@@ -362,13 +364,18 @@ and runs the full test suite.
|
|||||||
docker run --rm -it -v "$(pwd):/kte" kte-linux /bin/bash
|
docker run --rm -it -v "$(pwd):/kte" kte-linux /bin/bash
|
||||||
|
|
||||||
# Then inside the container:
|
# Then inside the container:
|
||||||
cmake -B build -DBUILD_GUI=OFF -DBUILD_TESTS=ON
|
cmake -B build -DBUILD_GUI=ON -DBUILD_TESTS=ON
|
||||||
cmake --build build --target kte
|
cmake --build build --target kte # Terminal version
|
||||||
|
cmake --build build --target kge # GUI version
|
||||||
cmake --build build --target kte_tests
|
cmake --build build --target kte_tests
|
||||||
./build/kte_tests
|
./build/kte_tests
|
||||||
|
|
||||||
# Or run kte directly
|
# Or run kte directly
|
||||||
./build/kte --help
|
./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
|
#### Running kte Interactively
|
||||||
@@ -408,7 +415,7 @@ sudo usermod -aG docker $USER
|
|||||||
```
|
```
|
||||||
|
|
||||||
**Build fails with ncurses errors**:
|
**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.
|
ncurses). If you modify the Dockerfile, ensure this dependency remains.
|
||||||
|
|
||||||
**"No such file or directory" errors**:
|
**"No such file or directory" errors**:
|
||||||
|
|||||||
Reference in New Issue
Block a user