Install Centos

Install ApiDQ application #

Install docker #

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo
sudo yum install docker-ce docker-ce-cli
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
sudo systemctl start docker
sudo groupadd docker
sudo usermod -aG docker $USER

Log out and log back in so that your group membership is re-evaluated.

If testing on a virtual machine, it may be necessary to restart the virtual machine for changes to take effect.

Install docker-compose #

sudo curl -L "$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Install postgresql #

sudo yum install epel-release
sudo yum install
sudo yum -y install postgresql13 postgresql13-server postgresql13-contrib
sudo /usr/bin/postgresql-13-setup initdb
sudo systemctl enable postgresql-13
sudo systemctl start postgresql-13

Create database and user #

db_apidq - database name
user_apidq - database user
p_a_s_s_w_o_r_d - user password

sudo -u postgres createdb db_apidq
sudo -i -u postgres psql db_apidq -c "CREATE ROLE user_apidq WITH LOGIN PASSWORD 'p_a_s_s_w_o_r_d' SUPERUSER;"
sudo -i -u postgres psql db_apidq -c "GRANT ALL PRIVILEGES ON DATABASE db_apidq TO user_apidq;"
sudo -i -u postgres psql db_apidq -c 'CREATE EXTENSION hstore;'
sudo -i -u postgres psql db_apidq -c 'CREATE EXTENSION pg_trgm;'

Setting database server #

Edit the file /var/lib/pgsql/13/data/postgresql.conf and set Listen address to your server IP address or “*” for all interfaces.

sudo vi /var/lib/pgsql/13/data/postgresql.conf
# line 59
listen_addresses = '*'

Also set PostgreSQL to accept remote connections

sudo vi /var/lib/pgsql/13/data/pg_hba.conf
# Accept from anywhere (not recommended)
host all all md5

Restart the database service after saving the changes.

sudo systemctl restart postgresql-13

Download and install dictionaries #

Create new dir

mkdir apidq

cd apidq

All dictionaries can be downloaded from the SFTP server Connect to the SFTP server

sftp -P65110

Password Nieawx3tpqKF

After connecting, you will see the dictionaries available to you and their versions.

sftp> ls
ru        services
sftp> ls services
services/services_20210831.dump  services/services_20210920.dump

sftp> ls ru
ru/ru_20210801.dump   ru/ru_20210920.dump   ru/ru_20211012.dump

Download the dictionaries you need

sftp> get services/services_20210920.dump
sftp> get ru/ru_20210920.dump

Close connection with SFTP server


Restore dictionaries from dumps

 pg_restore --no-owner --no-acl -Fc -U user_apidq -h -d db_apidq services_20210920.dump
 pg_restore --no-owner --no-acl -Fc -U user_apidq -h -d db_apidq ru_20210920.dump

Connect to ApiShip Docker Registry #

Run this command to download the current stable release of Docker Compose

docker login

Username: honor - login to access the GitLab server
Password: sHdVj57ogNc_AKmUBDEX - password to access the GitLab server

Creating of configuration files #

Create address-config.toml file with content

ListenAddr = "" #  ip address where the address service will be available 
ListenPort = "8083" #  port where the address service will be available 
Debug = false
Facility = "service-address"
Address = "host.docker.internal" #  ip postgresql server
Port = "5432" #  port postgresql server
Dbname = "db_apidq" #  apidq database
User = "user_apidq"
Password = "p_a_s_s_w_o_r_d"

Create gateway-config.toml file with content

ListenAddr = "" #  ip address where service will be available 
ListenPort = "8080" #  port where service will be available 
ReadTimeout = 60000
WriteTimeout = 60000
Debug = false
Facility = "service-gateway"
Enabled = true
EndpointAddr = "address" #  ip address or host  service from address-config.toml
EndpointPort = "8083" #  port service from address-config.toml

Create docker-compose.yaml file with content

version: "3.0"
    image: ""
      - "8080:8080"
      - ./gateway-config.toml:/dist/config.toml
    image: ""
      - ./address-config.toml:/dist/config.toml
      - "host.docker.internal:"

Run and check application #

docker-compose up -d

Check clean/address (address standardization)

curl -X POST -H "Content-Type: application/json" -d '{"query": "котлас кузнецова 14в 132", "countryCode": "RU"}'