Skip to content
Open
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
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node_modules
npm-debug.log*
coverage
dist
.git
.github
.env
.env.local
.env.*.local
test
docker-compose*.yml
*.log
.DS_Store
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=

# PostgreSQL (used by the Docker local stack and future persistence features)
DATABASE_URL=postgres://smartdrop:smartdrop@localhost:5432/smartdrop

# Stellar Horizon
STELLAR_HORIZON_URL=https://horizon.stellar.org

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules/
.env
.env.local
.env.*.local
docker-compose.override.yml
dist/
*.log
.DS_Store
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM node:20-alpine AS builder

WORKDIR /app
ENV NODE_ENV=production

COPY package*.json ./
RUN npm ci --omit=dev

FROM node:20-alpine AS production

WORKDIR /app
ENV NODE_ENV=production

COPY --from=builder /app/node_modules ./node_modules
COPY package*.json ./
COPY src ./src

USER node
EXPOSE 3000

CMD ["npm", "start"]
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,31 @@ Multi-source price oracle that fetches and caches USD prices for Stellar assets.

## Setup

### Quick Start With Docker

Run the local API, Redis, and Postgres stack with Docker Compose:

```bash
docker compose up --build
```

The API listens on port `4000` in the compose environment:

```bash
curl http://localhost:4000/health
```

The compose stack mounts `./src` into the API container and runs
`npm run dev`, so source changes restart the Node process automatically. Redis
and Postgres include health checks, and `docker-compose.override.yml` is ignored
for local-only secrets or service tweaks.

To remove containers and the local Postgres volume:

```bash
docker compose down -v
```

### Prerequisites

- Node.js >= 20.9.0
Expand Down
57 changes: 57 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
services:
api:
build: .
command: npm run dev
environment:
NODE_ENV: development
PORT: 4000
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_PASSWORD: ''
DATABASE_URL: postgres://smartdrop:smartdrop@postgres:5432/smartdrop
STELLAR_HORIZON_URL: https://horizon.stellar.org
USDC_ISSUER: GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335AX2OBFLDTQLNUEHRGPTM6RIA
PRICE_CACHE_TTL: 60
PRICE_REFRESH_INTERVAL: 30
PRICE_STALE_THRESHOLD: 5
PRICE_ANOMALY_THRESHOLD: 10
LOG_LEVEL: info
CORS_ALLOWED_ORIGINS: http://localhost:3000,http://localhost:3001,http://localhost:4000
ports:
- '4000:4000'
depends_on:
redis:
condition: service_healthy
postgres:
condition: service_healthy
volumes:
- ./src:/app/src

redis:
image: redis:7-alpine
ports:
- '6379:6379'
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
interval: 5s
timeout: 3s
retries: 12

postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: smartdrop
POSTGRES_PASSWORD: smartdrop
POSTGRES_DB: smartdrop
ports:
- '5432:5432'
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U smartdrop -d smartdrop']
interval: 5s
timeout: 3s
retries: 12
volumes:
- postgres-data:/var/lib/postgresql/data

volumes:
postgres-data: