mirror of
https://github.com/sipeed/NanoKVM.git
synced 2026-09-11 09:26:44 -05:00
Layer the frontend toolchain on top of the existing release builder image so a single container covers Go, C support-layer and web development, with the builder image remaining the single source of truth for the cross toolchain, Go and MaixCDK. - Mount the workspace at /home/build/NanoKVM, where the Makefile and support/sg2002/build expect it, and resync MaixCDK components via update_lib on create so C builds never use stale sources - Install Node from official dist tarballs (integrity-checked, pinned to the major used by CI), with NODE_DIST_MIRROR / NPM_REGISTRY / BASE_IMAGE build args for restrictive or mirrored corporate networks - Export the MaixCDK virtualenv via remoteEnv so non-interactive processes (tasks, extensions, exec) get it too; make updateRemoteUserUID explicit since the published builder image bakes the CI runner's uid - Run pnpm non-interactively during post-create (no TTY) and give the skeleton-less home a standard ~/.profile -> ~/.bashrc chain - Make the web toolchain convention explicit via package.json engines (Node >= 22, pnpm >= 11, matching CI) and document it in web/README - Document the dev container in the README, point server/README at the container flow that works on any host OS, and ignore .pnpm-store/
NanoKVM Server
This is the backend server implementation for NanoKVM.
For detailed documentation, please visit our Wiki.
Structure
server
├── common // Common utility components
├── config // Server configuration
├── dl_lib // Shared object libraries
├── include // Header files for shared objects
├── logger // Logging system
├── middleware // Server middleware components
├── proto // API request/response definitions
├── router // API route handlers
├── service // Core service implementations
├── utils // Utility functions
└── main.go
Configuration
The configuration file path is /etc/kvm/server.yaml.
# Network Settings
proto: http # Access protocol. Can be changed to `https` only when certificates are configured. Default is `http`
host: "" # The listening address for the HTTP/HTTPS service. If left empty, all network interfaces will be bound
port:
http: 80 # The listening port for the HTTP service. Default is `80`
https: 443 # The listening port for the HTTPS service (effective when HTTPS is enabled). Default is `443`
cert:
crt: server.crt # The path to the public key certificate for HTTPS
key: server.key # The path to the private key file for HTTPS
# Logging Configuration
logger:
level: info # Global log output level. Evaluated options from highest to lowest detail: `trace`, `debug`, `info`, `warn`, `error`, `fatal`, `panic`. Default is `info`
file: stdout # Log output destination. `stdout` outputs to the standard console. A file path directs log output to that file. Default is `stdout`
# Authentication & Security
authentication: enable # Whether to enable identity verification for HTTP API and Web endpoints. Options are `enable` or `disable`. Default is `enable`. Highly recommended to leave this enabled for internet-facing devices!
jwt:
secretKey: "" # The secret key used to sign and verify JWT Tokens. If left empty, a random key will be generated automatically on startup
refreshTokenDuration: 2678400 # The token refresh duration threshold in seconds before forcing a re-login. Default is `2678400` (~31 days)
revokeTokensOnLogout: true # Whether to invalidate all existing tokens upon logout by rotating the SecretKey. Default is `true`
security:
loginLockoutDuration: 0, # The duration (in seconds) to ban an IP from attempting to log in again after reaching the failure limit. If set to `0` or left empty, brute-force protection is disabled. Default is `0`
loginMaxFailures: 5, # The maximum number of continuous failed login attempts allowed per IP before triggering protection. Default is `5`
# WebRTC Traversal Settings
stun: stun.l.google.com:19302 # The default STUN server address used for NAT hole-punching to establish P2P streams
turn:
turnAddr: example_addr # The relay (TURN) server address (format `ip:port`) used as a fallback when P2P connection fails. Leave empty to disable TURN relay
turnUser: example_user # The username required for authorization to the TURN server
turnCred: example_cred # The credential/password required for authorization to the TURN server
Compile & Deploy
Note: The manual steps below require a Linux x86-64 host with Go 1.25 or newer; they are not compatible with ARM, Windows or macOS. With Docker you can skip them entirely and use the containerized flow instead — the root Makefile (make shell) or the dev container (see "Development" in the root README) — which works on any host OS; run server/build.sh inside the container for a release-equivalent build.
-
Install the Toolchain
- Download the toolchain from the following link: Download Link.
- Extract the file and add the
host-tools/gcc/riscv64-linux-musl-x86_64/bindirectory to your PATH environment variable. - Run
riscv64-unknown-linux-musl-gcc -v. If there is version information in the output, the installation is successful.
-
Compile the Project
- Run
cd serverfrom the project root directory. - Run
go mod tidyto install Go dependencies. - (Optional) If you compiled
libkvm.soyourself, you need to modify its RPATH bypatchelf --add-rpath \$ORIGIN ./dl_lib/libkvm.so. - Run
CGO_ENABLED=1 GOOS=linux GOARCH=riscv64 CC=riscv64-unknown-linux-musl-gcc CGO_CFLAGS="-mcpu=c906fdv -march=rv64imafdcv0p7xthead -mcmodel=medany -mabi=lp64d" go buildto compile the project. - After compilation, an executable file named
NanoKVM-Serverwill be generated.
- Run
-
Modify RPATH
- Run
sudo apt install patchelforpip install patchelfto install patchelf. - Run
patchelf --version. Ensure the version is 0.14 or higher`. - Run
patchelf --add-rpath \$ORIGIN/dl_lib NanoKVM-Serverto modify the RPATH of the executable file.
- Run
-
Deploy the Application
- File uploads requires SSH. Please enable it in the Web Settings:
Settings > SSH; - Replace the original file in the NanoKVM
/kvmapp/server/directory with the newly compiledNanoKVM-Server. - Restart the service on NanoKVM by executing
/etc/init.d/S95nanokvm restart.
- File uploads requires SSH. Please enable it in the Web Settings:
Manually Update
File uploads requires SSH. Please enable it in the Web Settings:
Settings > SSH;
- Download the latest application from GitHub;
- Unzip the downloaded file and rename the unzipped folder to
kvmapp; - Back up the existing
/kvmappdirectory on your NanoKVM, then replace it with the newkvmappfolder; - Run
/etc/init.d/S95nanokvm restarton your NanoKVM to restart the service.