Skip to content

Commit a03e876

Browse files
committed
Merge branch 'feature/backend-deployment'
2 parents f98aece + 07a88d6 commit a03e876

File tree

5 files changed

+100
-0
lines changed

5 files changed

+100
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Deploy Feed Data Service
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-latest
12+
environment: ${{ github.ref == 'refs/heads/main' && 'production' || 'staging' }}
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Copy backend code to server
19+
uses: appleboy/scp-action@v0.1.7
20+
with:
21+
host: ${{ secrets.SSH_HOST }}
22+
username: ${{ secrets.SSH_USER }}
23+
key: ${{ secrets.SSH_PRIVATE_KEY }}
24+
source: "backend/*"
25+
target: "/home/app/dashboard-demo/"
26+
strip_components: 0
27+
rm: true
28+
29+
- name: Create .env file on server
30+
uses: appleboy/ssh-action@v1.0.0
31+
with:
32+
host: ${{ secrets.SSH_HOST }}
33+
username: ${{ secrets.SSH_USER }}
34+
key: ${{ secrets.SSH_PRIVATE_KEY }}
35+
script: |
36+
cd /home/app/dashboard-demo/backend
37+
printf 'ARKIV_PRIVATE_KEY=%s\nETH_RPC_URL=%s\n' \
38+
"${{ secrets.ARKIV_PRIVATE_KEY }}" \
39+
"${{ vars.ETH_RPC_URL }}" > .env
40+
chmod 600 .env # Secure the .env file
41+
42+
- name: Deploy via SSH
43+
uses: appleboy/ssh-action@v1.0.0
44+
with:
45+
host: ${{ secrets.SSH_HOST }}
46+
username: ${{ secrets.SSH_USER }}
47+
key: ${{ secrets.SSH_PRIVATE_KEY }}
48+
script: |
49+
cd /home/app/dashboard-demo/backend
50+
docker compose build
51+
docker compose down
52+
docker compose up -d
53+
docker compose logs --tail=50 feed-data

backend/.dockerignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
node_modules
2+
dist
3+
*.tsbuildinfo
4+
.git
5+
.gitignore
6+
README.md
7+
.env
8+
.env.local
9+
*.log
10+
.DS_Store
11+

backend/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Use Bun as the base image
2+
FROM oven/bun:latest
3+
4+
# Set working directory
5+
WORKDIR /app
6+
7+
# Copy package files
8+
COPY package.json bun.lock ./
9+
10+
# Install dependencies
11+
RUN bun install --frozen-lockfile
12+
13+
# Copy source code
14+
COPY . .
15+
16+
# Set environment variables (can be overridden at runtime)
17+
ENV POLL_INTERVAL_MS=1000
18+
19+
# Run the feed-real-time script
20+
CMD ["bun", "run", "feed-real-time"]
21+

backend/docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
services:
2+
feed-data:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
container_name: dashboard-demo-feed-data
7+
restart: on-failure
8+
environment:
9+
- ARKIV_CHAIN=${ARKIV_CHAIN:-infurademo}
10+
- ARKIV_PRIVATE_KEY=${ARKIV_PRIVATE_KEY}
11+
- ETH_RPC_URL=${ETH_RPC_URL}
12+
- POLL_INTERVAL_MS=${POLL_INTERVAL_MS:-1000}
13+
env_file:
14+
- .env

backend/feedData.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ async function collectLatestOnce() {
235235
console.log("✅ Up to date; no new blocks to store");
236236
return { stored: 0 };
237237
}
238+
blocksToStore.reverse();
238239

239240
// Store in batches of 100
240241
console.log("\n💾 Storing new blocks in Arkiv...");

0 commit comments

Comments
 (0)