How to execute Platform with docker and docker-compose?
- 1 Introduction
- 2 Pre-requirements:
- 3 Deploy
Introduction
To deploy onesait Platform Community, we must consider the following pre-requirements:
If you prefer a videotutorial you can watch this:
https://www.youtube.com/watch?time_continue=5&v=ZcLdEhI5Lfg
Pre-requirements:
1- Have Docker, Community Edition installed
https://docs.docker.com/install/
2- Have Docker compose installed
https://docs.docker.com/compose/install/
Once Docker is installed, for Windows or MacOS environments, we must increase the memory allocated to the Docker service. We recommend at least 8 GB of memory and 2 GB of swap.
3- Have Docker File Sharing configured propperly (only Windows)
Docker for windows needs to set pc user credentials to access file system for container volume mapping.
It can be setted on Settings>Reset Credentials.
Once the requirements are satisfied, it is possible to deploy the platform.
Deploy
Step 1: Download docker-compose's files to launch the platform's services
These files, in yml format, are in the platform's repository in GitHub. To do it, you need to clone the repository locally, then place yourself in the master branch.
> git clone https://github.com/onesaitplatform/onesait-cloud-platform-community-deploy.git
> cd onesait-cloud-platform-community-deploy
> git fetch origin master
> git checkout master
Step 2: Launch the persistence services
Place yourself in the same directory as the docker-compose.yml, in charge of launching the database services, is.
cd onesait-cloud-platform-community-deploy/op_data
You can see several files in that directory:
/.env
Check that the keys have the following values:
keu | value |
---|---|
REPOSITORY | |
PERSISTENCE_TAG | mariadb |
MODULE_TAG | 2.0.0-ce (or the proper version) |
MONGO_TAG | 6.0-noauth |
QUASAR_TAG | 14 (not neccesary after 5.0.0-ce) |
/docker-compose.yml: if we want to launch the databases without persistence, then we run from a terminal the following command, from the same directory that the file is:
> docker-compose up -d
IMPORTANT: If the databases are launched ephemerally, when the services with docker-compose down are stopped, we will lose all the data.
/docker-compose.persistent.yml: if you want to persist the databases, then you must write in the .env file the directories of your machine where you want the data to be stored. There is no default assigned value. As an example, you can use:
key | example value |
---|---|
REALTIME_VOLUME | /Users/devopsuser/realtimedbdata |
CONFIGDB_VOLUME | /Users/devopsuser/configdbdata |
From the terminal, run the following command:
Once the databases have been launched, you can see the status of each with the following command:
You should see an output like this one:
If you want to see a database container log, you run:
Step 3: Populate the databases with data
In that same directory (onesait-cloud-platform-community-deploy/op_data), there is another docker-compose file, in charge of launching the initial data load service.
In case you are using the machine's hostname, you should replace 'localhost' in SERVER_NAME variable at docker-compose.yml by your machine's hostname.
As you did previously, you can run:
In this case you do not include the -d flag (detached mode) because the service stops on its own once its task is over.
It should be executed again to fill the realtimedb, changing in docker-compose.initdb.yml the variable LOADMONGODB=true.
Step 4: Launch the platform's modules
Same as we did with the persistence services, we launch the platform's different modules with docker-compose, ordered by start-up and in the directory onesait-cloud-platform-community-deploy/op-modules:
Path | Module | DBs up required | Modules up required |
---|---|---|---|
/control-panel | Platform's web console. | configdb, schedulerdb, realtimedb, quasar |
|
/webprojects | Platform web hosting | configdb, schedulerdb, realtimedb, quasar | controlpanel |
/keycloak (mandatory after 6.0.0-ce) | Authentication server | configdb, schedulerdb, realtimedb, quasar | controlpanel |
/keycloak-manager (mandatory after 6.0.0-ce) | Authentication server | configdb, schedulerdb, realtimedb, quasar | controlpanel, keycloak |
/cacheserver | Cache server | configdb, schedulerdb, realtimedb, quasar | controlpanel |
/iotbroker | Platform's IoT broker. | configdb, schedulerdb, realtimedb, quasar | controlpanel, router, cacheserver |
/flowengine | Platform's Flow engine. | configdb, schedulerdb, realtimedb, quasar | controlpanel, router, cacheserver |
/api-manager | API Manager Module. | configdb, schedulerdb, realtimedb, quasar | controlpanel, router, cacheserver, iotbroker |
/oauth-server (deprecated after 6.0.0-ce) | Authentication server | configdb, schedulerdb, realtimedb, quasar | controlpanel, router, cacheserver, |
/notebooks | Notebooks module | configdb, schedulerdb, realtimedb, quasar | controlpanel, router, cacheserver, iotbroker |
/dashboard-engine | Dashboard module | configdb, schedulerdb, realtimedb, quasar | controlpanel, router, cacheserver, iotbroker |
/rules-engine | Rules engine module | configdb, schedulerdb, realtimedb, quasar | controlpanel, router, cacheserver |
/dataflow | Dataflow module | configdb, schedulerdb, realtimedb, quasar | controlpanel, router, cacheserver, iotbroker |
/devicesimulator | Device simulator module | configdb, schedulerdb, realtimedb, quasar | controlpanel, router, cacheserver, iotbroker |
/digitaltwinbroker | Digital twin broker module | configdb, schedulerdb, realtimedb, quasar | controlpanel, router, cacheserver, iotbroker |
/monitoringui | Monitoring UI module | configdb, schedulerdb, realtimedb, quasar | controlpanel, router, cacheserver, iotbroker |
Each file contains:
/.env file with the following environment variables:
key | value | description |
---|---|---|
REPOSITORY | a registry containing the service's image. | |
SERVERNAME | localhost | host machine's hostname |
MODULE_TAG | 2.0.0-ce | service image tag. |
docker-compose.yml file, containing the service's description, volume mapping, ports, subnets, etc.
In case you are using the machine's hostname, you should replace 'localhost' in SERVER_NAME (or SERVERNAME in case of flowengine) variable at docker-compose.yml by your machine's hostname.
To launch each of these modules, you must, from the command line, reach the module's directory and execute the command:
For example in order to execute Control Panel go to op-modules/control-panel and execute >docker-compose up -d
Step 5: Launch the inverse proxy service (NGINX)
We go to the folder onesait-cloud-platform-community-deploy/op-modules/nginx-proxy in order to launch a container with the NGINX service. It has mapped a volume with the configuration file needed to re-direct incoming requests that reach the control panel (nginx.conf).
If you need to launch any other modules, you just have to docker-compose up -d in the module's folder and uncomment the line in nginx.conf.
You must edit nginx.conf and replace the string ${SERVER_NAME} with the Docker host machine's hostname. You can find it from the command line by executing the command "hostname" or localhost.
nginx.conf before set SERVER_NAME
nginx.conf after set SERVER_NAME
It is needed to generate ssl certificates using script generate-certificates.sh
generate-certificates.sh
It is needed to set up some variables inside the script.
generate-certificates.sh variables
The ./tls folder will be generated, then you can install the certificates in the host. This folder will be mapped to the container.
Starting in 6.0.0-ce version, keycloak and keycloak-manager modules must be up and running in order to log into the Platform. When running keycloak-manager, keycloak and control panel must be up and running previously.
Once edited, you launch the service as you have done previously with other services. From the directory /nginx-proxy, execute:
And you can access the control panel by writing the following URL in the web browser: https://<hostname>/controlpanel
You can access with these users/passwords:
administrator/Community2019!
developer/Community2019!
analytics/Community2019!
Example: Launching other module
To provide a complete example, we show how to launch dashboardengine module:
Commands to run necessary containers (from op_moules folder)
Uncomment line in ./op_modules/nginx-proxy/nginx.conf for the modules up (you can copy - paste and replace {SERVER_NAME})
nginx.conf for dashboardengine
Then we rebuild the proxy module to reload changes:
Once done you can use dashboard module in controlpanel!