Last Updated on : 2024-06-14 18:23:01download
Hybrid deployment allows you to run both microapps developed on your own and those provided by Tuya in your SaaS. This topic describes how to configure your local environment for hybrid deployment and make your custom microapps run as expected.
You can deploy a custom microapp container on Docker. API requests will be routed through the SaaS domain name to the runtime service that you have deployed. Then, based on the types of API requests, they are routed to the backend service configured by yourself or to Tuya’s cloud service.
Download the runtime environment.
Go to the target directory in local mode. Run the download script and unzip the installation package.
# If you use curl
curl -Ljo sdf-deploy-rt.zip https://github.com/tuya-sat/sdf-deploy/archive/refs/tags/rt.zip
# If you use wget
wget https://github.com/tuya-sat/sdf-deploy/archive/refs/tags/rt.zip -O sdf-deploy-rt.zip
After the download is completed, unzip the installation package.
unzip sdf-deploy-rt.zip
After the package is unzipped, you can see files with the following directory structure:
# sdf-deploy-rt directory
├── LICENSE
├── README.md
├── docker-compose
│ ├── README.md
│ └── docker-compose.yml
│ └── redis
Edit the .env
file and configure the developer App Key
and Secret Key
of the SaaS application.
cd sdf-deploy-rt/docker-compose/ # Go to the docker-compose directory
vi .env # Edit the .env file.
# developer Configuration information
APP_KEY=Developer App Key
SECRET_KEY=Developer Secret Key
The following table describes these parameters.
Configuration file | Parameter | Description | Value |
---|---|---|---|
.env | OPEN_API |
Domain name of Tuya OpenAPI platform |
|
.env | APP_KEY |
Developer identity | Go to SaaS Development > MicroApp Dev and click View Development Credentials in the top right corner of the microapp list to get the App Key . |
.env | SECRET_KEY |
Developer identity secret | Go to SaaS Development > MicroApp Dev and click View Development Credentials in the top right corner of the microapp list to get the Secret Key . |
.env | CUSTOM_API_URL |
Domain name of developer backend service | https://your-api-gateway.com |
.env | HOST_PORT |
Port of SaaS domain name | Default port: 80 |
Start the microapp container.
docker compose up
# For Docker compose of an early version, run the command docker-compose up
When mqtt MQTT client status: connect
appears, it means the startup is successful.
[+] Running 2/0
⠿ Container sdf-redis Created 0.0s
⠿ Container sdf-fgw Created 0.0s
Attaching to sdf-fgw, sdf-redis
sdf-redis | 1:C 08 Jun 2023 11:54:08.807 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
......
sdf-fgw | 2023-06-08T11:58:15.500Z INFO microadmin request https://micro-app-admin.tuyacn.com/v1.0/sdf/developer/mqtt/auth
sdf-fgw | 2023-06-08T11:58:15.518Z INFO mqtt MQTT client status: end
sdf-fgw | 2023-06-08T11:58:15.627Z INFO mqtt MQTT client config: {"clientId":"sdf_developer_key_clientid_52 ******** 3","username":"sdf_developer_key_username_523 ******** d","password":"6***5","wsUrl":"wss://mqtt-im.tuyacn.com:443/mqtt"}
sdf-fgw | 2023-06-08T11:58:15.809Z INFO mqtt MQTT client status: connect
sdf-fgw | 2023-06-08T11:58:15.909Z INFO mqtt MQTT client status: connect
......
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback