Docker Compose Setup

The Apiwallet can be ran using docker-compose. For information about docker see docker.com The docker image strawpay/apiwallet is available on dockerhub. The image exposes port 9000. You will need an auth token from Strawpay, see Quick Start for how to obtain one. In the following replace <my-auth> with your auth token.

Warning Ensure that you wallet files are stored outside the container, in the example below we use a docker volume.

By default docker-compose will use the enclosing directory name as a prefix for all created docker resources. The name is arbitrary, here we use apiwallet.

mkdir apiwallet
cd apiwallet

Create docker-compose.yaml containing

# docker-compose.yaml
version: '2'
services:
  apiwallet:
    image: strawpay/apiwallet
    ports:
      - 9000:9000
    volumes:
      - wallets:/var/wallets 
    environment:
      - ISSUER_AUTH=<my-auth>
    depends_on:
      - chown-wallets

# Note, we must change the owner of the wallets volumes since apiwallet run with user daemon(2)
# and docker volumes are created write only for root.
  chown-wallets:
    image: alpine
    volumes:
      - wallets:/var/wallets
    command: "chown daemon:daemon /var/wallets"

volumes:
  wallets:

Then run:

docker-compose up -d

Verify with

docker-compose ps

View the logs with

docker-compose logs [-f]

Configuration

The wallet can be configured with command overrides, environment variables and/or a configuration file. In the following examples we will configure the issuer auth with the value <my-auth> in different ways. For more information about the configuration see Configuration. In all cases we modify the docker-compose.yaml file

Command Overrides

Change the apiwallet service to

apiwallet:
  image: strawpay/apiwallet
  command: -Dapiwallet.stroem.issuer.auth=<my-auth>
  ports:
    - 9000:9000
  volumes:
    - wallets:/var/wallets 
  depends_on:
    - chown-wallets

Environment variables

Change the apiwallet service to

apiwallet:
  image: strawpay/apiwallet
  ports:
    - 9000:9000
  volumes:
    - wallets:/var/wallets 
  environment:
    - ISSUER_AUTH=<my-auth>
  depends_on:
    - chown-wallets

Configuration file

To use a configuration file it is recommended to include the default configuration file. Create a file my.conf with the content:

include classpath("application.conf")
apiwallet.stroem.issuer.auth = <my-auth>

There are several ways to get the configuration file accessible to the container. Hera are a two.

Including configuration in a new docker image

Create Dockerfile next to my.conf with the following content:

FROM strawpay/apiwallet
MAINTAINER You <you@example.com>
COPY my.conf /opt/docker/conf/apiwallet.conf

Build the new image with

docker build -t mywallet .

Change the apiwallet service to

apiwallet:
  image: mywallet
  ports:
    - 9000:9000
  volumes:
    - wallets:/var/wallets 
  environment:
    - ISSUER_AUTH=<my-auth>
  depends_on:
    - chown-wallets   

Mapping a host file

mkdir -p /var/apiwallet/conf
cp my.conf /var/apiwallet/conf  

Change the apiwallet service to

apiwallet:
  image: strawpay/apiwallet
  ports:
    - 9000:9000
  volumes:
    - wallets:/var/wallets
    - /var/apiwallet/conf/my.conf:/opt/docker/conf/apiwallet.conf:ro
  environment:
    - ISSUER_AUTH=<my-auth>
  depends_on:
    - chown-wallets

Operating

Options when starting the container

Apart from the configuration, other options, e.g. -Dlogback.configurationFile may be set in the command. You can also pass in jvm options using a -J prefix, e.g. -J-Xmx512m. In this example we have created my_logback.xml in /var/apiwallet/conf.

apiwallet:
  image: strawpay/apiwallet
  command: -Dlogback.configurationFile=/conf/my_logback.xml -J-Xmx512m
  ports:
    - 9000:9000
  volumes:
    - wallets:/var/wallets
    - /var/apiwallet/conf:/conf:ro
  environment:
    - ISSUER_AUTH=<my-auth>
  depends_on:
    - chown-wallets    

Verify that the container is running.

docker-compose ps

Logs

The logs can be accessed with

docker-compose logs [-f]  

For more information on how to set up logging see the Configuration

API

See API.

Failed starting

If the issuer auth is not set you will see exit code 78 in the ps command as well as an exception in the logs.

com.strawpay.apiwallet.ConfigException: No configuration setting found for key 'apiwallet.stroem.issuer.auth'

Enter your auth and start again with

docker-compose up -d