commit
8962ae50da
|
@ -0,0 +1,6 @@
|
|||
FROM nginx
|
||||
|
||||
# https://github.com/jetbrains-infra/docker-nginx-resolver
|
||||
ADD entrypoint.sh /entrypoint.sh
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
|
@ -17,6 +17,13 @@ Directory structure
|
|||
├── mango-vial - WEBSOCKET API Service for L1, L2 orderbook data for mango markets version 3
|
||||
└── py - python3 client for above REST API Service
|
||||
```
|
||||
|
||||
# How to run
|
||||
* `docker-compose up` starts the REST API Service and the WEBSOCKET API Service, and a ngninx reverse proxy
|
||||
* The REST API is then available e.g. `curl http://localhost/api/wallet/balances`
|
||||
* the WEBSOCKET API is then available e.g.`wscat --connect ws://localhost/ws` (note by default the websocket program when run in isolation is available at `ws://localhost/v1/ws` )
|
||||
|
||||
|
||||
# Todos
|
||||
losely sorted in order of importance/priority
|
||||
- rpc node related issues
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
version: "3.9"
|
||||
services:
|
||||
mango-service-v3:
|
||||
build: mango-service-v3
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- ~/.config/solana:/root/.config/solana # mount volume where keys are present, also see PRIVATE_KEY_PATH
|
||||
environment:
|
||||
- PORT=3000
|
||||
- GROUP_NAME=mainnet.1
|
||||
- CLUSTER_URL=${CLUSTER_URL} # configure custom RPC node
|
||||
- PRIVATE_KEY_PATH=/root/.config/solana/id.json # configure path to private keypair here
|
||||
mango-vial:
|
||||
build: "mango-vial"
|
||||
ports:
|
||||
- "8000:8000"
|
||||
environment:
|
||||
- MV_PORT=8000
|
||||
- MV_ENDPOINT=${CLUSTER_URL} # configure custom RPC node
|
||||
reverse-proxy:
|
||||
build: .
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ./nginx.conf/:/etc/nginx/nginx.conf # custom config which unifies mango-service-v3 and mango-vial
|
|
@ -0,0 +1 @@
|
|||
CLUSTER_URL=https://api.mainnet-beta.solana.com
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# https://github.com/jetbrains-infra/docker-nginx-resolver
|
||||
export DOLLAR='$'
|
||||
mkdir -p /etc/nginx/includes/
|
||||
echo resolver $(awk 'BEGIN{ORS=" "} $1=="nameserver" {print $2}' /etc/resolv.conf) ";" > /etc/nginx/includes/resolver.conf
|
||||
exec "$@"
|
|
@ -0,0 +1,46 @@
|
|||
error_log /dev/stdout info;
|
||||
|
||||
events {}
|
||||
|
||||
http {
|
||||
# https://github.com/jetbrains-infra/docker-nginx-resolver
|
||||
include /etc/nginx/includes/resolver.conf;
|
||||
|
||||
# https://www.nginx.com/blog/websocket-nginx/
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
upstream rest-api {
|
||||
server mango-service-v3:3000;
|
||||
}
|
||||
|
||||
upstream ws-api {
|
||||
server mango-vial:8000;
|
||||
}
|
||||
|
||||
server {
|
||||
access_log /dev/stdout;
|
||||
|
||||
listen 80;
|
||||
|
||||
# https://localhost/api
|
||||
location /api/ {
|
||||
set $backend_api "http://rest-api/api/";
|
||||
if ($request_uri ~* "/api/(.*$)") {
|
||||
set $path_remainder $1;
|
||||
}
|
||||
proxy_pass $backend_api$path_remainder;
|
||||
}
|
||||
|
||||
# ws://localhost/ws
|
||||
location /ws {
|
||||
proxy_pass http://ws-api/v1/ws;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue