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:
You should see a log message like the following once the container has successfully started:
You can now send HTTP requests to the connector to verify it's working:
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:
Note that you should pick a password properly above.
To start a Redis cache, run:
You can verify the containers are running via:
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:
Or more conveniently, we can put all the same args into a file named connector.env
with the following contents:
and start the connector via:
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
can be set in an env file to docker like this:
For Spring properties that use yaml list like:
The equivalent env-file override would be:
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:
Or if using a ENV file, then add the following line to the file:
Last updated