Skip to content

Commit d3fdae4

Browse files
authored
Merge pull request #65 from geniusyield/61-example-config-for-kupo-backend-for-bot-api-server
Example config for kupo backend for bot api server #61
2 parents f879637 + 8283866 commit d3fdae4

File tree

6 files changed

+118
-7
lines changed

6 files changed

+118
-7
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "cardano-configurations"]
2+
path = cardano-configurations
3+
url = https://github.com/input-output-hk/cardano-configurations.git
4+
branch = 692010ed0f454bfbb566c06443227c79e2f4dbab

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ pull:
1111
start:
1212
docker compose up -d --remove-orphans
1313

14+
start-kupo:
15+
docker-compose -f docker-compose-kupo.yml up -d
16+
17+
node-logs:
18+
docker compose logs -f node
19+
1420
logs:
1521
docker compose logs -f
1622

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ This repository houses on-chain smart contracts, Haskell off-chain interaction l
77
- [Structure of repository](#structure-of-repository)
88
- [Bot API Server](#bot-api-server)
99
- [Spinning up the api server using docker](#spinning-up-the-api-server-using-docker)
10+
- [Setting up the API Server with Docker (Maestro)](#setting-up-the-API-Server-with-docker-maestro)
11+
- [Setting up the API Server with Docker (Kupo)](#setting-up-the-API-Server-with-docker-kupo)
1012
- [Building locally from source using Docker](#building-locally-from-source-using-docker)
1113
- [Building locally from source using the Haskell Toolchain](#building-locally-from-source-using-the-haskell-toolchain)
1214
- [Swagger API documentation](#swagger-api-documentation)
@@ -26,6 +28,8 @@ This repository houses on-chain smart contracts, Haskell off-chain interaction l
2628

2729
### Spinning up the api server using docker
2830

31+
#### Setting up the API Server with Docker (Maestro)
32+
2933
The api server can be started using [docker-compose](https://github.com/geniusyield/dex-contracts-api/blob/main/docker-compose.yml). Simply clone the repository,
3034
prepare a `.env` file with the necessary secrets and use the make targets from
3135
the Makefile available in the repository.
@@ -80,6 +84,33 @@ Integration with the Genius Yield DEX has never been easier.
8084
> [!TIP]
8185
> Have a look at sample configuration in [Building locally from source using the Haskell Toolchain](#building-locally-from-source-using-the-haskell-toolchain) section for thorough explanation of options made available to configure the server.
8286
87+
#### Setting up the API Server with Docker (Kupo)
88+
89+
If you're looking to utilize the API server alongside the Kupo provider backend, you're in luck! We've streamlined the process for you.
90+
91+
Inside the repository, you'll find a `docker-compose-kupo.yml` file, which serves as a blueprint for running a local Cardano node, Kupo, and the API server seamlessly.
92+
93+
```bash
94+
# Step 1: Clone the repository
95+
git clone git@github.com:geniusyield/dex-contracts-api.git
96+
97+
# Step 2: Initialize and update submodules
98+
cd dex-contracts-api
99+
git submodule update --init --recursive
100+
101+
# Step 3: Configure your environment variables
102+
# Create a .env file and populate it with the necessary secrets
103+
echo """
104+
SERVER_API_KEY=___REPLACE_ME___
105+
SEED_PHRASE=[word_1, word_2, ... word_23, word_24]""" > .env
106+
nano .env # Use your preferred text editor to replace placeholders with actual values
107+
108+
# Step 4: Launch the API server with Kupo
109+
docker-compose -f docker-compose-kupo.yml up -d
110+
```
111+
112+
By following these steps, you'll have the API server up and running smoothly, integrated with the powerful capabilities of the Kupo provider backend.
113+
83114
### Building locally from source using Docker
84115

85116
The easiest way to build the software is using docker.

cardano-configurations

Submodule cardano-configurations added at 692010e

docker-compose-kupo.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
version: '3.8'
2+
services:
3+
server:
4+
image: ghcr.io/geniusyield/dex-contracts-api:latest
5+
container_name: server
6+
restart: always
7+
volumes: ["node-ipc:/ipc"]
8+
ports: ["8082:8082"]
9+
depends_on: { node: { condition: service_healthy } }
10+
environment:
11+
MAESTRO_API_KEY: ${MAESTRO_API_KEY}
12+
SERVER_API_KEY: ${SERVER_API_KEY}
13+
SEED_PHRASE: ${SEED_PHRASE}
14+
SERVER_CONFIG: |
15+
coreProvider:
16+
socketPath: /ipc/node.socket
17+
kupoUrl: "kupo:1442"
18+
networkId: mainnet
19+
logging: [{type: {tag: stderr}, severity: "Debug", verbosity: "V2"}]
20+
maestroToken: <<MAESTRO_API_KEY>>
21+
serverApiKey: <<SERVER_API_KEY>>
22+
wallet:
23+
tag: mnemonicWallet
24+
contents:
25+
mnemonic: <<SEED_PHRASE>>
26+
port: 8082
27+
kupo:
28+
image: cardanosolutions/kupo:v2.8.0
29+
container_name: kupo
30+
restart: always
31+
volumes: ["node-ipc:/ipc", "./cardano-configurations/network:/network"]
32+
ports: ['1442:1442']
33+
depends_on: { node: { condition: service_healthy } }
34+
command: [
35+
--node-socket, /ipc/node.socket,
36+
--since, origin,
37+
--match, "*",
38+
--host, "0.0.0.0",
39+
--node-config, "/network/${NETWORK-mainnet}/cardano-node/config.json",
40+
--workdir,
41+
--prune-utxo,
42+
]
43+
healthcheck:
44+
test: ["CMD", "/bin/kupo", "health-check"]
45+
interval: 30s
46+
timeout: 10s
47+
retries: 100
48+
node:
49+
image: ghcr.io/intersectmbo/cardano-node:8.9.1
50+
container_name: node
51+
restart: always
52+
environment:
53+
- NETWORK=${NETWORK-mainnet}
54+
volumes: ["${NETWORK-mainnet}-node-db:/data/db", "node-ipc:/ipc"]
55+
healthcheck:
56+
test: ["CMD", "test", "-S", "/ipc/node.socket"]
57+
interval: 30s
58+
timeout: 10s
59+
retries: 100
60+
volumes:
61+
preprod-node-db: null
62+
mainnet-node-db: null
63+
node-ipc: null

start.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,25 @@ if [ -z "$SERVER_CONFIG" ]; then
77
exit 1 # Exit code 1 for unset variable
88
fi
99

10-
11-
if [ -z "$CORE_MAESTRO_API_KEY" ]; then
12-
echo "Error: CORE_MAESTRO_API_KEY environment variable is not set." >&2
13-
exit 1 # Exit code 1 for unset variable
10+
if [[ "$SERVER_CONFIG" == *"<<CORE_MAESTRO_API_KEY>>"* ]]; then
11+
if [ -z "$CORE_MAESTRO_API_KEY" ]; then
12+
echo "Error: CORE_MAESTRO_API_KEY environment variable is not set." >&2
13+
exit 1 # Exit code 1 for unset variable
14+
fi
1415
fi
15-
if [ -z "$MAESTRO_API_KEY" ]; then
16-
echo "Error: MAESTRO_API_KEY environment variable is not set." >&2
17-
exit 1 # Exit code 1 for unset variable
16+
17+
if [[ "$SERVER_CONFIG" == *"<<MAESTRO_API_KEY>>"* ]]; then
18+
if [ -z "$MAESTRO_API_KEY" ]; then
19+
echo "Error: MAESTRO_API_KEY environment variable is not set." >&2
20+
exit 1 # Exit code 1 for unset variable
21+
fi
1822
fi
23+
1924
if [ -z "$SERVER_API_KEY" ]; then
2025
echo "Error: SERVER_API_KEY environment variable is not set." >&2
2126
exit 1 # Exit code 1 for unset variable
2227
fi
28+
2329
if [ -z "$SEED_PHRASE" ]; then
2430
echo "Error: SEED_PHRASE environment variable is not set." >&2
2531
exit 1 # Exit code 1 for unset variable

0 commit comments

Comments
 (0)