May, 2019

Documentation System of Choice

May 29, 2019

Sphinx is a great system and it looks great. However, it is a bit too heavy for my needs and thus I have started using HUGO based solution, bucause I maintain another project using HUGO templates.

I currently use docdoc HUGO theme. It is not the best and it is used for this site, but it is one system less to remember.

NATS in Docker

May 29, 2019

The challenge of configuring a project is in the need to make a set of comprehansive changes. The following is a log of actions taken to configure NATS as a “try” level project.

For more see NATS Documentation

Docker composer is a great way to manage installation easily.

Create directory for docker-composer project, because it tracks images on per directory basis.

mkdir ~/projs/nats/
cd ~/projs/nats

We are going to use rmate to edit files on the target system.

Install rmate on docker host:

  1. Copy content of https://raw.githubusercontent.com/aurora/rmate/master/rmate file.

    cat > /tmp/rmate

Shift-Ins to paste copied content.

  1. Move created file:

    sudo mv /tmp/rmate /usr/local/bin/ sudo chmod +x /usr/local/bin/rmate

Install rmate in VSCode (remote extension). Start rmate in VSCode.

Close existing SSH session and reopen it with:

ssh -R 52698:127.0.0.1:52698 user@docker_host

Get back to the project location:

cd ~/projs/nats/

You can now edit files with command:

rmate file_name

If file_name does not exist, it will get created.

Edit docker-compose.yaml file:

rmate docker-compose.yaml

The configuration is based on nats image instructions. Check instructions for up-to-date information.

# Each server exposes multiple ports
# 4222 is for clients.
# 8222 is an HTTP management port for information reporting.
# 6222 is a routing port for clustering.

The following is an example content:

--- 
services: 
  nats_svc: 
    container_name: nats
    image: nats:latest
    ports:
      # "host:container"
      - "4222:4222"
      - "8222:8222"
      - "6222:6222"
    networks:
      - home
networks:
  home:
    external: true
version: "3.2"

If external network is missing create it with command

docker network create hoome

Create Makefile with command

cat > Makefile

and the following content:

f=docker-compose.yaml
name=nats

.PHONY: default create

create:
	docker-compose -f $(f) up -d

term:
	docker container stop $(name)
	docker container rm $(name)

This simplifies container creation and replacement to commands:

make create
make term

Test NATS web interface at:

http://hserv:8222/

where hserv is a hostname of the docker host machine.

There is also a NATS Streaming Docker Image.

New update.