Repository navigation
Development
github-actions[bot] edited this page Jul 11, 2026
·
6 revisions
Guide for developers and contributors who want to build TeleCloud from source or contribute translations. Hướng dẫn dành cho nhà phát triển và người đóng góp muốn tự build TeleCloud hoặc đóng góp bản dịch.
Docker xử lý toàn bộ quá trình build mà không cần cài đặt Go hay Bun trên máy.
- Clone dự án:
git clone --recursive https://github.com/dabeecao/telecloud-go.git - Build image:
sudo docker build --build-arg DEFAULT_API_ID=your_api_id --build-arg DEFAULT_API_HASH=your_api_hash -t telecloud:local . - Chạy image vừa build:
sudo docker run -d -p 8091:8091 -v "$(pwd)/data:/app/data" --env-file .env telecloud:local
- Cài đặt Golang (1.26+) và Bun (https://bun.com).
- Clone với
--recursive(Bắt buộc để lấy code frontend):git clone --recursive https://github.com/dabeecao/telecloud-go.git - Build Frontend:
cd web bun install bun run build.js cd .. # Hoặc đơn giản là chạy `make frontend` ở thư mục gốc
- Build Backend:
go mod tidy go build -o telecloud
Để tránh bị lộ thông tin API nhạy cảm khi đẩy code lên GitHub, TeleCloud hỗ trợ tự động nạp thông tin này từ file .env cục bộ (được bỏ qua bởi Git).
- Khai báo
API_IDvàAPI_HASHtrong tệp.env. - Sử dụng các công cụ build:
-
Bằng Makefile: Chạy lệnh
makehoặcmake build. Script sẽ tự động lấy API từ tệp.envđể nhúng lúc biên dịch. -
Bằng Script build test: Chạy lệnh
./build-test.sh. Script cũng sẽ tự đọc.env, hoặc hiển thị hộp thoại yêu cầu nhập nếu không tìm thấy. -
Bằng lệnh thủ công:
go build -ldflags="-X telecloud/config.DefaultAPIIDStr=YOUR_API_ID -X telecloud/config.DefaultAPIHash=YOUR_API_HASH" -o telecloud
-
Bằng Makefile: Chạy lệnh
Mã nguồn frontend nằm ở repo: dabeecao/telecloud-frontend.
- Tìm tệp bản dịch trong
static/locales/(VD:vi.json). - Tạo tệp mới (VD:
fr.json) và dịch từen.json. - Thêm ngôn ngữ vào
availableLangstrongstatic/js/common.js. - Gửi Pull Request vào repository frontend.
- Để tránh xung đột đường dẫn lưu trữ khóa
master.keykhi thư mụcdatađược tạo sau lúc ứng dụng khởi động, toàn bộ mã nguồn sử dụng hàmutils.GetMasterKeyFilePath()để xác định vị trí tệp khóa chủ. - Hàm này tự động phát hiện tệp khóa tồn tại sẵn tại các đường dẫn:
/app/data/master.key,data/master.keyhoặc gần file SQLite DBDATABASE_PATH. - Trong phát triển, luôn gọi hàm
utils.GetMasterKeyFilePath()thay vì tự nội suy đường dẫn để tránh lỗi mất khóa hay sinh khóa mới khi cấu hình MySQL/Postgres.
- Khi viết các câu truy vấn SQL liên quan tới kiểu dữ liệu logic (
BOOLEAN), ví dụ trườngis_folderhoặcforce_password_change:-
KHÔNG ĐƯỢC gán hoặc so sánh trực tiếp với số nguyên (
1hoặc0). -
BẮT BUỘC sử dụng các từ khóa SQL tiêu chuẩn là
TRUEvàFALSEđể đảm bảo tương thích tốt nhất trên cả SQLite, MySQL và đặc biệt là cơ chế so khớp kiểu dữ liệu nghiêm ngặt của PostgreSQL.
-
KHÔNG ĐƯỢC gán hoặc so sánh trực tiếp với số nguyên (
git clone --recursive https://github.com/dabeecao/telecloud-go.gitsudo docker build --build-arg DEFAULT_API_ID=your_api_id --build-arg DEFAULT_API_HASH=your_api_hash -t telecloud:local .
- Install Golang (1.26+) and Bun (https://bun.com).
- Build frontend in
web/usingbun install && bun run build.js(ormake frontendin root). - Run
go mod tidyandgo build -o telecloudin root.
To prevent exposing sensitive API credentials in Git history, TeleCloud supports loading them dynamically from a local .env file (which is ignored by Git).
- Define
API_IDandAPI_HASHin your.envfile. - Build using helper tools:
-
Using Makefile: Run
makeormake build. It will extract credentials from.envand embed them. -
Using Test Script: Run
./build-test.sh. It also reads from.envor prompts for inputs if missing. -
Manually:
go build -ldflags="-X telecloud/config.DefaultAPIIDStr=YOUR_API_ID -X telecloud/config.DefaultAPIHash=YOUR_API_HASH" -o telecloud
-
Using Makefile: Run
Frontend source: dabeecao/telecloud-frontend.
- Edit JSON files in
static/locales/. - Add the language to
availableLangsinstatic/js/common.js. - Submit a Pull Request.
- To prevent key path conflicts when the
datadirectory is created dynamically during runtime, always useutils.GetMasterKeyFilePath()to resolve the persistent key path. - The path resolver automatically checks standard locations (
/app/data/master.key,data/master.key, or relative to SQLiteDATABASE_PATH) before choosing a fallback write path. - Never write ad-hoc file checks for
master.key; use the unified helper instead to prevent auto-regeneration bugs under MySQL/PostgreSQL.
- When writing SQL queries that filter or write to
BOOLEANcolumns (such asis_folderorforce_password_change):-
DO NOT use integer literals (
1or0). -
ALWAYS use standard SQL boolean literals
TRUEandFALSEto satisfy PostgreSQL's strict type verification while keeping full compatibility with SQLite and MySQL.
-
DO NOT use integer literals (