GridGain Developers Hub

Docker Deployment

Deploying GridGain Web Console with Docker.

Overview

In order to use GridGain Web Console in a private corporate network, it should be deployed within that network. The easiest way to do this is to use Docker images.

Prerequisites

  • Register an account on Docker Hub.

  • Create a folder where you will be deploying GridGain Web Console and open this folder in the terminal.

  • Sign in to Docker Hub from the terminal window.

    # add current user to docker group if required:
    sudo usermod -aG docker $(whoami)
    
    # logout/login might be required to apply changes
    
    docker login -u your_docker_hub_account -p your_docker_hub_password
  • Web Console uses docker-compose to deploy its components. Compose is included by default in most Docker installations. Additional information on installing and configuring Compose can be found in the component installation documentation

Starting the Web Agent

To establish a connection between the Ignite/GridGain cluster and the web console, you will need to first configure and start Web Agent. Here is how to do this:

  1. Start a node with REST server mode enabled. Move the ignite-rest-http folder from {gridgain_dir}/libs/optional/ to {gridgain_dir}/lib/, or if you start the node from an IDE then add the dependency below to your POM xml file.

    <dependency>
        <groupId>org.apache.ignite</groupId>
        <artifactId>ignite-rest-http</artifactId>
        <version>{ignite.version}</version>
    </dependency>
  2. In the default.properties file located in the gridgain-web-console-agent-2021.04.00 directory, configure the Web Agent’s serverURI property to refer to the GridGain node’s REST server URI. By default, the agent connects to http://localhost:8080. Web Agent attempts to load configuration settings from the default.properties file. See the Web Agent Configuration page for the list of supported properties.

    tokens=1a2b3c4d5f,2j1s134d12
    serverURI=https://console.example.com:8008
  3. In the terminal, start the web agent from the GridGain web agent directory using the web-console-agent.{sh|bat} script, like so:

    $ ./web-console-agent.sh
    $ web-console-agent.bat

Docker Based Deployment

The easiest way to deploy Web Console is to deploy through Docker. This can be setup quickly through a docker compose file. Docker compose will pull the Web Console backend and frontend images from DockerHub, launch each container, and configure ports. Create docker-compose.yml in the folder where GridGain Web Console will be deployed. A sample 'docker-compose.yml' can be found below.

version: '2.4'
services:
  backend:
    image: gridgain/gridgain-web-console-backend:2021.04.00
    # Restart on crash.
    restart: always
    environment:
      # Mail settings
      #- SPRING_MAIL_HOST=
      #- SPRING_MAIL_PORT=
      #- SPRING_MAIL_USERNAME=
      #- SPRING_MAIL_PASSWORD=
      - JVM_OPTS=

    volumes:
      - ${PWD}/work:/opt/gridgain-web-console-server/work

  frontend:
    image: gridgain/gridgain-web-console-frontend:2021.04.00
    ports:
      # Proxy HTTP nginx port (HOST_PORT:DOCKER_PORT)
      - 80:8008

When creating the compose file by hand, set the value of image: gridgain/gridgain-web-console-frontend to match the version of the Web Console release. For example, image: gridgain/gridgain-web-console-frontend:8.8.0

Alter other properties in the environment or other sections of the file, if needed (for example, you may want to configure the mail settings).

In the terminal window, execute the following command to run GridGain Web Console. Docker will pull the image and start GridGain Web Console in the background.

sudo docker-compose up -d

Open http://localhost:8008 in a browser, and register the first user. Admin rights will be granted to the first registered user.

Console Updates

In order to update GridGain Web Console, it should be stopped and the old containers should be removed.

docker-compose stop
docker-compose rm
docker-compose pull
docker-compose up -d

To store user data, an external volume should be used (see the "volumes" section in docker-compose.yml).

Useful Commands

# To stop docker containers:
docker-compose stop

# To start docker containers:
docker-compose start

# To view logs:
docker-compose logs

# To delete docker containers:
docker-compose rm

Docker Per Image Deployment

Run Backend for GridGain Web Console

In the terminal, execute the following command to run the backend in docker container.

docker run -d -it --name console_backend  -v <database-data>/work:/opt/gridgain-web-console-server/work gridgain/gridgain-web-console-backend

Run Frontend for GridGain Web Console

In the terminal, execute the following command to run frontend in docker container.

docker run -d --name=console_frontend -p 80:80/tcp --link console_backend:backend gridgain/gridgain-web-console-frontend

Open http://localhost in a browser, and register the first user. Admin rights will be granted to the first registered user.

How to Add HTTPS to Your Web Console

After you have downloaded the Web Console docker frontend and backend:

  1. Create a docker-compose.yaml file with the following content:

    version: '2.4'
    services:
      backend:
        image: gridgain/gridgain-web-console-backend:2021.04.00
        # Restart on crash.
        restart: always
        environment:
          # Mail settings. Please uncomment and supply mail settings values
          #- SPRING_MAIL_HOST=
          #- SPRING_MAIL_PORT=
          #- SPRING_MAIL_USERNAME=
          #- SPRING_MAIL_PASSWORD=
          - JVM_OPTS=
    
        volumes:
          - ${PWD}/work:/opt/gridgain-web-console-server/work
    
      frontend:
        image: gridgain/gridgain-web-console-frontend:2021.04.00
        volumes:
          - ${PWD}/web-console.conf:/etc/nginx/web-console.conf
          - ${PWD}/server.crt:/etc/nginx/server.crt
          - ${PWD}/server.nopass.key:/etc/nginx/server.nopass.key
        ports:
          # Proxy HTTP nginx port (HOST_PORT:DOCKER_PORT)
          - 80:8008
          - 443:8443
  2. Update the docker images tag to reflect the version you downloaded.

  3. Create a web-console.conf file with the following content:

    upstream backend-endpoint {
        server backend:3000;
    }
    
    server {
       listen 8008 default_server;
       listen [::]:8008 default_server;
       server_name _;
       return 301 https://$host$request_uri;
    }
    
    server {
        set $ignite_console_dir /data/www;
    
        listen 8443 ssl;
        server_name localhost;
        ssl_certificate         /etc/nginx/server.crt;
        ssl_certificate_key     /etc/nginx/server.nopass.key;
    
        # Enable Mutual SSL if disabled https will be used.
        #ssl_verify_client       on;
    
        ssl_protocols       TLSv1.2;
        ssl_ciphers         HIGH:!aNULL:!MD5;
    
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
        add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; script-src-elem 'self'; worker-src 'self' blob:; style-src https://fonts.googleapis.com 'self' 'unsafe-inline'; style-src-elem https://fonts.googleapis.com 'self' 'unsafe-inline'; font-src https://fonts.gstatic.com 'self'; connect-src * ws: wss:; img-src 'self'";
        add_header X-Frame-Options SAMEORIGIN;
        add_header X-Content-Type-Options nosniff;
        add_header Referrer-Policy no-referrer;
        add_header Feature-Policy "geolocation 'none';midi 'none';sync-xhr 'none';microphone 'none';camera 'none';magnetometer 'none';gyroscope 'none';speaker 'self';fullscreen 'self';payment 'none';";
    
        root $ignite_console_dir;
        error_page 500 502 503 504 /50x.html;
    
        location / {
            try_files $uri /index.html = 404;
        }
    
        location /api/v1 {
            proxy_pass http://backend-endpoint;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Host $http_host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass_header X-XSRF-TOKEN;
        }
    
        location /browsers {
            proxy_pass http://backend-endpoint;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Origin http://backend-endpoint;
            proxy_pass_header X-XSRF-TOKEN;
        }
    
        location /agents {
            proxy_pass http://backend-endpoint;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Origin http://backend-endpoint;
        }
    
        location = /50x.html {
            root $ignite_console_dir/error_page;
        }
    }
  4. Generate your certificates: server.crt, server.key.

  5. Start the Web Console:

    docker compose up