Skip to content
This repository has been archived by the owner on Jan 10, 2021. It is now read-only.

Add Docker support #12

Merged
merged 1 commit into from
Oct 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions api/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.git
.gitignore
.dockerignore
docker-compose.yml
docker-compose-base.yml
Dockerfile
docker/dev/Dockerfile
docker/prod/Dockerfile

.idea
*.iml

target
support

build
out
15 changes: 15 additions & 0 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ Note that username is ignored and can be whatever, i.e. in following example use

../gradlew run --args="--httpApiHost=127.0.0.1 --httpApiPort=8080"

## Docker integration

First you need to build the docker image for the API:

cd api
docker-compose build

Start container with the API:

docker-compose up alice

It will automatically start `bisq-api` (alice), `bitcoind` and `seednode` in regtest mode.

curl localhost:8080/api/v1/version

**CAUTION! Please do not expose the API over a public interface**

## Experimental features
Expand Down
34 changes: 34 additions & 0 deletions api/docker-compose-base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '2.1'

services:
api:
build:
context: ..
dockerfile: api/docker/dev/Dockerfile
image: bisq/api
environment:
- LOG_LEVEL=debug
- USE_LOCALHOST_FOR_P2P=true
- USE_DEV_PRIVILEGE_KEYS=true
- SEED_NODES=seed:8000
- BTC_NODES=bitcoin:18444
- BASE_CURRENCY_NETWORK=BTC_REGTEST
- BITCOIN_REGTEST_HOST=NONE
- HTTP_API_HOST=0.0.0.0
- ENABLE_HTTP_API_EXPERIMENTAL_FEATURES=true
seed:
image: bisq/seednode
environment:
- MY_ADDRESS=seed:8000
- SEED_NODES=seed:8000
- BTC_NODES=bitcoin:18444
- USE_LOCALHOST_FOR_P2P=true
- BASE_CURRENCY_NETWORK=BTC_REGTEST
- BITCOIN_REGTEST_HOST=NONE
bitcoin:
image: bisq/bitcoind:latest
command: -logips -rpcallowip=::/0 -regtest -printtoconsole
environment:
- DISABLEWALLET=0
- RPCUSER=user
- RPCPASSWORD=password
51 changes: 51 additions & 0 deletions api/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: '2.1'

services:
alice:
extends:
file: docker-compose-base.yml
service: api
ports:
- 8080:8080
environment:
- NODE_PORT=8003
links:
- seed
- bitcoin
bob:
extends:
file: docker-compose-base.yml
service: api
ports:
- 8081:8080
environment:
- NODE_PORT=8004
links:
- seed
- bitcoin
arbitrator:
extends:
file: docker-compose-base.yml
service: api
ports:
- 8082:8080
environment:
- NODE_PORT=8005
links:
- seed
- bitcoin
seed:
extends:
file: docker-compose-base.yml
service: seed
ports:
- 8000:8000
links:
- bitcoin
bitcoin:
extends:
file: docker-compose-base.yml
service: bitcoin
ports:
# If it is default regtest port (18444) then bisq ignores btcNodes param and uses localhost
- 18445:18444
29 changes: 29 additions & 0 deletions api/docker/dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM openjdk:10-jdk

RUN apt-get update && apt-get install -y --no-install-recommends \
openjfx && rm -rf /var/lib/apt/lists/*

WORKDIR /bisq/api

#ENV HTTP_API_HOST=
#ENV HTTP_API_PORT=
ENV LANG=en_US

CMD ./docker/startApi.sh

#Fetch gradle and dependencies
COPY gradle /bisq/gradle/
COPY gradlew build.gradle gradle.properties settings.gradle /bisq/
RUN ../gradlew --no-daemon -v

COPY assets /bisq/assets/
COPY common /bisq/common/
COPY core /bisq/core/
COPY p2p /bisq/p2p/
COPY pricenode /bisq/pricenode/
RUN ../gradlew --no-daemon build -x test

COPY api /bisq/api

#Compile sources to speed up startup
RUN ../gradlew --no-daemon --offline compileJava -x test
42 changes: 42 additions & 0 deletions api/docker/startApi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

ARGS=""
if [ ! -z "$APP_NAME" ]; then
ARGS="$ARGS --appName=$APP_NAME"
fi
if [ ! -z "$NODE_PORT" ]; then
ARGS="$ARGS --nodePort=$NODE_PORT"
fi
if [ ! -z "$USE_LOCALHOST_FOR_P2P" ]; then
ARGS="$ARGS --useLocalhostForP2P=$USE_LOCALHOST_FOR_P2P"
fi
if [ ! -z "$SEED_NODES" ]; then
ARGS="$ARGS --seedNodes=$SEED_NODES"
fi
if [ ! -z "$BTC_NODES" ]; then
ARGS="$ARGS --btcNodes=$BTC_NODES"
fi
if [ ! -z "$BITCOIN_REGTEST_HOST" ]; then
ARGS="$ARGS --bitcoinRegtestHost=$BITCOIN_REGTEST_HOST"
fi
if [ ! -z "$BASE_CURRENCY_NETWORK" ]; then
ARGS="$ARGS --baseCurrencyNetwork=$BASE_CURRENCY_NETWORK"
fi
if [ ! -z "$LOG_LEVEL" ]; then
ARGS="$ARGS --logLevel=$LOG_LEVEL"
fi
if [ ! -z "$USE_DEV_PRIVILEGE_KEYS" ]; then
ARGS="$ARGS --useDevPrivilegeKeys=$USE_DEV_PRIVILEGE_KEYS"
fi
if [ "$ENABLE_HTTP_API_EXPERIMENTAL_FEATURES" == "true" ]; then
ARGS="$ARGS --enableHttpApiExperimentalFeatures"
fi
if [ ! -z "$HTTP_API_PORT" ]; then
ARGS="$ARGS --httpApiPort=$HTTP_API_PORT"
fi
if [ ! -z "$HTTP_API_HOST" ]; then
ARGS="$ARGS --httpApiHost=$HTTP_API_HOST"
fi

echo ../gradlew run --no-daemon --args "foo $ARGS"
../gradlew run --no-daemon --args "foo $ARGS"