kopia lustrzana https://github.com/ToolJet/ToolJet
Revise docker setup (#3954)
* fixes separate client build * update docs * add SERVE_CLIENT flag for dev docker step for uniformity * Doc changes * Doc changes * Doc changes * update readme * add separate docker compose setups * Doc changes * rename compose files * remove unused dependency * rename service name to server for uniformity Co-authored-by: Navaneeth Pk <navaneeth@tooljet.io>pull/3973/head
rodzic
84e7cef097
commit
0d482f8161
|
@ -0,0 +1,38 @@
|
|||
version: '3'
|
||||
|
||||
services:
|
||||
server:
|
||||
tty: true
|
||||
stdin_open: true
|
||||
image: tooljet/tooljet-ce:latest
|
||||
restart: always
|
||||
env_file: .env
|
||||
ports:
|
||||
- 80:80
|
||||
depends_on:
|
||||
- postgres
|
||||
environment:
|
||||
SERVE_CLIENT: "true"
|
||||
PORT: "80"
|
||||
command: npm run start:prod
|
||||
|
||||
postgres:
|
||||
image: postgres:13
|
||||
restart: always
|
||||
ports:
|
||||
- 5432:5432
|
||||
volumes:
|
||||
- postgres:/var/lib/postgresql/data
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
|
||||
volumes:
|
||||
postgres:
|
||||
driver: local
|
||||
driver_opts:
|
||||
o: bind
|
||||
type: none
|
||||
device: ${PWD}/postgres_data
|
||||
certs:
|
||||
logs:
|
||||
fallbackcerts:
|
|
@ -0,0 +1,37 @@
|
|||
version: '3'
|
||||
|
||||
services:
|
||||
client:
|
||||
tty: true
|
||||
stdin_open: true
|
||||
image: tooljet/tooljet-client-ce:latest
|
||||
restart: always
|
||||
env_file: .env
|
||||
depends_on:
|
||||
- server
|
||||
volumes:
|
||||
- logs:/var/log/openresty/
|
||||
- certs:/etc/resty-auto-ssl/
|
||||
- fallbackcerts:/etc/fallback-certs
|
||||
# - /replace_path_here/nginx.conf.template:/etc/openresty/nginx.conf.template
|
||||
ports:
|
||||
- 80:80
|
||||
- 443:443
|
||||
command: openresty -g "daemon off;"
|
||||
|
||||
server:
|
||||
image: tooljet/tooljet-server-ce:latest
|
||||
tty: true
|
||||
stdin_open: true
|
||||
restart: always
|
||||
ports:
|
||||
- 3000
|
||||
env_file: .env
|
||||
environment:
|
||||
SERVE_CLIENT: "false"
|
||||
command: npm run start:prod
|
||||
|
||||
volumes:
|
||||
certs:
|
||||
logs:
|
||||
fallbackcerts:
|
|
@ -1,37 +1,15 @@
|
|||
version: '3'
|
||||
|
||||
services:
|
||||
client:
|
||||
server:
|
||||
tty: true
|
||||
stdin_open: true
|
||||
image: tooljet/tooljet-client-ce:latest
|
||||
image: tooljet/tooljet-ce:latest
|
||||
restart: always
|
||||
env_file: .env
|
||||
depends_on:
|
||||
- server
|
||||
volumes:
|
||||
- logs:/var/log/openresty/
|
||||
- certs:/etc/resty-auto-ssl/
|
||||
- fallbackcerts:/etc/fallback-certs
|
||||
# - /replace_path_here/nginx.conf.template:/etc/openresty/nginx.conf.template
|
||||
ports:
|
||||
- 80:80
|
||||
- 443:443
|
||||
command: openresty -g "daemon off;"
|
||||
|
||||
server:
|
||||
image: tooljet/tooljet-server-ce:latest
|
||||
tty: true
|
||||
stdin_open: true
|
||||
restart: always
|
||||
ports:
|
||||
- 3000
|
||||
env_file: .env
|
||||
environment:
|
||||
SERVE_CLIENT: "false"
|
||||
SERVE_CLIENT: "true"
|
||||
PORT: "80"
|
||||
command: npm run start:prod
|
||||
|
||||
volumes:
|
||||
certs:
|
||||
logs:
|
||||
fallbackcerts:
|
||||
|
|
|
@ -26,6 +26,7 @@ services:
|
|||
environment:
|
||||
- WEBPACKER_DEV_SERVER_HOST=0.0.0.0
|
||||
- NODE_ENV=development
|
||||
- SERVE_CLIENT=false
|
||||
command: npm run --prefix frontend start
|
||||
|
||||
server:
|
||||
|
|
|
@ -22,7 +22,7 @@ RUN npm --prefix plugins prune --production
|
|||
COPY ./frontend/package.json ./frontend/package-lock.json ./frontend/
|
||||
RUN npm --prefix frontend install
|
||||
COPY ./frontend ./frontend
|
||||
RUN npm --prefix frontend run build --production
|
||||
RUN SERVE_CLIENT=false npm --prefix frontend run build --production
|
||||
RUN npm --prefix frontend prune --production
|
||||
|
||||
FROM openresty/openresty:1.19.9.1rc1-buster-fat
|
||||
|
|
|
@ -7,12 +7,17 @@ title: Deploying ToolJet client
|
|||
|
||||
ToolJet client is a standalone application and can be deployed on static website hosting services such as Netlify, Firebase, S3/Cloudfront, etc.
|
||||
|
||||
You can build standalone client with the below command:
|
||||
```bash
|
||||
SERVE_CLIENT=false npm run build
|
||||
```
|
||||
|
||||
## Deploying ToolJet client on Firebase
|
||||
|
||||
:::tip
|
||||
You should set the environment variable `TOOLJET_SERVER_URL` ( URL of the server ) while building the frontend.
|
||||
You should set the environment variable `TOOLJET_SERVER_URL` ( URL of the server ) while building the frontend and also set `SERVE_CLIENT` to `false`` for standalone client build.
|
||||
|
||||
For example: `NODE_ENV=production TOOLJET_SERVER_URL=https://server.tooljet.com npm run build && firebase deploy`
|
||||
For example: `SERVE_CLIENT=false TOOLJET_SERVER_URL=https://server.tooljet.com npm run build && firebase deploy`
|
||||
:::
|
||||
|
||||
1. Initialize firebase project
|
||||
|
@ -31,7 +36,7 @@ For example: `NODE_ENV=production TOOLJET_SERVER_URL=https://server.tooljet.com
|
|||
You should set the environment variable `TOOLJET_SERVER_URL` ( URL of the server ) while building the frontend.
|
||||
|
||||
|
||||
For example: `NODE_ENV=production TOOLJET_SERVER_URL=https://server.tooljet.io npm run build`
|
||||
For example: `SERVE_CLIENT=false TOOLJET_SERVER_URL=https://server.tooljet.io npm run build`
|
||||
:::
|
||||
|
||||
#### Using Load balancer
|
||||
|
|
|
@ -3,50 +3,154 @@ id: docker
|
|||
title: Docker
|
||||
---
|
||||
|
||||
# Deploying ToolJet using docker-compose
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
Follow the steps below to deploy ToolJet on a server using docker-compose. This setup will deploy both **ToolJet server** and **ToolJet client**.
|
||||
# Deploying ToolJet using Docker Compose
|
||||
|
||||
Follow the steps below to deploy ToolJet on a server using Docker Compose. ToolJet requires a PostgreSQL database to store applications definitions, (encrypted) credentials for datasources and user authentication data.
|
||||
|
||||
:::info
|
||||
If you rather want to try out ToolJet locally with docker, you can follow the steps [here](https://docs.tooljet.com/docs/setup/docker-local).
|
||||
If you rather want to try out ToolJet on your local machine with Docker, you can follow the steps [here](https://docs.tooljet.com/docs/setup/docker-local).
|
||||
:::
|
||||
|
||||
1. Make sure that the server can receive traffic on port 80, 443 and 22.
|
||||
For example, if the server is an AWS EC2 instance and the installation should receive traffic from the internet, the inbound rules of the security group should look like this:
|
||||
|
||||
| protocol | port | allowed_cidr |
|
||||
| -------- | ---- | ------------ |
|
||||
| tcp | 22 | your IP |
|
||||
| tcp | 80 | 0.0.0.0/0 |
|
||||
| tcp | 443 | 0.0.0.0/0 |
|
||||
|
||||
2. Install docker and docker-compose on the server.
|
||||
### Installing Docker and Docker Compose
|
||||
Install docker and docker-compose on the server.
|
||||
- Docs for [Docker Installation](https://docs.docker.com/engine/install/)
|
||||
- Docs for [Docker Compose Installation](https://docs.docker.com/compose/install/)
|
||||
|
||||
3. Setup a PostgreSQL database and make sure that the database is accessible. (Optional)
|
||||
:::info
|
||||
We recommend to use managed postgres service on production for ease of administration, security and management (backups, monitoring etc).
|
||||
If you'd want to run postgres with persistent volume rather, curl for the alternate docker compose file shared in the next step.
|
||||
:::
|
||||
### Deployment options
|
||||
|
||||
4. Download our production docker-compose file into the server.
|
||||
There are four options to deploy ToolJet using Docker Compose:
|
||||
1. **Using an external PostgreSQL database**. This setup is recommended if you want to use a managed PostgreSQL service such as AWS RDS or Google Cloud SQL.
|
||||
2. **Using in-built PostgreSQL database**. This setup uses the official Docker image of PostgreSQL.
|
||||
3. **Using an external PostgreSQL database and auto SSL**. Recommended only if you want the Docker container itself to do do SSL termination.
|
||||
4. **Using in-built PostgreSQL database and auto SSL**. Recommended only if you want the Docker container itself to do do SSL termination.
|
||||
|
||||
For managed PostgreSQL database:
|
||||
Confused about which setup to select? feel free to ask the community via Slack: https://tooljet.com/slack.
|
||||
|
||||
:::info
|
||||
We recommend to use managed PostgreSQL service on production for ease of administration, security and management (backups, monitoring etc).
|
||||
If you'd want to run postgres with persistent volume rather, curl for the alternate docker compose file shared in the next step.
|
||||
:::
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="with-external-db" label="With external DB" default>
|
||||
|
||||
1. Setup a PostgreSQL database and make sure that the database is accessible.
|
||||
|
||||
2. Download our production docker-compose file into the server.
|
||||
```bash
|
||||
curl -LO https://raw.githubusercontent.com/ToolJet/ToolJet/main/deploy/docker/docker-compose.yaml
|
||||
```
|
||||
|
||||
OR
|
||||
3. Create `.env` file in the current directory (where the docker-compose.yaml file is downloaded):
|
||||
|
||||
For PostgreSQL database setup with persistent volume:
|
||||
```bash
|
||||
curl -LO https://raw.githubusercontent.com/ToolJet/ToolJet/main/deploy/docker/docker-compose-postgres.yaml
|
||||
mv docker-compose-postgres.yaml docker-compose.yaml
|
||||
curl -LO https://raw.githubusercontent.com/ToolJet/ToolJet/main/deploy/docker/.env.example
|
||||
mv .env.example .env
|
||||
```
|
||||
|
||||
Set up environment variables in `.env` file as explained in [environment variables reference](/docs/setup/env-vars)
|
||||
|
||||
`TOOLJET_HOST` environment variable can either be the public ipv4 address of your server or a custom domain that you want to use.
|
||||
|
||||
Examples:
|
||||
`TOOLJET_HOST=http://12.34.56.78` or
|
||||
`TOOLJET_HOST=https://yourdomain.com` or
|
||||
`TOOLJET_HOST=https://tooljet.yourdomain.com`
|
||||
|
||||
:::info
|
||||
Please make sure that `TOOLJET_HOST` starts with either `http://` or `https://`
|
||||
:::
|
||||
|
||||
:::info
|
||||
If there are self signed HTTPS endpoints that Tooljet needs to connect to, please make sure that `NODE_EXTRA_CA_CERTS` environment variable is set to the absolute path containing the certificates.
|
||||
:::
|
||||
|
||||
4. Once you've populated the `.env` file, run
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
to start all the required services.
|
||||
|
||||
:::info
|
||||
If you're running on a linux server, `docker` might need sudo permissions. In that case you can either run:
|
||||
`sudo docker-compose up -d`
|
||||
OR
|
||||
Setup docker to run without root privileges by following the instructions written here https://docs.docker.com/engine/install/linux-postinstall/
|
||||
:::
|
||||
|
||||
5. If you've set a custom domain for `TOOLJET_HOST`, add a `A record` entry in your DNS settings to point to the IP address of the server.
|
||||
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="with-in-built-db" label="With in-built DB">
|
||||
|
||||
1. Download our production docker-compose file into the server.
|
||||
```bash
|
||||
curl -LO https://raw.githubusercontent.com/ToolJet/ToolJet/main/deploy/docker/docker-compose-db.yaml
|
||||
mv docker-compose-db.yaml docker-compose.yaml
|
||||
mkdir postgres_data
|
||||
```
|
||||
|
||||
5. Create `.env` file in the current directory (where the docker-compose.yaml file is downloaded):
|
||||
2. Create `.env` file in the current directory (where the docker-compose.yaml file is downloaded):
|
||||
|
||||
```bash
|
||||
curl -LO https://raw.githubusercontent.com/ToolJet/ToolJet/main/deploy/docker/.env.example
|
||||
mv .env.example .env
|
||||
```
|
||||
|
||||
Set up environment variables in `.env` file as explained in [environment variables reference](/docs/setup/env-vars)
|
||||
|
||||
`TOOLJET_HOST` environment variable can either be the public ipv4 address of your server or a custom domain that you want to use.
|
||||
|
||||
Examples:
|
||||
`TOOLJET_HOST=http://12.34.56.78` or
|
||||
`TOOLJET_HOST=https://yourdomain.com` or
|
||||
`TOOLJET_HOST=https://tooljet.yourdomain.com`
|
||||
|
||||
:::info
|
||||
Please make sure that `TOOLJET_HOST` starts with either `http://` or `https://`
|
||||
:::
|
||||
|
||||
:::info
|
||||
If there are self signed HTTPS endpoints that Tooljet needs to connect to, please make sure that `NODE_EXTRA_CA_CERTS` environment variable is set to the absolute path containing the certificates.
|
||||
:::
|
||||
|
||||
3. Once you've populated the `.env` file, run
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
to start all the required services.
|
||||
|
||||
:::info
|
||||
If you're running on a linux server, `docker` might need sudo permissions. In that case you can either run:
|
||||
`sudo docker-compose up -d`
|
||||
OR
|
||||
Setup docker to run without root privileges by following the instructions written here https://docs.docker.com/engine/install/linux-postinstall/
|
||||
:::
|
||||
|
||||
4. If you've set a custom domain for `TOOLJET_HOST`, add a `A record` entry in your DNS settings to point to the IP address of the server.
|
||||
|
||||
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="docker-auto-ssl-and-with-external" label="With auto SSL & external DB">
|
||||
|
||||
1. Setup a PostgreSQL database and make sure that the database is accessible.
|
||||
|
||||
2. Download our production docker-compose file into the server.
|
||||
```bash
|
||||
curl -LO https://raw.githubusercontent.com/ToolJet/ToolJet/main/deploy/docker/docker-compose-ssl.yaml
|
||||
mv docker-compose-ssl.yaml docker-compose.yaml
|
||||
```
|
||||
|
||||
3. Create `.env` file in the current directory (where the docker-compose.yaml file is downloaded):
|
||||
|
||||
```bash
|
||||
curl -LO https://raw.githubusercontent.com/ToolJet/ToolJet/main/deploy/docker/.env.example
|
||||
|
@ -75,7 +179,7 @@ If you rather want to try out ToolJet locally with docker, you can follow the st
|
|||
If there are self signed HTTPS endpoints that Tooljet needs to connect to, please make sure that `NODE_EXTRA_CA_CERTS` environment variable is set to the absolute path containing the certificates.
|
||||
:::
|
||||
|
||||
6. Once you've populated the `.env` file, run
|
||||
4. Once you've populated the `.env` file, run
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
|
@ -90,16 +194,91 @@ If you rather want to try out ToolJet locally with docker, you can follow the st
|
|||
Setup docker to run without root privileges by following the instructions written here https://docs.docker.com/engine/install/linux-postinstall/
|
||||
:::
|
||||
|
||||
7. If you've set a custom domain for `TOOLJET_HOST`, add a `A record` entry in your DNS settings to point to the IP address of the server.
|
||||
5. If you've set a custom domain for `TOOLJET_HOST`, add a `A record` entry in your DNS settings to point to the IP address of the server.
|
||||
|
||||
8. Seed the database:
|
||||
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="docker-auto-ssl-and-inbuilt-db" label="With auto SSL & in-built DB">
|
||||
|
||||
1. Download our production docker-compose file into the server.
|
||||
```bash
|
||||
curl -LO https://raw.githubusercontent.com/ToolJet/ToolJet/main/deploy/docker/docker-compose-ssl-db.yaml
|
||||
mv docker-compose-ssl-db.yaml docker-compose.yaml
|
||||
mkdir postgres_data
|
||||
```
|
||||
|
||||
2. Create `.env` file in the current directory (where the docker-compose.yaml file is downloaded):
|
||||
|
||||
```bash
|
||||
curl -LO https://raw.githubusercontent.com/ToolJet/ToolJet/main/deploy/docker/.env.example
|
||||
mv .env.example .env
|
||||
```
|
||||
|
||||
Set up environment variables in `.env` file as explained in [environment variables reference](/docs/setup/env-vars)
|
||||
|
||||
`TOOLJET_HOST` environment variable can either be the public ipv4 address of your server or a custom domain that you want to use.
|
||||
|
||||
:::info
|
||||
We use the [lets encrypt](https://letsencrypt.org/) plugin on top of nginx to create TLS certificates on the fly.
|
||||
And in case you want to modify the nginx config, you can use this [template](https://github.com/ToolJet/ToolJet/blob/develop/frontend/config/nginx.conf.template) and then mount the volume at `/etc/openresty/nginx.conf.template` on the client container.
|
||||
:::
|
||||
|
||||
Examples:
|
||||
`TOOLJET_HOST=http://12.34.56.78` or
|
||||
`TOOLJET_HOST=https://yourdomain.com` or
|
||||
`TOOLJET_HOST=https://tooljet.yourdomain.com`
|
||||
|
||||
:::info
|
||||
Please make sure that `TOOLJET_HOST` starts with either `http://` or `https://`
|
||||
:::
|
||||
|
||||
:::info
|
||||
If there are self signed HTTPS endpoints that Tooljet needs to connect to, please make sure that `NODE_EXTRA_CA_CERTS` environment variable is set to the absolute path containing the certificates.
|
||||
:::
|
||||
|
||||
3. Once you've populated the `.env` file, run
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
to start all the required services.
|
||||
|
||||
:::info
|
||||
If you're running on a linux server, `docker` might need sudo permissions. In that case you can either run:
|
||||
`sudo docker-compose up -d`
|
||||
OR
|
||||
Setup docker to run without root privileges by following the instructions written here https://docs.docker.com/engine/install/linux-postinstall/
|
||||
:::
|
||||
|
||||
4. If you've set a custom domain for `TOOLJET_HOST`, add a `A record` entry in your DNS settings to point to the IP address of the server.
|
||||
|
||||
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Creating admin workspace and account
|
||||
|
||||
```bash
|
||||
docker-compose exec server npm run db:seed:prod
|
||||
```
|
||||
|
||||
This seeds the database with a default user with the following credentials:
|
||||
- email: `dev@tooljet.io`
|
||||
- password: `password`
|
||||
- email: `dev@tooljet.io`
|
||||
- password: `password`
|
||||
|
||||
9. You're all done, ToolJet client would now be served at the URL you've set in `TOOLJET_HOST`.
|
||||
|
||||
:::caution
|
||||
Make sure that the server can receive traffic on port 80 & 443.
|
||||
For example, if the server is an AWS EC2 instance and the installation should receive traffic from the internet, the inbound rules of the security group should look like this:
|
||||
|
||||
| protocol | port | allowed_cidr |
|
||||
| -------- | ---- | ------------ |
|
||||
| tcp | 80 | 0.0.0.0/0 |
|
||||
| tcp | 443 | 0.0.0.0/0 |
|
||||
:::
|
||||
|
||||
You're all done! ToolJet would now be served at the URL you've set in `TOOLJET_HOST`.
|
||||
|
|
|
@ -232,3 +232,9 @@ This can be an absolute path, or relative to main HTML file.
|
|||
| variable | description |
|
||||
| ------------------ | ----------------------------------------------------------- |
|
||||
| ASSET_PATH | the asset path for the website ( eg: https://app.tooljet.com/) |
|
||||
|
||||
|
||||
#### Serve client as a server end-point ( optional )
|
||||
|
||||
By default the client build will be done to be served with ToolJet server.
|
||||
If you intend to use client separately then can set `SERVE_CLIENT` to `false`.
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<% if (process.env.NODE_ENV==='production' ) { %>
|
||||
<base href="__REPLACE_SUB_PATH__" />
|
||||
<% if (process.env.NODE_ENV === 'production' && process.env.SERVE_CLIENT !=='false' ) { %>
|
||||
<base href="__REPLACE_SUB_PATH__" />
|
||||
<% } else { %>
|
||||
<base href="/" />
|
||||
<base href="/" />
|
||||
<% } %>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
|
|
@ -126,6 +126,7 @@ module.exports = {
|
|||
new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /(en)$/),
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH),
|
||||
'process.env.SERVE_CLIENT': JSON.stringify(process.env.SERVE_CLIENT),
|
||||
}),
|
||||
],
|
||||
devServer: {
|
||||
|
|
Ładowanie…
Reference in New Issue