Skip to content

Commit

Permalink
Merge pull request #5 from PotLock/main
Browse files Browse the repository at this point in the history
v1
  • Loading branch information
elliotBraem authored Jan 29, 2025
2 parents a29ef9f + b51fc59 commit d223515
Show file tree
Hide file tree
Showing 188 changed files with 27,071 additions and 12,155 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,8 @@ frontend/**/*.sw?
# flyctl launch added from node_modules/tailwindcss/stubs/.gitignore
!node_modules/tailwindcss/stubs/**/*
fly.toml

# workspace
landing-page
docs
.github
28 changes: 28 additions & 0 deletions .github/near-rewards.yml
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
18 changes: 18 additions & 0 deletions .github/workflows/fly-deploy.yml
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 }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
**/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz
Expand Down Expand Up @@ -45,3 +45,7 @@ next-env.d.ts
.cache
.db
.turbo
landing-page/yarn.lock
package-lock.json
landing-page/bun.lockb
bun.lockb
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build
coverage
node_modules
.turbo
.next
.docusaurus
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Please follow the existing code style and conventions used in the project.

## Testing

This repository uses playwright tests, which can be found in [/playwright-tests](./playwright-tests/). Ensure that your changes include appropriate tests and that existing tests pass.
This repository uses tests located in the backend's `src/__tests__` directory. Ensure that your changes include appropriate tests and that existing tests pass.

## Submitting Issues

Expand Down
81 changes: 53 additions & 28 deletions Dockerfile
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"]
Loading

0 comments on commit d223515

Please sign in to comment.