Deployment
We are ready to deploy our app on your machine. It is paid service. Costs $ 200. One time payment. If you are interested, contact us by e-mail hi@corp.ymessenger.org
Preparation
Write to us the domain where your server will be located at hi@corp.ymessenger.org so that we add information about your server to the balancer and send you the identity of your server. This is necessary so that you can connect to your server using official applications.
Purchase or rent a server (even VPS will do).
Install Docker
Docker is a popular containerization system. It is necessary for rapid deployment of a server application. The following is a list of Docker installation commands from the official repository for Ubuntu 18.04.
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt install docker-ce
curl -s https://api.github.com/repos/docker/compose/releases/latest \
| grep browser_download_url \
| grep docker-compose-Linux-x86_64 \
| cut -d '"' -f 4 \
| wget -qi -
chmod +x docker-compose-Linux-x86_64
Additionally, install docker-compose according to the instructions from the official docker website: docs.docker.com/compose/install/
Find out the IP that Docker has taken
Run the command ip address | grep docker and remember the IP address of the Docker (after the word inet). Here it is 172.17.0.1. It will come in handy later.
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
Install Redis and PostgreSQL
The Y messenger server application uses Redis and PostgreSQL to store data. For best performance, it is recommended that you separate the application server and the database server. If your priority is to reduce the cost of system support as much as possible, then you can install everything on one server, but in this case the system performance decreases.
If you are not familiar with the Redis installation process, you can use this article: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-18−04-ru.
Open the Redis configuration file (/etc/redis/redis.conf) and fill in the bind line with the value of the Docker IP address.
bind 127.0.0.1 ::1 172.17.0.1
During the installation of PostgreSQL, you will need to create a separate role (DBMS user). We recommend using the built-in utility createuser. Create a user with the right to create databases.
For the server application to work with the database, you need to edit the pg_hba.conf file and allow the new user access from the network 172.16.238.0/24.
Replace {{USERNAME}} with your DBMS username. In this example, we allow the user to connect from any IP address. This is useful when deploying a server, but reduces database security. It is recommended that after starting the server application, limit the IP addresses that can connect to the database.
host    all     {{USERNAME}}      0.0.0.0/0 md5
Open the Postgresql configuration file (/etc/postgresql/10/main/postgresql.conf) and enable Postgres to listen to the Docker's IP address by changing the value of the listen_addresses directive as shown below.
listen_addresses = 'localhost,172.17.0.1'
Restart PostgreSQL and check the connectivity as shown below.
Replace {{USERNAME}} with your DBMS username.
sudo service postgresql restart
psql --username={{USERNAME}} --host=172.17.0.1 -W postgres
If everything is done correctly, you can connect to the DBMS. Create 3 databases: for user data, for blockchain and for control panel.
CREATE DATABASE ymess_db ENCODING 'UTF8'
CREATE DATABASE ymess_blockchain ENCODING 'UTF8'
CREATE DATABASE ymess_admin ENCODING 'UTF8'
This is the preparation of the DBMS, you can exit the terminal with the command \q
Data folder
The server application requires a ymessenger-data data directory in the root of the file system. This folder will contain all the files necessary for the normal functioning of the server application.
mkdir /ymessenger-data
Container launch file
Создайте текстовый файл docker-compose.yml в папке /ymessenger-data. В этом файле размещаются настройки контейнера серверного приложения.
version: '3.5'

services:

  web:
    container_name: 'ymessenger_node'
    image: 'index.docker.io/ymessenger/ymessenger'
    restart: always
    build:
      context: .
      dockerfile: ymessenger_node.dockerfile
    volumes:
      - /ymessenger-data:/var/www/ymessenger_node/Config
      - /ymessenger-data/LocalFileStorage:/var/www/ymessenger_node/LocalFileStorage
      - /ymessenger-data/logs:/var/www/ymessenger_node/Logs
      - /usr/bin/docker:/usr/bin/docker
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
     - "5000:5000"
     - "5001:5001"
     - "5002:5002"
     - "5555:5555"
     - "443:443"
     - "80:80"
    networks:
       ymessenger-network:
           ipv4_address: 172.16.238.10
    labels:
       com.centurylinklabs.watchtower.enable: "true"

  watchtower:
    image: containrrr/watchtower
    container_name: 'watchtower'
    ports:
      - "3443:3443"
      - "3080:3080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /root/.docker/config.json:/config.json
    command: --interval 60 --label-enable
    networks:
      - ymessenger-network

