Skip to content

Commit b7ea74d

Browse files
committed
Add docker files and update README
1 parent 78141ee commit b7ea74d

File tree

8 files changed

+302
-2
lines changed

8 files changed

+302
-2
lines changed

.github/FUNDING.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
github: [Rabbit-Company]
2+
open_collective: rabbit-company
3+
liberapay: RabbitCompany
4+
ko_fi: rabbitcompany
5+
patreon: rabbitcompany
6+
issuehunt: rabbit-company
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish to Docker hub
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Set up QEMU
18+
uses: docker/setup-qemu-action@v3
19+
20+
- name: Set up Docker Buildx
21+
id: buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Login to DockerHub
25+
uses: docker/login-action@v3
26+
with:
27+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
28+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
29+
30+
- name: Build and push
31+
uses: docker/build-push-action@v6
32+
with:
33+
context: .
34+
push: true
35+
platforms: linux/amd64,linux/arm64
36+
tags: rabbitcompany/rabbitassets:latest
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Publish to Docker hub on Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Get the version
16+
id: get_version
17+
uses: battila7/get-version-action@v2
18+
19+
- name: Set up QEMU
20+
uses: docker/setup-qemu-action@v3
21+
22+
- name: Set up Docker Buildx
23+
id: buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Login to DockerHub
27+
uses: docker/login-action@v3
28+
with:
29+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
30+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
31+
32+
- name: Build and push
33+
uses: docker/build-push-action@v6
34+
with:
35+
context: .
36+
push: true
37+
platforms: linux/amd64,linux/arm64
38+
tags: |
39+
rabbitcompany/rabbitassets:${{steps.get_version.outputs.version-without-v}}
40+
rabbitcompany/rabbitassets:${{steps.get_version.outputs.major}}

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM oven/bun:1-alpine
2+
WORKDIR /usr/src/app
3+
4+
ENV NODE_ENV=production
5+
6+
COPY package.json bun.lock tsconfig.json ./
7+
8+
RUN bun install --frozen-lockfile --production
9+
10+
COPY src/ ./src/
11+
12+
USER bun
13+
EXPOSE 3000/tcp
14+
ENTRYPOINT [ "bun", "run", "start" ]

README.md

