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
49 changes: 49 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
target
**/target
**/node_modules
**/.next
**/.pnpm-store
**/.turbo
**/.cache
**/dist
**/build
.env
.env.*
docker-compose.yml

# Dependencies
node_modules
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Next.js
.next
out
build

# Environment files
.env*.local
.env

# Git
.git
.gitignore

# IDE
.vscode
.idea
*.swp
*.swo

# OS
.DS_Store
Thumbs.db

# Testing
coverage
.nyc_output

# Misc
*.log
.cache
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ENV=dev | prod
POSTGRES_USER=postgres
POSTGRES_PASSWORD=password
POSTGRES_DB=polkadot_clob
POSTGRES_DB_FULL_NAME=${POSTGRES_DB}_${ENV}
INDEXER_PORT=8081 (suggeted, can be every available port)
30 changes: 29 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,34 @@
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

.env

target/

# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules

# next.js
/.next/
/out/

# production
/build

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ This project implements a fully functional orderbook-based DEX on Substrate, fea
- **Custom Assets Pallet**: Manages USDT and ETH balances with lock/unlock functionality
- **Atomic Settlement**: All trades are settled atomically with proper fund transfers

## Quick Start
Pull mock data:
```bash
cd tradebot
git lfs pull
```

From root directory:
```bash
docker compose up --build
```

## Architecture

### Two-Phase Design
Expand Down
76 changes: 73 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
services:
solochain:
image: solochain-node:latest
container_name: solochain
command:
- --dev
- --rpc-cors=all
- --rpc-methods=Unsafe
- --unsafe-rpc-external
- --base-path
- /data
ports:
# ws port 9944
- "9944:9944"
- "9933:9933"
- "9615:9615"
- "30333:30333"
volumes:
- solochain-data:/data
restart: unless-stopped

timescaledb:
image: timescale/timescaledb-ha:pg17
ports:
- "5432:5432"
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
- POSTGRES_DB=polkadot_clob
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
volumes:
- ./indexer/db/timescale.sql:/mnt/timescale.sql
restart: unless-stopped
Expand All @@ -15,3 +35,53 @@ services:
interval: 10s
timeout: 5s
retries: 5

indexer:
build:
context: .
dockerfile: indexer/Dockerfile
container_name: indexer
depends_on:
timescaledb:
condition: service_healthy
solochain:
condition: service_started
environment:
Env: ${ENV}
NODE_WS_URL: ws://solochain:9944
DATABASE_URL: postgres://postgres:password@timescaledb:5432/${POSTGRES_DB_FULL_NAME}
RUST_LOG: indexer=debug,info
ports:
- "8081:3000"
restart: unless-stopped

frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: frontend
ports:
- "3000:3000"
env_file:
- ./frontend/.env
restart: unless-stopped

tradebot:
build:
context: .
dockerfile: tradebot/Dockerfile
container_name: tradebot
depends_on:
timescaledb:
condition: service_healthy
solochain:
condition: service_started
env_file:
- ./tradebot/.env
volumes:
- ./tradebot/ETHUSDC_2025-11-12T22-08-37-339Z_synthetic_blocks.jsonl:/app/ETHUSDC_2025-11-12T22-08-37-339Z_synthetic_blocks.jsonl:ro
restart: unless-stopped

volumes:
pgdata:
solochain-data:
36 changes: 36 additions & 0 deletions frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Dependencies
node_modules
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Next.js
.next
out
build

# Environment files
.env*.local
.env

# Git
.git
.gitignore

# IDE
.vscode
.idea
*.swp
*.swo

# OS
.DS_Store
Thumbs.db

# Testing
coverage
.nyc_output

# Misc
*.log
.cache
27 changes: 27 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules

# next.js
/.next/
/out/

# production
/build

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
31 changes: 31 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# ----- base -----
FROM node:20-alpine AS base
WORKDIR /app
RUN apk add --no-cache libc6-compat && corepack enable

# Only lockfile + manifest first for better caching
COPY package.json pnpm-lock.yaml ./
RUN corepack prepare pnpm@9 --activate && pnpm fetch

# ----- build -----
FROM base AS build
COPY . .
# If you removed the workspace file, this installs just this app
RUN pnpm install --no-frozen-lockfile
RUN pnpm build

# ----- runtime -----
FROM node:20-alpine AS runtime
WORKDIR /app
RUN addgroup -S nextjs && adduser -S nextjs -G nextjs

# Copy minimal runtime artifacts
COPY --from=build /app/.next ./.next
COPY --from=build /app/public ./public
COPY --from=build /app/package.json .
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/next.config.mjs ./next.config.mjs

EXPOSE 3000
USER nextjs
CMD ["node", "node_modules/next/dist/bin/next", "start", "-p", "3000"]
62 changes: 62 additions & 0 deletions frontend/README.docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Docker Setup for Orbex

## Prerequisites
- Docker installed on your system
- Docker Compose installed

## Environment Variables

The application requires the following environment variables:
- `NODE_ENV`: Set to `prod` for production
- `SERVER_URL`: API server URL (default: http://localhost:3000)
- `NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID`: Your WalletConnect project ID

## Quick Start

### 1. Build and run with Docker Compose

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

The application will be available at http://localhost:3000

### 2. Run in detached mode

\`\`\`bash
docker-compose up -d
\`\`\`

### 3. Stop the application

\`\`\`bash
docker-compose down
\`\`\`

## Manual Docker Commands

### Build the image

\`\`\`bash
docker build -t orbex-web-app .
\`\`\`

### Run the container

\`\`\`bash
docker run -p 3000:3000 \
-e NODE_ENV=prod \
-e SERVER_URL=http://localhost:3000 \
-e NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your-project-id \
orbex-web-app
\`\`\`

## Development

To override environment variables, create a `.env` file or modify the `docker-compose.yml` file.

## Troubleshooting

- If port 3000 is already in use, modify the port mapping in `docker-compose.yml`
- Check logs: `docker-compose logs -f`
- Rebuild after code changes: `docker-compose up --build`
Loading
Loading