generated from NEARBuilders/project-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from PotLock/main
v1
- Loading branch information
Showing
188 changed files
with
27,071 additions
and
12,155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: NEAR Protocol Rewards Tracking | ||
on: | ||
schedule: | ||
- cron: '0 */12 * * *' # Every 12 hours | ||
workflow_dispatch: # Manual trigger | ||
push: | ||
branches: [ main ] # Start on main branch updates | ||
|
||
jobs: | ||
calculate-rewards: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
issues: read | ||
pull-requests: read | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Calculate Rewards | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_REPO: ${{ github.repository }} | ||
run: | | ||
npm install -g near-protocol-rewards@latest | ||
near-protocol-rewards calculate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/ | ||
|
||
name: Fly Deploy | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
deploy: | ||
name: Deploy app | ||
runs-on: ubuntu-latest | ||
concurrency: deploy-group # optional: ensure only one action runs at a time | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: superfly/flyctl-actions/setup-flyctl@master | ||
- run: flyctl deploy --remote-only | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
build | ||
coverage | ||
node_modules | ||
.turbo | ||
.next | ||
.docusaurus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,77 @@ | ||
FROM oven/bun as deps | ||
## NOTE | ||
# This Dockerfile builds the frontend and backend separately, | ||
# frontend uses npm and backend requires bun. | ||
# This separation is a temporary solution for a Bun issue with rsbuild, | ||
# see: https://github.com/oven-sh/bun/issues/11628 | ||
|
||
# Frontend deps & build stage | ||
FROM node:20 as frontend-builder | ||
WORKDIR /app | ||
|
||
# Copy package files for all workspaces | ||
COPY package.json bun.lockb turbo.json ./ | ||
# Copy frontend package files | ||
COPY frontend/package.json ./frontend/ | ||
COPY backend/package.json ./backend/ | ||
|
||
# Install dependencies | ||
RUN bun install | ||
# Install frontend dependencies | ||
RUN cd frontend && npm install | ||
|
||
# Copy frontend source code | ||
COPY frontend ./frontend | ||
|
||
# Build frontend | ||
RUN cd frontend && npm run build | ||
|
||
# Build stage | ||
FROM oven/bun as builder | ||
# Backend deps & build stage | ||
FROM oven/bun as backend-builder | ||
WORKDIR /app | ||
|
||
# Set NODE_ENV for build process | ||
ENV NODE_ENV="production" | ||
# Copy backend package files | ||
COPY package.json ./ | ||
COPY backend/package.json ./backend/ | ||
COPY backend/drizzle.config.ts ./backend/ | ||
|
||
# Copy all files from deps stage including node_modules | ||
COPY --from=deps /app ./ | ||
# Install backend dependencies | ||
RUN cd backend && bun install | ||
|
||
# Copy source code | ||
COPY . . | ||
# Copy backend source code | ||
COPY backend ./backend | ||
|
||
# Build both frontend and backend | ||
RUN bun run build | ||
# Build backend | ||
RUN cd backend && bun run build | ||
|
||
# Production stage | ||
FROM oven/bun as production | ||
WORKDIR /app | ||
|
||
# Create directory for mount with correct permissions | ||
RUN mkdir -p /.data/db /.data/cache && \ | ||
chown -R bun:bun /.data | ||
# Install LiteFS dependencies | ||
RUN apt-get update -y && apt-get install -y ca-certificates fuse3 sqlite3 | ||
|
||
# Copy only necessary files from builder | ||
COPY --from=builder --chown=bun:bun /app/package.json /app/bun.lockb /app/turbo.json ./ | ||
COPY --from=builder --chown=bun:bun /app/node_modules ./node_modules | ||
COPY --from=builder --chown=bun:bun /app/frontend/dist ./frontend/dist | ||
COPY --from=builder --chown=bun:bun /app/backend/dist ./backend/dist | ||
# Copy LiteFS binary | ||
COPY --from=flyio/litefs:0.5 /usr/local/bin/litefs /usr/local/bin/litefs | ||
|
||
# Create directories for mounts with correct permissions | ||
RUN mkdir -p /litefs /var/lib/litefs && \ | ||
chown -R bun:bun /litefs /var/lib/litefs | ||
|
||
# Create volume mount points | ||
# Copy only necessary files from builders | ||
COPY --from=backend-builder --chown=bun:bun /app/package.json ./ | ||
COPY --chown=bun:bun curate.config.json ./ | ||
|
||
COPY --from=frontend-builder --chown=bun:bun /app/frontend/dist ./frontend/dist | ||
COPY --from=backend-builder --chown=bun:bun /app/backend ./backend | ||
|
||
RUN cd backend && bun install | ||
|
||
# Set environment variables | ||
ENV DATABASE_URL="file:/.data/db/sqlite.db" | ||
ENV CACHE_DIR="/.data/cache" | ||
ENV DATABASE_URL="file:/litefs/db" | ||
ENV NODE_ENV="production" | ||
ENV FRONTEND_DIST_PATH="/app/frontend/dist" | ||
|
||
# Expose the port | ||
EXPOSE 3000 | ||
|
||
# Start the application using the production start script | ||
CMD ["bun", "run", "start"] | ||
# Copy LiteFS configuration | ||
COPY --chown=bun:bun litefs.yml /etc/litefs.yml | ||
|
||
# Start LiteFS (runs app with distributed file system for SQLite) | ||
ENTRYPOINT ["litefs", "mount"] |
Oops, something went wrong.