You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/build-apps/event-handlers.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
In Openblocks, event handlers are responsible for collecting and processing events from components and queries, and executing subsequent actions. For example, for a **Button** component, you can add an event handler to trigger the **Run query** action **** in response to the button **Click** event.
Set event handlers wisely to provide a reactive and responsive user experience (UX). For example, triggering a **get-all** query after **insert-new-data** query finishes enables table automatically refresh.
8
8
@@ -32,7 +32,7 @@ Running a query can result in success or failure, so queries have two events: **
32
32
33
33
There are a number of event handler actions available in Openblocks for handling different scenarios. Set them in the **Action** dropdown list in an event handler.
34
34
35
-
 (1).png>)
35
+
 (1).png>)
36
36
37
37
{% hint style="info" %}
38
38
See [advanced](event-handlers.md#advanced) on this page to know advanced settings.
@@ -48,7 +48,7 @@ Trigger the selected query.
48
48
49
49
To control a component, select a component in the **Component** dropdown list and call one of its methods in the **Method** dropdown list.
Copy file name to clipboardExpand all lines: docs/build-apps/module.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ When building an app, you want to reuse components and queries across different
4
4
5
5
<figure><imgsrc="../.gitbook/assets/module-1.png"alt=""><figcaption><p>Build a <ahref="module.md#demo-a-statistics-module">statistics module</a></p></figcaption></figure>
6
6
7
-
<figure><imgsrc="../.gitbook/assets/module-2 (1).png"alt=""><figcaption><p>Reuse this module anywhere</p></figcaption></figure>
7
+
<figure><imgsrc="../.gitbook/assets/module-2.png"alt=""><figcaption><p>Reuse this module anywhere</p></figcaption></figure>
8
8
9
9
## Module basics
10
10
@@ -67,7 +67,7 @@ Module inputs are parameters passed to the module from external apps. The suppor
67
67
68
68
This section guides you through the steps to build a statistics module and reuse it in an app.  
Navigate to the left sidebar, click <imgsrc="../.gitbook/assets/image (1).png"alt=""data-size="line"> > **Other** > **Scripts and style** > **Add a library**. Then paste the **cowsay** link here.
72
72
73
-
<figure><imgsrc="../.gitbook/assets/Add a library (1) (1) (1) (1) (1) (1).png"alt=""><figcaption></figcaption></figure>
73
+
<figure><imgsrc="../.gitbook/assets/Add a library (1) (1) (1) (1) (1) (1) (1).png"alt=""><figcaption></figcaption></figure>
74
74
75
75
Now you can write code in **JS query** to test its usage with `cowsay.say`:
76
76
77
-
<figure><imgsrc="../.gitbook/assets/write code in JS query (1) (1) (1) (1) (2).png"alt=""><figcaption></figcaption></figure>
Copy file name to clipboardExpand all lines: docs/queries/query-basics.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ Queries support you to read data from or write data to your data sources. You ca
6
6
7
7
You can connect to a data source that was already in your data source library or create a new one. For detailed information, see [data-source-basics.md](../data-sources/data-source-basics.md"mention").
Copy file name to clipboardExpand all lines: docs/self-hosting/README.md
+110-49
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,14 @@
1
-
---
2
-
description: Host Openblocks on your own device using Docker or Docker-Compose.
3
-
---
4
-
5
1
# Self-hosting
6
2
7
-
## Prerequisites
3
+
In this article, you will be guided through hosting Openblocks on your own server using Docker-Compose or Docker.
4
+
5
+
For easy setup and deployment, we provide an [all-in-one image](https://hub.docker.com/r/openblocksdev/openblocks-ce) which bundles frontend, backend and data persistence services altogether in one single container. 
6
+
7
+
Also, for developers in need of stateless containers in cluster environment, we provide [separate images](https://hub.docker.com/u/openblocksdev) of backend and frontend services with a customizable Dockerfile.
8
+
9
+
## All-in-one image: all services in one container <ahref="#all-in-one"id="all-in-one"></a>
10
+
11
+
### Prerequisites
8
12
9
13
*[Docker](https://docs.docker.com/get-docker/) (version 20.10.7 or above)
10
14
*[Docker-Compose](https://docs.docker.com/compose/install/) (version 1.29.2 or above)
@@ -17,12 +21,12 @@ Windows users are recommended to use PowerShell for running commands below.
17
21
18
22
In your working directory, run the following commands to make a directory named `openblocks` to store the data of Openblocks:
19
23
20
-
```powershell
24
+
```bash
21
25
mkdir openblocks
22
26
cd openblocks
23
27
```
24
28
25
-
## Deploy
29
+
###Deploy
26
30
27
31
{% tabs %}
28
32
{% tab title="Docker-Compose (Recommend)" %}
@@ -57,10 +61,12 @@ Follow the steps below:
57
61
58
62
59
63
60
-
When you see `frontend`, `backend`, `redis`, and `mongo``entered the RUNNING state`, the Openblocks service has officially started:\
61
-
64
+
When you see `frontend`, `backend`, `redis`, and `mongo``entered the RUNNING state`, the Openblocks service has officially started: 
4. Visit [**http://localhost:3000**](http://localhost:3000) and click **Sign up**. Openblocks will automatically create a workspace for you, then you can start building your apps and invite members to your workspace.
Run the following commands to update to the latest Openblocks image:
88
+
89
+
```bash
90
+
docker-compose pull
91
+
docker-compose rm -fsv openblocks
92
+
docker-compose up -d
93
+
```
94
+
{% endtab %}
95
+
96
+
{% tab title="Docker" %}
97
+
Run the following commands to update to the latest Openblocks image:
98
+
99
+
{% code overflow="wrap" %}
100
+
```bash
101
+
docker pull openblocksdev/openblocks-ce
102
+
docker rm -fv openblocks
103
+
docker run -d --name openblocks -p 3000:3000 -v "$PWD/stacks:/openblocks-stacks" openblocksdev/openblocks-ce
104
+
```
105
+
{% endcode %}
106
+
{% endtab %}
107
+
{% endtabs %}
108
+
109
+
## Separate images: services in different containers <a href="#multi" id="multi"></a>
110
+
111
+
For developers who require stateless containers in a cluster environment, we offer separate images of backend and frontend service with a customizable Dockerfile. A well-functioning Openblocks deployment consists of below services:
112
+
113
+
***api-service**: Backend service.
114
+
***node-service**: Backend service.
115
+
***frontend**: Frontend service.
116
+
***MongoDB**: Used for persisting data of users, apps, data sources, etc.
117
+
***Redis**: Used for maintaining user sessions, rate limiter, etc.
118
+
119
+
### Prerequisites
120
+
121
+
* [Docker-Compose](https://docs.docker.com/compose/install/) (version 1.29.2 or above)
122
+
123
+
### Deploy
124
+
125
+
1. In your working directory, run the following commands to make a directory named `openblocks` to store the data of Openblocks:
126
+
127
+
```bash
128
+
mkdir openblocks
129
+
cd openblocks
130
+
```
131
+
2. Download the configuration file by clicking [docker-compose-multi.yml](https://cdn-files.openblocks.dev/docker-compose-multi.yml) or running the curl command:
***mongodb**: Start a new MongoDB instance on your host. You can delete this part and modify the environment variable `MONGODB_URI` of **openblocks-api-service** to use your own MongoDB.
140
+
***redis**: Start a new Redis instance on your host. You can delete this part and modify the environment variable `REDIS_URI` of **openblocks-api-service** to use your own Redis.
141
+
***openblocks-api-service**: Required. 
142
+
***openblocks-node-service**: Required.
143
+
***openblocks-frontend**: Required. Can be optional if you deploy frontend on CDN.
144
+
4. Start Docker containers by running this command:
145
+
146
+
```bash
147
+
docker-compose -f docker-compose-multi.yml up -d
148
+
```
149
+
5. Visit [**http://localhost:3000**](http://localhost:3000) and click **Sign up**. Openblocks will automatically create a workspace for you, then you can start building your apps and invite members to your workspace.
Run the following commands to update services to the latest:
156
+
157
+
```bash
158
+
docker-compose pull
159
+
docker-compose up -d
160
+
```
161
+
162
+
## Customize configurations
163
+
164
+
This section shows how to customize deployment configurations by setting environment variables. 
78
165
79
-
This section shows how to customize deployment configurations. If you have already started a container, you need to restart the containerforthe new configurations to take effect. Following are the ways to **restart** your container:
166
+
If you have already started Docker containers, you need to restart the containersfor new configurations to take effect. For example, the way to **restart** your container running an all-in-one image is:
80
167
81
168
{% tabs %}
82
169
{% tab title="Docker-Compose (Recommend)" %}
83
170
One single command:
84
171
85
-
```
86
-
docker-compose up
172
+
```bash
173
+
docker-compose up -d
87
174
```
88
175
89
176
It picks up configuration changes by stopping containers already in service and recreating new ones.
@@ -92,14 +179,20 @@ It picks up configuration changes by stopping containers already in service and
92
179
{% tab title="Docker" %}
93
180
Run the following commands to stop, remove the container already in service, and start up a new one using the newly customized deployment command.
94
181
95
-
```docker
182
+
```bash
96
183
docker stop openblocks
97
184
docker rm openblocks
98
185
# run your new docker run command
99
186
```
100
187
{% endtab %}
101
188
{% endtabs %}
102
189
190
+
Below are examples of configuring all-in-one image by setting environment variables in`docker-compose.yml`. If you are self-hosting with separate images, modify `openblocks-api-service` part of `docker-compose-multi.yml` instead. 
191
+
192
+
{% hint style="info" %}
193
+
For more information about configurations and environment variables, see [Configuration](https://github.com/openblocks-dev/openblocks/tree/develop/deploy/docker#all-in-one-image).
194
+
{% endhint %}
195
+
103
196
### Use your own MongoDB and Redis
104
197
105
198
By default Openblocks uses the built-in MongoDB and Redis installed inside the container, and you can replace them with your own MongoDB and Redis clusters.
@@ -114,7 +207,7 @@ Add environment variables `MONGODB_URI` and `REDIS_URI` in `docker-compose.yml`
114
207
Add environment variables `MONGODB_URI` and `REDIS_URI` to the deployment command, as shown below:
@@ -158,7 +251,7 @@ With an SSL certificate, you can securely visit self-hosted Openblocks with HTTP
158
251
2. Change the `ports`in the deployment command to `3443:3443`, as shown below:
159
252
160
253
{% code overflow="wrap" %}
161
-
```docker
254
+
```bash
162
255
docker run -d --name openblocks -p 3443:3443 -v "$PWD/stacks:/openblocks-stacks" openblocksdev/openblocks-ce
163
256
```
164
257
{% endcode %}
@@ -170,35 +263,3 @@ In cases where you have certificates with names: `server.crt` and `server.key`,
170
263
`server.crt` =>`fullchain.pem`\
171
264
`server.key` =>`privkey.pem`
172
265
{% endhint %}
173
-
174
-
## Update
175
-
176
-
{% tabs %}
177
-
{% tab title="Docker-Compose" %}
178
-
Run the following commands to update to the latest Openblocks image:
179
-
180
-
```docker
181
-
docker-compose pull
182
-
docker-compose rm -fsv openblocks
183
-
docker-compose up -d
184
-
```
185
-
{% endtab %}
186
-
187
-
{% tab title="Docker" %}
188
-
Run the following commands to update to the latest Openblocks image:
189
-
190
-
{% code overflow="wrap" %}
191
-
```docker
192
-
docker pull openblocksdev/openblocks-ce
193
-
docker rm -fv openblocks
194
-
docker run -d --name openblocks -p 3000:3000 -v "$PWD/stacks:/openblocks-stacks" openblocksdev/openblocks-ce
195
-
```
196
-
{% endcode %}
197
-
{% endtab %}
198
-
{% endtabs %}
199
-
200
-
## Sign up
201
-
202
-
Visit **http://localhost:3000** and click **Sign up**. Openblocks will automatically create a workspace for you, then you can start building your apps and invite members to your workspace.
0 commit comments