Skip to content

Commit

Permalink
feat: add indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
tnrdd committed May 6, 2024
1 parent f5f2c9d commit 74907f8
Show file tree
Hide file tree
Showing 18 changed files with 6,640 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
Dockerfile
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DATABASE_URI=postgres://postgres:postgres@localhost:5432/sqf-indexer
RPC_URL_SEPOLIA=
24 changes: 24 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Build
on:
push:
branches:
- "**"
- "!main"
pull_request:
branches:
- "**"
jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Docker Compose
uses: hoverkraft-tech/[email protected]
with:
compose-file: "./docker-compose.yaml"
env:
DATABASE_URI: ${{ secrets.DATABASE_URI }}
RPC_URL_SEPOLIA: ${{ secrets.RPC_URL_SEPOLIA }}
43 changes: 43 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build and Deploy
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Docker Compose
uses: hoverkraft-tech/[email protected]
with:
compose-file: "./docker-compose.yaml"
env:
DATABASE_URI: ${{ secrets.DATABASE_URI }}
RPC_URL_SEPOLIA: ${{ secrets.RPC_URL_SEPOLIA }}

deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up SSH key
run: |
mkdir ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -p 22 ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Deploy
run: |
ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} /bin/bash <<'ENDSSH'
cd ${{ secrets.APP_PATH }}
git pull origin main
export DATABASE_URI=${{ secrets.DATABASE_URI }}
export RPC_URL_SEPOLIA=${{ secrets.RPC_URL_SEPOLIA }}
docker compose -f docker-compose.yaml up -d --build
ENDSSH
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
.env
sqlite_cache
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:lts

# Create app directory
WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

# Bundle app source
COPY src src
COPY tsconfig.json ./

RUN npm run build

EXPOSE 3000

CMD [ "npm", "start" ]
26 changes: 26 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
services:
sqf-indexer:
build:
context: .
ports:
- '3000:3000'
command: npm run start
environment:
- NODE_ENV=production
- DATABASE_URI=${DATABASE_URI}
- RPC_URL_SEPOLIA=${RPC_URL_SEPOLIA}
volumes:
- sqlite_data:/sqlite_cache
db:
image: postgres:14
ports:
- "5432:5432"
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=sqf-indexer
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
sqlite_data:
10 changes: 10 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";


export default [
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
];
Loading

0 comments on commit 74907f8

Please sign in to comment.