Install Centos

Install ApiDQ application #

Install docker #

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io
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 "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(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 https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
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 0.0.0.0/0 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 storage.apidq.io Connect to the SFTP server

sftp -P65110 honor@storage.apidq.io

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

exit

Restore dictionaries from dumps

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

Connect to ApiShip Docker Registry #

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

export DOCKER_REGISTRY=gitlab.apiship.ru:5050/apidq/apidq
docker login gitlab.apiship.ru:5050

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

[main]
ListenAddr = "0.0.0.0" #  ip address where the address service will be available 
ListenPort = "8083" #  port where the address service will be available 
Debug = false
[logger]
Facility = "service-address"
[postgresql]
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

[main]
ListenAddr = "0.0.0.0" #  ip address where service will be available 
ListenPort = "8080" #  port where service will be available 
ReadTimeout = 60000
WriteTimeout = 60000
Debug = false
[logger]
Facility = "service-gateway"
[addressService]
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"
services:
  gateway:
    image: "gitlab.apiship.ru:5050/apidq/apidq/apidq-service-gateway:1.2.0"
    ports:
      - "8080:8080"
    volumes:
      - ./gateway-config.toml:/dist/config.toml
  address:
    image: "gitlab.apiship.ru:5050/apidq/apidq/apidq-service-address:1.2.0"
    volumes:
      - ./address-config.toml:/dist/config.toml
    extra_hosts:
      - "host.docker.internal:172.17.0.1"

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"}' http://0.0.0.0:8080/api/v1/clean/address