feat: add libsql

This commit is contained in:
Sun-ZhenXing
2025-12-29 18:05:34 +08:00
parent 4c7b3afc10
commit 953bb146ba
18 changed files with 1128 additions and 502 deletions

71
src/libsql/.env.example Normal file
View File

@@ -0,0 +1,71 @@
# Global registry prefix (optional, for custom registry mirrors)
# GLOBAL_REGISTRY=
# libSQL Server version
LIBSQL_VERSION=latest
# Platform architecture (linux/amd64 or linux/arm64)
# Note: For ARM64 (Apple Silicon), use latest-arm tag or run via Rosetta with linux/amd64
LIBSQL_PLATFORM=linux/amd64
# Timezone
TZ=UTC
# ==================== Port Configuration ====================
# HTTP/Hrana API port (client connections)
LIBSQL_HTTP_PORT_OVERRIDE=8080
# gRPC port (for replication between primary and replicas)
LIBSQL_GRPC_PORT_OVERRIDE=5001
# Replica HTTP port (only used when replica profile is enabled)
LIBSQL_REPLICA_HTTP_PORT_OVERRIDE=8081
# Replica gRPC port (only used when replica profile is enabled)
LIBSQL_REPLICA_GRPC_PORT_OVERRIDE=5002
# ==================== Node Configuration ====================
# Node type: primary, replica, or standalone
# - primary: Main database instance, accepts writes
# - replica: Read-only replica, replicates from primary
# - standalone: Single instance without replication
LIBSQL_NODE=primary
# Database file name (stored in /var/lib/sqld by default)
LIBSQL_DB_PATH=iku.db
# HTTP listen address (internal, usually no need to change)
LIBSQL_HTTP_LISTEN_ADDR=0.0.0.0:8080
# gRPC listen address (internal, usually no need to change)
LIBSQL_GRPC_LISTEN_ADDR=0.0.0.0:5001
# ==================== Replication Configuration ====================
# Primary URL for replica instances (format: http://host:port or https://host:port)
# Only required when LIBSQL_NODE=replica
# Example for Docker Compose: http://libsql:5001
LIBSQL_PRIMARY_URL=http://libsql:5001
# ==================== Authentication (Optional) ====================
# HTTP basic authentication (format: basic:base64(username:password))
# Example: basic:dXNlcjpwYXNz (for user:pass)
# LIBSQL_HTTP_AUTH=
# Path to JWT key file for authentication (mounted into container)
# LIBSQL_AUTH_JWT_KEY_FILE=
# JWT key directly as environment variable (alternative to file)
# LIBSQL_AUTH_JWT_KEY=
# ==================== Resource Limits ====================
# Primary instance resource limits
LIBSQL_CPU_LIMIT=1.0
LIBSQL_MEMORY_LIMIT=512M
LIBSQL_CPU_RESERVATION=0.5
LIBSQL_MEMORY_RESERVATION=256M
# Replica instance resource limits (when replica profile is enabled)
LIBSQL_REPLICA_CPU_LIMIT=1.0
LIBSQL_REPLICA_MEMORY_LIMIT=512M
LIBSQL_REPLICA_CPU_RESERVATION=0.5
LIBSQL_REPLICA_MEMORY_RESERVATION=256M