
<img src="/private/apostol-dm/raw/branch/master/docker/screenshots/Authorization.png" width="23%"></img> <img src="/private/apostol-dm/raw/branch/master/docker/screenshots/Account_details.png" width="23%"></img> <img src="/private/apostol-dm/raw/branch/master/docker/screenshots/Deal_information.png" width="23%"></img> <img src="/private/apostol-dm/raw/branch/master/docker/screenshots/Create_deal.png" width="23%"></img>

# Intro

Deal Module (dm) - the Bitdeals daemon that provides a special interfaces for creating and modifying user accounts and deals.

# Running DM docker container

On first run the initialization script will create, a new bitcoin and PGP keys and start the daemon.

Daemon settings may specified by an environment variables. PGP secret key is stored on a Docker volume.

First run example: `docker run -i -t -e DM_TESTNET=true -p 127.0.0.1:443:443 bitdeals/apostol-dm` - register new user, open WebUI port.

# Usage

Here are some example snippets to help you get started creating a container at localhost.

## docker-compose

```yaml
version: "3"
services:
  bitdeals-module:
    image: registry.bitdeals.org/apostol-dm
    environment:
      - DM_TESTNET=true
      - DM_BITCOIN=<address>
      - DM_FEE=<0.1%>
      - DM_FORWEB=http://127.0.0.1
      - |
        DM_PGP_SEC=
        -----BEGIN PGP PRIVATE KEY BLOCK-----
        <key>
        -----END PGP PRIVATE KEY BLOCK-----

    volumes:
      - dm:/home/dm
    ports:
      - 127.0.0.1:4999:4999 
      - 127.0.0.1:80:80
      - 127.0.0.1:443:443
volumes:
  dm:
```

## docker cli

```sh
docker run -d \
  -e DM_TESTNET=true \
  -e DM_BITCOIN=<address> \
  -e DM_FEE=0.1% \
  -e DM_PGP_SEC="$(gpg2 --armor --export-secret-key Account_URL)" \
  -p 127.0.0.1:4999:4999 \
  -p 127.0.0.1:80:80 \
  -p 127.0.0.1:443:443 \
  -v /home/dm/:/home/dm/ \ 
  registry.bitdeals.org/apostol-dm
```

# Parameters

Container images are configured using parameters passed at runtime.

|Parameter|Function|
|:--------|:-------|
|-p 80|WebUI port|
|-p 443|WebUI port|
|-p 4999|dm API port [(API documentation)](/private/apostol-dm/src/branch/master/doc/REST-API-ru.md)| 
|-e DM_ACCOUNT_URL=|Set Account_URL for a new account registration. Format: `http[s]://<host>[:<port>]`|
|-e DM_BITCOIN=|User account bitcoin address. Will be created if empty.|
|-e DM_BITDEALS_PGP_FINGERPRINT=|Force to get BitDeals PGP key by fingerprint from keyserver. Default: `none`|
|-e DM_FEE=|User fee for created deals. You MUST indicate the sign "%" for a percentage of the deal amount or FIXED value in satoshi. Default: `0.1%`|
|-e DM_FORWEB=|dm host for dm Web app (the host should be accessable from your browser). Default: `http://127.0.0.1`|
|-e DM_LC_ALL=|Set locale for dm. Default: `en_US.UTF-8`|
|-e DM_PGP_PASSWORD=|User PGP key password.|
|-e DM_PGP_SEC=|Variable with ASCII armored PGP user secret key. Will be created if empty (with Account_URL in the key details).|
|-e DM_TESTNET=|Enable bitcoin testnet mode. Default: `false`|
|-e DM_TZ=|Set timezone for dm. Default: `Etc/UTC`|
|-e DM_PRIVATEDASH=|Enable Web app authorization on bitdeals.org for account private dashboard access. Default: `false`|
|-e DM_PRIVACY_MODE=|Block currency rates from coinbase.com. Default: `false`|
|-e DM_WEB_LANG=|Set interface language for dm WebUI: `ru` or `en`. Default: `en`|