Lines changed: 174 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,174 @@
1-
# RabbitAssets
1+
# RabbitAssets 🐰📈
2+
3+
A high-performance asset price monitoring system built with Bun that tracks cryptocurrency, stock, and fiat currency prices across multiple exchanges and exports metrics in OpenMetrics format for Prometheus.
4+
5+
## Features
6+
7+
- 🚀 Blazing Fast - Built with Bun for optimal performance
8+
- 📊 Multi-Exchange Support - Binance, Kraken, Coinbase, RabbitStocks, and Fiat currencies
9+
- 🌍 Multi-Currency Portfolio - Automatic currency conversion with real-time forex rates
10+
- 🎯 OpenMetrics Export - Prometheus-compatible metrics endpoint
11+
- 🔄 Real-time Updates - WebSocket connections for live price updates
12+
- 👥 Multi-Owner Support - Track assets for multiple portfolio owners
13+
- 🐳 Docker Ready - Easy deployment with Docker and Docker Compose
14+
- 🔐 Bearer Authentication - Optional token-based API security
15+
- 📈 Portfolio Analytics - Value breakdowns, currency distribution, and asset percentages
16+
17+
## Supported Exchanges
18+
19+
- [**RabbitStocks**](https://github.com/Rabbit-Company/RabbitStockAPI) - Stock market data
20+
- **Binance** - Cryptocurrency prices via WebSocket
21+
- **Kraken** - Cryptocurrency prices via WebSocket
22+
- **Coinbase** - Cryptocurrency prices via WebSocket
23+
- [**Fiat**](https://github.com/Rabbit-Company/RabbitForexAPI) - Forex currency conversion rates
24+
25+
## Quick Start
26+
27+
### Prerequisites
28+
29+
Docker and Docker Compose
30+
31+
### Configuration
32+
33+
Create a `config.json` next to `docker-compose.yml` file:
34+
35+
```json
36+
{
37+
"server": {
38+
"host": "0.0.0.0",
39+
"port": 3000,
40+
"token": null
41+
},
42+
"logger": {
43+
"level": 3
44+
},
45+
"assets": [
46+
{
47+
"symbol": "EUR",
48+
"quantity": 1500,
49+
"exchange": "fiat",
50+
"currency": "USD",
51+
"owner": "default"
52+
},
53+
{
54+
"symbol": "EUR",
55+
"quantity": 430,
56+
"exchange": "fiat",
57+
"currency": "EUR",
58+
"owner": "ziga"
59+
},
60+
{
61+
"symbol": "UBNT",
62+
"quantity": 3.624,
63+
"exchange": "rabbitstocks",
64+
"currency": "EUR",
65+
"owner": "default"
66+
},
67+
{
68+
"symbol": "UBNT",
69+
"quantity": 1.31,
70+
"exchange": "rabbitstocks",
71+
"currency": "EUR",
72+
"owner": "ziga"
73+
},
74+
{
75+
"symbol": "NET",
76+
"quantity": 4.5,
77+
"exchange": "rabbitstocks",
78+
"currency": "EUR",
79+
"owner": "default"
80+
},
81+
{
82+
"symbol": "WISEl",
83+
"quantity": 4,
84+
"exchange": "rabbitstocks",
85+
"currency": "EUR",
86+
"owner": "default"
87+
},
88+
{
89+
"symbol": "BTC",
90+
"quantity": 0.043212,
91+
"exchange": "binance",
92+
"currency": "USD",
93+
"owner": "default"
94+
},
95+
{
96+
"symbol": "BTC",
97+
"quantity": 0.0003167,
98+
"exchange": "binance",
99+
"currency": "USD",
100+
"owner": "ziga"
101+
},
102+
{
103+
"symbol": "ETH",
104+
"quantity": 0.64232,
105+
"exchange": "coinbase",
106+
"currency": "USD",
107+
"owner": "default"
108+
},
109+
{
110+
"symbol": "SOL",
111+
"quantity": 0.16,
112+
"exchange": "coinbase",
113+
"currency": "USD",
114+
"owner": "default"
115+
},
116+
{
117+
"symbol": "XMR",
118+
"quantity": 2.54,
119+
"exchange": "kraken",
120+
"currency": "USD",
121+
"owner": "default"
122+
}
123+
]
124+
}
125+
```
126+
127+
### Running with Docker Compose
128+
129+
```bash
130+
docker-compose up -d
131+
```
132+
133+
### Manual Docker Run
134+
135+
```bash
136+
docker run -d \
137+
--name rabbitassets \
138+
-p 3000:3000 \
139+
-v $(pwd)/config.json:/usr/src/app/config.json \
140+
rabbitcompany/rabbitassets:latest
141+
```
142+
143+
## API Endpoints
144+
145+
### GET `/metrics`
146+
147+
OpenMetrics format endpoint for Prometheus scraping.
148+
149+
### GET `/v1/assets`
150+
151+
JSON API endpoint returning all asset metrics.
152+
153+
Example response:
154+
155+
```json
156+
[
157+
{
158+
"symbol": "BTC",
159+
"quantity": 0.043212,
160+
"currentPrice": 45000.5,
161+
"value": 1944.56,
162+
"currency": "USD",
163+
"owner": "default"
164+
},
165+
{
166+
"symbol": "ETH",
167+
"quantity": 0.64232,
168+
"currentPrice": 2500.75,
169+
"value": 1605.48,
170+
"currency": "USD",
171+
"owner": "default"
172+
}
173+
]
174+
```

config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"server": {
3-
"port": 9090,
43
"host": "0.0.0.0",
4+
"port": 3000,
55
"token": null
66
},
77
"logger": {

docker-compose.override.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
services:
2+
rabbitassets:
3+
build:
4+
context: .
5+
container_name: rabbitassets
6+
restart: unless-stopped
7+
ports:
8+
- "3000:3000"
9+
volumes:
10+
- ./config.json:/usr/src/app/config.json
11+
healthcheck:
12+
test: ["CMD", "curl", "-f", "http://localhost:3000"]
13+
interval: 10s
14+
timeout: 3s
15+
retries: 3
16+
start_period: 5s

docker-compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
services:
2+
rabbitassets:
3+
image: rabbitcompany/rabbitassets:latest
4+
container_name: rabbitassets
5+
restart: unless-stopped
6+
ports:
7+
- "3000:3000"
8+
volumes:
9+
- ./config.json:/usr/src/app/config.json
10+
healthcheck:
11+
test: ["CMD", "curl", "-f", "http://localhost:3000"]
12+
interval: 10s
13+
timeout: 3s
14+
retries: 3
15+
start_period: 5s

0 commit comments

Comments
 (0)