networks:
  ymessenger-network:
    name: ymessenger-network
    ipam:
       config:
        - subnet: "172.16.238.0/24"

Application configuration file
The application configuration file is a set of configuration parameters in a JSON file called appsettings.json. Below is an example file with the minimum required parameters. If you have a backup of this file, you can use it.
{{NODE_DOMAIN}} - the domain name on which the messenger server will be hosted. For example, messenger.example.com. The DNS server must have an A record with the IP address of the server.
{{EMAIL}} - the email address that will be used to send service letters, for example, sending a verification code for authorization by e-mail. The email server must be accessible via SMTP.
{{EMAIL_PASS}} - password from the email account.
{{EMAIL_SERVER}} - The domain name of the e-mail server.
{{EMAIL_PORT}} - port of the e-mail server.
{{DB_HOST}} - The IP address or domain of the PostgreSQL database server. If you installed exactly according to this instruction and the DBMS is located on the same server, then most likely there should be a value of 172.17.0.1.
{{DB_PORT}} - port for connecting to the PostgreSQL DBMS. The default is 5432.
{{DB_GENERAL}} - The name of the main database. The name ymess_db was used in this manual.
{{DB_USERNAME}} - DBMS username.
{{DB_PASSWORD}} - DBMS user password.
{{DB_BLOCKCHAIN}} - the name of the database for storing the blockchain. This manual used ymess_blockchain.
{{DB_ADMIN}} - the name of the database for storing control panel information. This manual used ymess_admin.
{{REDIS_HOST}} - The IP address or domain of the Redis server. If you installed exactly according to this instruction and the DBMS is located on the same server, then most likely there should be a value of 172.17.0.1.
{{REDIS_PORT}} - the port of the Redis server.
{{NODE_ID}} - server identifier. You receive it from us in response to a letter to hi@corp.ymessenger.org.
{{NODE_TAG}} is the tag of your server. Used for easy identification. You receive it from us in response to a letter to hi@corp.ymessenger.org.
{{NODE_COUNTRY_ISO}} - 3-letter ISO-code of the country of your server.
{{NODE_START_DATE}} - the date your server was launched in the format YYYY-MM-DDTCHH: MM: SS.
{{CERT_COUNTRY}} - The name of the country in English for the issuance of the SSL certificate.
{{CERT_LOCALITY}} - The 2-letter ISO code of the country for issuing the SSL certificate.
{{CERT_ORGANIZATION}} - The name of the organization in English for issuing the SSL certificate.
{{CERT_ORGANIZATION_UNIT}} - The name of the organization's unit in English for issuing the SSL certificate.
{{CERT_STATE}} - the name of the region of the country in English for issuing an SSL certificate.
{{NODE_PASSWORD}} - server password. This password will encrypt the data in the backups and it will be used to initialize the encryption component.
{
  "NodesUrls": [
    "{{NODE_DOMAIN}}"
  ],
  "SmtpClient": {
    "Email": "{{EMAIL}}",
    "Password": "{{EMAIL_PASS}}",
    "Host": "{{EMAIL_SERVER}}",
    "Port": "{{EMAIL_PORT}}"
  },
  "MessengerDbConnection": {
    "Host": "{{DB_HOST}}",
    "Port": {{DB_PORT}},
    "Database": "{{DB_GENERAL}}",
    "Username": "{{DB_USERNAME}}",
    "Password": "{{DB_PASSWORD}}"
  },
  "BlockchainDbConnection": {
    "Host": "{{DB_HOST}}",
    "Port": {{DB_PORT}},
    "Database": "{{DB_BLOCKCHAIN}}",
    "Username": "{{DB_USERNAME}}",
    "Password": "{{DB_PASSWORD}}"
  },
  "AdminDbConnection": {
    "Host": "{{DB_HOST}}",
    "Port": {{DB_PORT}},
    "Database": "{{DB_ADMIN}}",
    "Username": "{{DB_USERNAME}}",
    "Password": "{{DB_PASSWORD}}"
  },
  "CacheServerConnection": {
    "Host": "{{REDIS_HOST}}",
    "Port": {{REDIS_PORT}}
  },
  "Node": {
    "Id": {{NODE_ID}},
    "Name": "",
    "Tag": "{{NODE_TAG}}",
    "About": "",
    "Country": "{{NODE_COUNTRY_ISO}}",
    "StartDay": "{{NODE_START_DATE}}",
    "Domains": [
      "{{NODE_DOMAIN}}"
    ],
    "ClientsPort": 5000,
    "NodesPort": 5002,
    "Visible": true,
    "Storage": true,
    "Routing": true,
    "EncryptionType": 1,
    "PermanentlyDeleting": false,
    "RegistrationMethod": 2
  },
  "Certificate": {
    "Email": "{{EMAIL}}",
    "CountryName": "{{CERT_COUNTRY}}",
    "Locality": "{{CERT_LOCALITY}}",
    "Organization": "{{CERT_ORGANIZATION}}",
    "OrganizationUnit": "{{CERT_ORGANIZATION_UNIT}}",
    "State": "{{CERT_STATE}}",
    "Domain": "{{NODE_DOMAIN}}"
  },
  "NotificationServerURL": "https://testlic-1.ymess.org:5003",
  "LicensorUrl": "testlic-1.ymess.org:5005",
  "Password": "{{NODE_PASSWORD}}",
  "MaxDbBackups": 5,
  "ConfirmUsers": false,
  "AllowedRegistration": true,
  "RecoveryMode": true,
  "S3FileStorageOptions": {},
  "SmsServiceConfiguration": {}
}
We have assigned default values to some fields. You can change them later from the control panel interface.
Server start
Run these commands so that your server downloads the current version of the application and launches it.
cd /ymessenger-data
docker-compose pull && docker-compose up -d
Launch check
Run the docker container ls command, find the line where the NAMES column is ymessenger_node, and look at the value of the STATUS column. It must contain the text Up
If the container with the name ymessenger_node is in a status other than Up, then most likely something is configured incorrectly. View the contents of the /ymessenger-data/logs folder for more information. Contact us at hi@corp.ymessenger.org for advice.
docker container ls
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                                                                                                NAMES
7e1252e1b940        containrrr/watchtower   "/watchtower --inter…"   47 seconds ago      Up 45 seconds       0.0.0.0:3080->3080/tcp, 0.0.0.0:3443->3443/tcp                                                       watchtower
4f363defcc5d        ymessenger/ymessenger   "/bin/bash -c ./Node…"   47 seconds ago      Up 44 seconds       0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:5000-5002->5000-5002/tcp, 0.0.0.0:5555->5555/tcp   ymessenger_node
After a few minutes, try going to the address http://your_domain:5555/Dashboard. If everything is configured correctly, you will see the interface for logging in the control panel of your server.
Since there is currently no administrator in your server, register by clicking on the "Register" link. On the page that opens, enter your data. A letter will be sent to the indicated mail with a confirmation link. Follow the link received.
Now you need to disable this registration of administrators. Other server administrators will need to be created in the control panel. Open the /ymessenger-data/appsettings.json file and change the AllowedRegistration key to false.
{
...
  "AllowedRegistration": false,
...
}
Congratulations! Your server has been successfully launched and is working, you can already use it! Further settings are available in the server control panel.
Our server application is updated automatically. You may be required to conduct scheduled updates to the server operating system components. Because we do not have access to your server, we cannot do this for our part.