Skip to content

Commit 692f731

Browse files
committed
Squash History
1 parent 90b50ca commit 692f731

File tree

11 files changed

+1215
-377
lines changed

11 files changed

+1215
-377
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 }}

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: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1-
# Build stage
2-
FROM alpine:latest as builder
3-
4-
# Install gomplate for advanced templating
5-
RUN apk add --no-cache curl && \
6-
curl -L https://github.com/hairyhenderson/gomplate/releases/download/v3.11.3/gomplate_linux-amd64 -o /usr/local/bin/gomplate && \
7-
chmod +x /usr/local/bin/gomplate
8-
9-
# Copy and process config in build stage
10-
COPY erpc.yaml /root/erpc.yaml.template
11-
RUN gomplate -f /root/erpc.yaml.template -o /root/erpc.yaml
12-
13-
# Final stage
141
FROM ghcr.io/erpc/erpc:latest
152

16-
# Set environment variables (these can be empty or set by your CI/CD environment)
17-
# ARG ALCHEMY_API_KEY
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
188

19-
# Copy processed config from builder
20-
COPY --from=builder /root/erpc.yaml /root/erpc.yaml
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
2112

2213
# Run server
2314
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: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
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.
25

36
<a href="https://docs.erpc.cloud"><img alt="Docs" src="https://img.shields.io/badge/docs-get%20started-brightgreen"/></a>
47
[![Telegram chat][tg-badge]][tg-url]
@@ -8,13 +11,21 @@
811

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

11-
# License
14+
## Deployment
15+
16+
This repository is configured with GitHub Actions workflows that automatically deploy:
17+
- The eRPC server and monitoring stack to the development environment when code is pushed to the `dev` branch
18+
- The eRPC server and monitoring stack to the production environment when code is pushed to the `main` branch
19+
20+
The deployment uses Railway's service IDs to deploy the eRPC server and monitoring stack separately.
21+
22+
## License
1223

1324
Apache 2.0
1425

1526
[ci-badge]: https://img.shields.io/badge/CI-passing-brightgreen
1627
[ci-url]: https://github.com/erpc/erpc/actions/workflows/development.yml
17-
[tg-badge]: https://img.shields.io/endpoint?color=neon&logo=telegram&label=chat&url=https%3A%2F%2Fmogyo.ro%2Fquart-apis%2Ftgmembercount%3Fchat_id%3Derpc_cloud
28+
[tg-badge]: https://img.shields.io/endpoint?color=neon&logo=telegram&label=chat&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Ferpc_cloud
1829
[tg-url]: https://t.me/erpc_cloud
1930
[license-badge]: https://img.shields.io/github/license/erpc/erpc
2031
[license-url]: https://github.com/erpc/erpc/blob/main/LICENSE

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)