Skip to content

Commit cb66978

Browse files
authored
Merge pull request #13 from Premian-Labs/d-branch-5
rebase fork
2 parents d903483 + 79e144e commit cb66978

File tree

12 files changed

+1527
-3
lines changed

12 files changed

+1527
-3
lines changed

.github/workflows/deploy-prod.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Deploy to Railway
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
environment: prod
11+
container: ghcr.io/railwayapp/cli:latest
12+
env:
13+
SVC_ID_ERPC: ${{ secrets.SVC_ID_ERPC }}
14+
SVC_ID_MONITOR: ${{ secrets.SVC_ID_MONITOR }}
15+
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
16+
steps:
17+
- uses: actions/checkout@v3
18+
- run: railway up -d --service=${{ env.SVC_ID_ERPC }}
19+
- run: railway up -d --service=${{ env.SVC_ID_MONITOR }}

.github/workflows/deploy.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Deploy to Railway
2+
3+
on:
4+
push:
5+
branches: [dev]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
environment: dev
11+
container: ghcr.io/railwayapp/cli:latest
12+
env:
13+
SVC_ID_ERPC: ${{ secrets.SVC_ID_ERPC }}
14+
SVC_ID_MONITOR: ${{ secrets.SVC_ID_MONITOR }}
15+
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
16+
steps:
17+
- uses: actions/checkout@v3
18+
- run: railway up -d --service=${{ env.SVC_ID_ERPC }}
19+
- run: railway up -d --service=${{ env.SVC_ID_MONITOR }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env

CLAUDE.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# eRPC Railway Deployment Guide
2+
3+
## Build and Deploy Commands
4+
- Deploy to Railway: Click the "Deploy on Railway" button in README.md
5+
- Local Docker build: `docker build -f Dockerfile.erpc -t erpc-server .`
6+
- Local monitoring build: `docker build -f Dockerfile.monitoring -t erpc-monitoring .`
7+
- Run locally: `docker-compose up -d`
8+
- View logs: `docker-compose logs -f`
9+
- Stop services: `docker-compose down`
10+
11+
## Automated Deployment
12+
- GitHub Actions automatically deploy to Railway on pushes to:
13+
- `dev` branch: Deploys to development environment
14+
- `main` branch: Deploys to production environment
15+
- Both the eRPC server and monitoring stack are deployed separately using distinct Railway service IDs
16+
17+
## Environment Variables
18+
- Required: `REDIS_ADDR`, `REDIS_PASSWORD`, `RPC_API_SECRET`
19+
- Optional: Various API keys for RPC providers (ALCHEMY_API_KEY, INFURA_API_KEY, etc.)
20+
- GitHub Actions secrets needed:
21+
- `RAILWAY_TOKEN`: Authentication token for Railway
22+
- `SVC_ID_ERPC`: Railway service ID for eRPC server
23+
- `SVC_ID_MONITOR`: Railway service ID for monitoring stack
24+
25+
## Container Structure
26+
- eRPC server: Handles RPC requests, runs on port 4000
27+
- Healthcheck: JSON-RPC `net_version` request to port 4000
28+
- Uses `Dockerfile.erpc` and `railway.erpc.json` for configuration
29+
- Metrics endpoint: Port 4001
30+
- Monitoring stack:
31+
- Grafana (port 3000) with healthcheck at /api/health
32+
- Prometheus (port 9090)
33+
- Uses `Dockerfile.monitoring` and `railway.monitor.json` for configuration
34+
35+
## Code Style Guidelines
36+
- Configuration files use YAML format
37+
- Environment variables use UPPERCASE_WITH_UNDERSCORES
38+
- Containerization follows multi-stage build patterns
39+
- Docker images should be minimal and secure

Dockerfile.erpc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
11
FROM ghcr.io/erpc/erpc:latest
2-
CMD ["./erpc-server"]
2+
3+
# Install curl for healthcheck
4+
RUN apt-get update && apt-get install -y curl && apt-get clean && rm -rf /var/lib/apt/lists/*
5+
6+
# Copy the processed config
7+
COPY erpc.yaml /root/erpc.yaml
8+
9+
# Add healthcheck
10+
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
11+
CMD curl -f http://localhost:4000/ -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"net_version","id":1}' || exit 1
12+
13+
# Run server
14+
CMD ["./erpc-server"]

Dockerfile.monitoring

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM grafana/grafana:9.3.2 as grafana
33

44
FROM ubuntu:22.04
55

6-
RUN apt-get update && apt-get install -y curl
6+
RUN apt-get update && apt-get install -y curl && apt-get clean && rm -rf /var/lib/apt/lists/*
77

88
# Set environment variables
99
ENV SERVICE_ENDPOINT=""
@@ -29,4 +29,8 @@ RUN chmod +x /entrypoint.sh
2929

3030
EXPOSE 3000 9090
3131

32+
# Add healthcheck for Grafana
33+
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
34+
CMD curl -f http://localhost:3000/api/health || exit 1
35+
3236
ENTRYPOINT ["/entrypoint.sh"]

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1+
<img src="https://github.com/user-attachments/assets/6673073f-eba7-4bce-9180-8d24ea046269" align="center" title="erpc banner">
2+
13
# eRPC Railway Template
4+
This is our implementation of eRPC, it's not perfect, but it's ours.
5+
This template is a fork of the upstream [erpc/erpc](https://github.com/erpc/erpc) repository. If you want to keep your fork in sync with the upstream repository, you can add the upstream remote using:
6+
7+
```bash
8+
git remote add upstream https://github.com/erpc/erpc.git
9+
git fetch upstream
10+
```
11+
12+
Then you can merge changes from upstream into your fork:
13+
14+
```bash
15+
git checkout main
16+
git merge upstream/main
17+
```
218

319
<a href="https://docs.erpc.cloud"><img alt="Docs" src="https://img.shields.io/badge/docs-get%20started-brightgreen"/></a>
420
[![Telegram chat][tg-badge]][tg-url]
@@ -8,7 +24,15 @@
824

925
[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/10iW1q)
1026

11-
# License
27+
## Deployment
28+
29+
This repository is configured with GitHub Actions workflows that automatically deploy:
30+
- The eRPC server and monitoring stack to the development environment when code is pushed to the `dev` branch
31+
- The eRPC server and monitoring stack to the production environment when code is pushed to the `main` branch
32+
33+
The deployment uses Railway's service IDs to deploy the eRPC server and monitoring stack separately.
34+
35+
## License
1236

1337
Apache 2.0
1438

docker-compose.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
version: '3.8'
2+
3+
services:
4+
erpc:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile.erpc
8+
ports:
9+
- "4000:4000"
10+
- "4001:4001"
11+
environment:
12+
- REDIS_ADDR=redis:6379
13+
- REDIS_PASSWORD=redispassword
14+
- RPC_API_SECRET=localsecret
15+
# Add your API keys here for local development
16+
- ALCHEMY_API_KEY=${ALCHEMY_API_KEY:-}
17+
- INFURA_API_KEY=${INFURA_API_KEY:-}
18+
- TENDERLY_ARB_API_KEY=${TENDERLY_ARB_API_KEY:-}
19+
- TENDERLY_ARB_NOVA_API_KEY=${TENDERLY_ARB_NOVA_API_KEY:-}
20+
- TENDERLY_ARB_SEP_API_KEY=${TENDERLY_ARB_SEP_API_KEY:-}
21+
- ONERPC_API_KEY=${ONERPC_API_KEY:-}
22+
- LLAMA_API_KEY=${LLAMA_API_KEY:-}
23+
- CS_ARB_API_KEY=${CS_ARB_API_KEY:-}
24+
- CS_ETH_API_KEY=${CS_ETH_API_KEY:-}
25+
- CS_BNB_API_KEY=${CS_BNB_API_KEY:-}
26+
- CS_POL_API_KEY=${CS_POL_API_KEY:-}
27+
- CS_BLAST_API_KEY=${CS_BLAST_API_KEY:-}
28+
- CS_OP_API_KEY=${CS_OP_API_KEY:-}
29+
- CS_BASE_API_KEY=${CS_BASE_API_KEY:-}
30+
- CS_ARB2_API_KEY=${CS_ARB2_API_KEY:-}
31+
- CS_ARB_API_KEY_TEST=${CS_ARB_API_KEY_TEST:-}
32+
- CS_ARBSEP_API_KEY_TEST=${CS_ARBSEP_API_KEY_TEST:-}
33+
- MORALIS_ARB_API_KEY=${MORALIS_ARB_API_KEY:-}
34+
- MORALIS_ARBSEP_API_KEY=${MORALIS_ARBSEP_API_KEY:-}
35+
- QN_ARBSEP_API_KEY=${QN_ARBSEP_API_KEY:-}
36+
- QN_ARB_API_KEY=${QN_ARB_API_KEY:-}
37+
- QN_ARB_NOVA_API_KEY=${QN_ARB_NOVA_API_KEY:-}
38+
- QN_ETH_HOLESKY_API_KEY=${QN_ETH_HOLESKY_API_KEY:-}
39+
- QN_ETH_API_KEY=${QN_ETH_API_KEY:-}
40+
- QN_ETH_SEP_API_KEY=${QN_ETH_SEP_API_KEY:-}
41+
depends_on:
42+
- redis
43+
restart: unless-stopped
44+
healthcheck:
45+
test: ["CMD", "curl", "-f", "http://localhost:4000/", "-X", "POST", "-H", "Content-Type: application/json", "-d", '{"jsonrpc":"2.0","method":"net_version","id":1}']
46+
interval: 30s
47+
timeout: 5s
48+
retries: 3
49+
start_period: 10s
50+
51+
monitoring:
52+
build:
53+
context: .
54+
dockerfile: Dockerfile.monitoring
55+
ports:
56+
- "3000:3000" # Grafana
57+
- "9090:9090" # Prometheus
58+
environment:
59+
- SERVICE_ENDPOINT=erpc
60+
- SERVICE_PORT=4001
61+
depends_on:
62+
- erpc
63+
restart: unless-stopped
64+
healthcheck:
65+
test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"]
66+
interval: 30s
67+
timeout: 5s
68+
retries: 3
69+
start_period: 20s
70+
71+
redis:
72+
image: redis:alpine
73+
command: redis-server --requirepass redispassword
74+
ports:
75+
- "6379:6379"
76+
volumes:
77+
- redis-data:/data
78+
restart: unless-stopped
79+
healthcheck:
80+
test: ["CMD", "redis-cli", "ping"]
81+
interval: 10s
82+
timeout: 5s
83+
retries: 3
84+
85+
volumes:
86+
redis-data:

0 commit comments

Comments
 (0)