No description
| .forgejo/workflows | ||
| .github/workflows | ||
| testfiles | ||
| .gitignore | ||
| Dockerfile | ||
| README.md | ||
LightGBM Static Library for ARM64 (with Headers)
Minimal Docker image containing the LightGBM static library (lib_lightgbm.a) and all necessary header files built for ARM64/aarch64 architecture with OpenMP support.
🚀 Quick Start
Pull the image
docker pull jacobsvante/lightgbm-static-aarch64:latest
Extract the library
# Extract library and headers to current directory
docker run --rm -v $(pwd):/output jacobsvante/lightgbm-static-aarch64:latest \
sh -c "cp /lib/lib_lightgbm.a /output/ && cp -r /include /output/"
Extract using Docker cp
# Create container
docker create --name lgbm jacobsvante/lightgbm-static-aarch64:latest
# Copy files
docker cp lgbm:/lib/lib_lightgbm.a ./
docker cp lgbm:/include ./
# Cleanup
docker rm lgbm
📦 Image Contents
The image contains:
/lib/lib_lightgbm.a- The static library (~5-10 MB)/include/LightGBM/- All C API header filesc_api.h- Main C API interfaceexport.h- Export macrosutils/*- Utility headers- Additional internal headers
/build_info.txt- Build configuration and header list
Base image: busybox:1.36 (minimal ~1.5 MB base)
Total image size: ~10-15 MB
🏗️ Build Features
- Architecture: ARM64/aarch64
- OpenMP: Enabled (multi-threading support)
- BLAS: OpenBLAS
- GPU: Disabled
- Static: Fully static, no runtime dependencies
- Compiler: GCC with
-O3optimization - Alpine: Built on Alpine Linux 3.22
💻 Using the Library
C++ Example
// main.cpp
#include "LightGBM/c_api.h"
#include <vector>
#include <iostream>
int main() {
// Your LightGBM code here
std::cout << "LightGBM ready!" << std::endl;
return 0;
}
// Compile with:
// g++ main.cpp -I./include -L. -l:lib_lightgbm.a -fopenmp -pthread -lm -o your_app
CMake Example
cmake_minimum_required(VERSION 3.10)
project(YourApp)
# Set include path for headers
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
find_package(OpenMP REQUIRED)
find_package(Threads REQUIRED)
add_executable(your_app main.cpp)
target_link_libraries(your_app
${CMAKE_CURRENT_SOURCE_DIR}/lib_lightgbm.a
OpenMP::OpenMP_CXX
Threads::Threads
m
)
Directory Structure After Extraction
your_project/
├── lib_lightgbm.a
├── include/
│ └── LightGBM/
│ ├── c_api.h # Main API header
│ ├── export.h # Export definitions
│ ├── utils/
│ │ ├── common.h
│ │ ├── log.h
│ │ └── ...
│ └── ...
├── build_info.txt
└── main.cpp # Your application
🏷️ Available Tags
latest- Latest stable buildstable- Stable LightGBM versionv4.1.0,v4.0.0- Specific LightGBM versionsmain-YYYYMMDD- Daily builds from main branchsha-xxxxxxx- Specific commit builds
🔧 GitHub Actions Setup
1. Fork this repository
2. Set up Docker Hub secrets
Go to Settings → Secrets and variables → Actions, add:
DOCKER_USERNAME- Your Docker Hub usernameDOCKER_TOKEN- Docker Hub access token (not password)
3. Create Docker Hub access token
- Log in to Docker Hub
- Go to Account Settings → Security
- Click "New Access Token"
- Give it a descriptive name
- Copy the token and add it as
DOCKER_TOKENsecret
4. Update configuration
Edit .github/workflows/build.yml:
- Change
DOCKER_USERNAMEto your username - Update
IMAGE_NAMEif desired - Modify repository URLs in labels
5. Trigger a build
- Push to main branch
- Create a tag (
git tag v1.0.0 && git push --tags) - Manually trigger via Actions tab
📊 Verification
Check library information
# View build info (includes header list)
docker run --rm jacobsvante/lightgbm-static-aarch64:latest cat /build_info.txt
# Check library size
docker run --rm jacobsvante/lightgbm-static-aarch64:latest ls -lh /lib/lib_lightgbm.a
# List all headers
docker run --rm jacobsvante/lightgbm-static-aarch64:latest find /include -type f -name "*.h"
# Count headers
docker run --rm jacobsvante/lightgbm-static-aarch64:latest sh -c "find /include -type f -name '*.h' | wc -l"
# View specific header
docker run --rm jacobsvante/lightgbm-static-aarch64:latest cat /include/LightGBM/c_api.h | head -50
Verify on host
# After extraction
file lib_lightgbm.a
nm lib_lightgbm.a | grep LGBM_ | head -10
# Check headers are complete
ls -la include/LightGBM/
find include -name "*.h" | wc -l
# Verify you can compile against it
echo '#include "LightGBM/c_api.h"
int main() { return 0; }' > test.cpp
g++ test.cpp -I./include -L. -l:lib_lightgbm.a -pthread -lm -o test && echo "Headers OK!"
🔄 Multi-Architecture Builds
To build for both ARM64 and AMD64, uncomment the platform matrix in the workflow:
strategy:
matrix:
platform:
- linux/arm64
- linux/amd64 # Uncomment this line
🐛 Troubleshooting
QEMU Issues
If building ARM64 on AMD64 runners fails:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
image: tonistiigi/binfmt:latest # Add this for better compatibility
Build Timeout
For large builds, increase the timeout:
jobs:
build-and-push:
runs-on: ubuntu-latest
timeout-minutes: 120 # Increase from default 60
📄 License
This Docker image build process is MIT licensed. LightGBM itself is licensed under the MIT License.
🤝 Contributing
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request