Running with Docker
Running with Docker

Prerequisites

  • Docker must be installed and running.

Starting a connector (using in-memory database and in-memory Redis)

The connector requires a SQL database and Redis to run. By default, the docker image will run using an in-memory H2 database and in-memory Redis cache. This mode is intended to quickly get a connector up and running but all data will be lost on container restarts. As such, this mode should not be used for any real world applications.
To start the latest nightly image of the java-ilpv4-connector in an interactive terminal, run:
1
docker run -p 8080:8080 -it interledger4j/java-ilpv4-connector:nightly
Copied!
You should see a log message like the following once the container has successfully started:
1
Started ConnectorApplication in 6.912 seconds
Copied!
You can now send HTTP requests to the connector to verify it's working:
1
curl http://localhost:8080/accounts -H 'Authorization: Basic YWRtaW46cGFzc3dvcmQ='
Copied!

Starting a connector (using external Postgres database and external Redis)

This mode requires having a Postgres database and Redis cache already running. This mode allows the java-ilpv4-connector to be restarted without loss of data (so long as the Postgres database and Redis cache are not lost).

Running Postgres and Redis in docker

If you already have a Postgres database and Redis cache running, skip this section. Otherwise, we'll start up a Postgres container and Redis container in docker.
To start a Postgres database, run:
1
docker run --name connector-postgres -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_DB=connector -d postgres
Copied!
Note that you should pick a password properly above.
To start a Redis cache, run:
1
docker run -d -p 6379:6379 redis
Copied!
You can verify the containers are running via:
1
docker ps
Copied!

Configuring java-ilpv4-connector to connect to external Postgres and Redis instances:

The docker container needs to be configured with the postgres and redis connection details. This is done by passing environment variables in the docker run command. Docker supports passing each environment variable as a separate argument or by providing a env file that contains environment variable mappings.
For example, here is how to configure and run the connector using separate env args:
1
docker run -p 8080:8080 -e spring.profiles.active=insecure,postgres,migrate -e redis.host=host.docker.internal -e spring.datasource.url=jdbc:postgresql://host.docker.internal:5432/connector -e spring.datasource.username=postgres -e spring.datasource.password=postgres -it interledger4j/java-ilpv4-connector:nightly
Copied!
Or more conveniently, we can put all the same args into a file named connector.env with the following contents:
1
spring.profiles.active=insecure,postgres,migrate
2
redis.host=host.docker.internal
3
spring.datasource.url=jdbc:postgresql://host.docker.internal:5432/connector
4
spring.datasource.username=postgres
5
spring.datasource.password=postgres
Copied!
and start the connector via:
1
docker run -p 8080:8080 --env-file ~/connector.env -it interledger4j/java-ilpv4-connector:nightly
Copied!

Configuration flags available via docker

java-ilpv4-connector uses Spring Boot for external configuration. Spring properties specific to the java-ilpv4-connector can be found under Connector Configuration Properties. Spring makes it easy to set/override a Spring property via environment variables. For example, a Spring property specified via yaml configuration like this
1
interledger:
2
connector:
3
nodeIlpAddress: test.xpring-dev.java1
Copied!
can be set in an env file to docker like this:
1
interledger.connector.nodeIlpAddress=test.xpring-dev.java1
Copied!
For Spring properties that use yaml list like:
1
interledger:
2
globalRoutingSettings:
3
staticRoutes:
4
- targetPrefix: test.connie.alice
5
peerAccountId: alice
Copied!
The equivalent env-file override would be:
1
interledger.connector.globalRoutingSettings.staticRoutes.0.targetPrefix=test.connie.alice
2
interledger.connector.globalRoutingSettings.staticRoutes.0.peerAccountId=alice
Copied!

Configuring Java VM options with docker

Java JVM options can be configured by setting the docker environment variable _JAVA_OPTIONS
For example, to configure the Java VM with a 512mb max heap and G1 garbage collector:
1
docker run -e _JAVA_OPTIONS="-XX:+UseG1GC -Xmx512m" -p 8080:8080 -it interledger4j/java-ilpv4-connector:nhartner
Copied!
Or if using a ENV file, then add the following line to the file:
1
_JAVA_OPTIONS=-XX:+UseG1GC -Xmx512m
Copied!
Last modified 1yr ago