# Installation

You can easily run Hicore server on Docker by following these steps

# Install Docker

You can run the server simply by using Docker but before that, make sure you were installed docker and docker-compose. if you have installed docker you can skip this part and go to Install The Hicore Server.

# Linux

# Step 1: Update Software Repositories For Installing Docker

It’s a good idea to update the local database of software to make sure you’ve got access to the latest revisions.

Open a terminal window and type:

sudo apt-get update

# Step 2: Uninstall Old Versions of Docker

Next, it’s recommended to uninstall any old Docker software before proceeding.

Use the command:

sudo apt-get remove docker docker-engine docker.io

# Step 3: Install Docker

To install Docker on Ubuntu, in the terminal window enter the command:

sudo apt install docker.io

# Step 4: Start and Automate Docker

The Docker service needs to be setup to run at startup. To do so, type in each command followed by enter:

sudo systemctl start docker
sudo systemctl enable docker

# Install Docker Compose

Installing docker-compose requires only a single step. Execute the bellow apt command:

 sudo apt install docker-compose

# Install The Hicore Server

# Step 1: Clone Project

For deploying server you should first clone the repository from Github for doing this in the terminal window enter the command:

 git clone https://github.com/hicore/hicore.git

# Step 2: Change Docker Compose File

change docker-compose file. go to the project directory and open docker-compose.yml file and change the variable's as your needs.

version: '3'
services:
  mongo:
    image: mongo:latest
    environment:
      - MONGO_INITDB_ROOT_USERNAME=admin
      - MONGO_INITDB_ROOT_PASSWORD=password
  mothership:
    build: .
    ports:
      - '7192:7192'
    environment:
      - DB_NAME=hicore
      - DB_HOST=mongo
      - DB_USERNAME=admin
      - DB_PASSWORD=password
      - SERVER_PORT=7192
    restart: always
    depends_on:
      - mongo
  child:
    build: ./childServer
    ports:
      - '7100:7100/udp'
    environment:
      - CHILD_PORT=7100
      - MOTHERSHIP_HOST=mothership
      - MOTHERSHIP_PORT=7192
    restart: always
    depends_on:
      - mothership
    command: sh -c "/usr/wait-for-it.sh --timeout=0 mothership:7192 && ./out/child"

# Mongo Config

Key Description
MONGO_INITDB_ROOT_USERNAME mongodb username
MONGO_INITDB_ROOT_PASSWORD mongodb password

# Hicore Mothership Server Config

Key Description
DB_NAME database name
DB_HOST host name for connecting to mongodb
DB_USERNAME mongodb username is the same as MONGO_INITDB_ROOT_USERNAME
DB_PASSWORD mongodb password is the same as MONGO_INITDB_ROOT_PASSWORD
DB_PORT mongodb port. default is 27017
SERVER_PORT mothership server port. default is 7192
SOCKET_KEY mothership server socket key. default is defaultKey
CHILD_SERVER_KEY child server key . default is defaultChildServerKey

# Hicore Child Server Config

Key Description
MOTHERSHIP_HOST host name to connect mothership server
MOTHERSHIP_PORT port number to connect mothership server
MOTHERSHIP_SOCKET_KEY mothership socket key is the same as SOCKET_KEY
CHILD_PORT child server port. default is 7100
CHILD_SERVER_KEY child server key same as CHILD_SERVER_KEY in mothership config
CHILD_SERVER_LOCATION your server location(optional)
CHILD_SERVER_CODE your server code(optional)
CHILD_SERVER_ID your server id(optional)

# Step 3: Run Docker Compose

After changing variables, you can simply build Docker container by using this command:

 docker-compose up --build

In this stage Docker starts creating container and then the server is ready to use and Hicore runs on your machine. you can connect to the Mothership Server at localhost:7192 and connect to the Child Server at localhost:7100

in case of changing the docker-compose file, make sure that stop container at first using this commend:

docker-compose down -v

And after that call this command again:

 docker-compose up --build

WARNING

In production, change keys in keys folder

DANGER

If you want to change your configuration and build a container again you lose all your data