Hello!
I am going to run loraserver and lora-app-server in docker building them from source code.
I need it to continuously edit source code and deploy loraserver.
First I ran redis
, mosquitto
, postgres
and gatewaybridge
as docker containers using following docker-compose.yml
:
version: "2"
services:
gatewaybridge:
image: loraserver/lora-gateway-bridge:2
container_name: gatewaybridge_c
network_mode: bridge
ports:
- 1700:1700/udp
volumes:
- ./configuration/lora-gateway-bridge:/etc/lora-gateway-bridge
postgresql:
image: postgres:9.6-alpine
container_name: postgres_c
network_mode: bridge
ports:
- "5432:5432"
volumes:
- ./configuration/postgresql/initdb:/docker-entrypoint-initdb.d
- ./data/postgresql:/var/lib/postgresql/data
redis:
image: redis:4-alpine
container_name: redis_c
network_mode: bridge
ports:
- "6379:6379"
volumes:
- ./data/redis:/data
mosquitto:
image: eclipse-mosquitto
container_name: mosquitto_c
network_mode: bridge
ports:
- "1883:1883"
with configuration files taken from loraserver-docker
project on github
Seems that all is OK.
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5a19ad1c908a redis:4-alpine "docker-entrypoint.s…" 44 minutes ago Up 44 minutes 0.0.0.0:6379->6379/tcp redis_c
05224b5e4883 loraserver/lora-gateway-bridge:2 "./lora-gateway-brid…" 44 minutes ago Up 44 minutes 0.0.0.0:1700->1700/udp gatewaybridge_c
0ff1f9490766 eclipse-mosquitto "/docker-entrypoint.…" 44 minutes ago Up 44 minutes 0.0.0.0:1883->1883/tcp mosquitto_c
cd2cc9995e1a postgres:9.6-alpine "docker-entrypoint.s…" 44 minutes ago Up 44 minutes 0.0.0.0:5432->5432/tcp postgres_c
Then I checked availability of database containers from another container that I built using following compose file:
version: "2"
services:
ubuntu:
image: ubuntu
external_links:
- redis_c
network_mode: bridge
and I was able to ping redis’s container:
$ apt-get update
$ apt-get install redis-tools
$ env
REDIS_C_PORT_6379_TCP=tcp://172.17.0.4:6379
REDIS_C_PORT_6379_TCP_ADDR=172.17.0.4
REDIS_C_NAME=/tmp_ubuntu_run_3_9fdef705db3b/redis_c
REDIS_C_PORT_6379_TCP_PORT=6379
REDIS_C_PORT_6379_TCP_PROTO=tcp
REDIS_C_PORT=tcp://172.17.0.4:6379
$ redis-cli -h redis_c -p 6379
redis_c:6379> ping
PONG
But when I try to run loraserver
using following compose file:
version: "2"
services:
loraserver:
build:
context: .
dockerfile: Dockerfile-devel
command: make serve
volumes:
- ./:/go/src/github.com/brocaar/loraserver
external_links:
- postgres_c
- redis_c
- mosquitto_c
network_mode: bridge
environment:
- DB_AUTOMIGRATE=true
- NET_ID=010203
- BAND=EU_863_870
- REDIS_URL=redis://redis:6379
- GW_MQTT_SERVER=tcp://mosquitto:1883
- GW_SERVER_JWT_SECRET=verysecret
- POSTGRES_DSN=postgres://loraserver_ns:loraserver_ns@postgres/loraserver_ns?sslmode=disable
- TEST_POSTGRES_DSN=postgres://loraserver_ns:loraserver_ns@postgres/loraserver_ns?sslmode=disable
- TEST_REDIS_URL=redis://redis:6379
- TEST_MQTT_SERVER=tcp://mosquitto:1883
with loraserver.toml
placed in /etc/loraserver
I got some error about redis and postgresql servers IP resolving:
$ make dev-requirements
$ make requirements
$ make test
Generating static files
Running tests
...
Given a clean Redis database time="2018-11-17T18:45:38Z" level=fatal msg="redis connection error: dial tcp: lookup redis on 67.207.67.2:53: no such host"
FAIL github.com/brocaar/loraserver/internal/adr 0.032s
...
$ make build
$ ./build/loraserver
INFO[0000] starting LoRa Server band=EU_863_870 docs="https://docs.loraserver.io/" net_id=000000 version=2.3.0-2-g036a553
INFO[0000] setup redis connection pool url="redis://redis:6379"
INFO[0000] connecting to postgresql
ERRO[0000] ping database error, will retry in 2s: dial tcp: lookup postgresql on 67.207.67.2:53: no such host
Have no idea where does this IP is taken from.
But I am pretty sure that postgres
and redis
are accessible from loraserver container as their IP addresses resolved similar to test ubuntu
container. I placed loraserver.toml
file in expected directory but still without luck.
How to resolve this?
Maybe I forgot something?
I tried to do as described in documentation for this wonderful server.
Maybe there is easier way exist to build loraserver
and lora-app-server
from source code using docker? Cuz I don’t wont to run it on host and prefer to minimize amount of used databases (that’s why I ran it separately from loraserver and lora-app-server).