Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# ── VCS ──────────────────────────────────────────────────────────────────────
.git
.gitignore

# ── Dependencies (Docker installs these inside the image) ─────────────────────
node_modules
**/node_modules

# ── Build artefacts ───────────────────────────────────────────────────────────
**/dist
**/.next
**/build

# ── Env files (keep secrets out of the image) ─────────────────────────────────
.env
.env.*
!.env.example

# ── Editor / OS noise ─────────────────────────────────────────────────────────
.DS_Store
Thumbs.db
.vscode
.idea
.cursor

# ── Logs ──────────────────────────────────────────────────────────────────────
*.log
logs/

# ── Turbo cache ───────────────────────────────────────────────────────────────
.turbo
19 changes: 19 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ─── PostgreSQL ───────────────────────────────────────────────────────────────
POSTGRES_USER=openrouter
POSTGRES_PASSWORD=openrouter_secret
POSTGRES_DB=openrouterdb

# Full connection URL used by Prisma in both backends
DATABASE_URL=postgresql://openrouter:openrouter_secret@postgres:5432/openrouterdb

# ─── Primary Backend ─────────────────────────────────────────────────────────
JWT_SECRET=changeme_replace_with_32_char_random_string

# ─── AI Provider Keys (api-backend) ──────────────────────────────────────────
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
GOOGLE_API_KEY=AIza...

# ─── Frontend URLs ────────────────────────────────────────────────────────────
PRIMARY_BACKEND_URL=http://localhost:3000
API_BACKEND_URL=http://localhost:4000
45 changes: 45 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Deploy to Docker Hub

on:
push:
branches: [main]

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push primary-backend
uses: docker/build-push-action@v6
with:
context: .
file: ./apps/primary-backend/Dockerfile
push: true
tags: sujaljain989/openrouter-primary-backend:latest

- name: Build and push api-backend
uses: docker/build-push-action@v6
with:
context: .
file: ./apps/api-backend/Dockerfile
push: true
tags: sujaljain989/openrouter-api-backend:latest

- name: Build and push dashboard-frontend
uses: docker/build-push-action@v6
with:
context: .
file: ./apps/dashboard-frontend/Dockerfile
push: true
tags: sujaljain989/openrouter-dashboard-frontend:latest
55 changes: 55 additions & 0 deletions NPM_TROUBLESHOOTING_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Node.js Troubleshooting & Installation Guide (Windows)

Saved this guide as a reference for resolving common installation issues (`EACCES`, `EPERM`, `node_modules` conflicts) in any Node.js project.

## 🛠️ The "Nuclear" Reset Command
Run this in **PowerShell (Run as Administrator)** to completely reset your environment and reinstall:

```powershell
# Delete node_modules and lock files, clean cache, and reinstall
rm -Force -Recurse node_modules; rm -Force bun.lock, package-lock.json; npm cache clean --force; npm install
```

---

## 📋 Step-by-Step Breakdown

### 1. Identify the Right Package Manager
Before running commands, check which file exists in the project root:
- `package-lock.json` → Use **NPM** (`npm install`)
- `yarn.lock` → Use **Yarn** (`yarn install`)
- `pnpm-lock.yaml` → Use **PNPM** (`pnpm install`)
- `bun.lock / bun.lockb` → Use **Bun** (`bun install`)

### 2. Resolution Levels

#### Level 1: Simple Reinstall (Try this first)
Recommended if you just suspect a single corrupt package.
```powershell
rm -Force -Recurse node_modules
npm install
```

#### Level 2: Clean slate with cache refresh
Recommended for `EACCES` or "permission denied" errors.
```powershell
rm -Force -Recurse node_modules
npm cache clean --force
npm install
```

#### Level 3: Full Reset (The "Nuclear" option)
Only use this if Level 1 & 2 fail, or if you have major version conflicts.
```powershell
rm -Force -Recurse node_modules
rm -Force package-lock.json # WARNING: This updates all package versions to the latest allowed
npm cache clean --force
npm install
```

---

## 💡 Pro-Tips to Avoid Errors
- **Run as Administrator**: Right-click your Terminal/PowerShell and select "Run as Administrator". This prevents 90% of `EACCES` errors on Windows.
- **Close Editor/Dev Servers**: Ensure VS Code, a running `npm run dev` server, or your antivirus isn't "locking" the `node_modules` folder while you install.
- **Node Version**: If a project fails to build, check if you have the correct Node version installed (`node -v`). Many projects specify a version in `package.json` under `"engines"`.
1 change: 1 addition & 0 deletions api_log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Error response from daemon: No such container: openrouter_api_backend
48 changes: 48 additions & 0 deletions apps/api-backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# ─── Stage 1: Install dependencies ───────────────────────────────────────────
FROM oven/bun:1.3.3-alpine AS deps

WORKDIR /app

COPY package.json package-lock.json ./

COPY packages/db/package.json ./packages/db/
COPY packages/eslint-config/package.json ./packages/eslint-config/
COPY packages/typescript-config/package.json ./packages/typescript-config/
COPY packages/ui/package.json ./packages/ui/
COPY apps/api-backend/package.json ./apps/api-backend/

RUN bun install

# ─── Stage 2: Generate Prisma client ─────────────────────────────────────────
FROM oven/bun:1.3.3-alpine AS builder

WORKDIR /app

# Copy node_modules and manifests from deps
COPY --from=deps /app/ ./

# Overlay source code
COPY packages/db/ ./packages/db/
COPY packages/typescript-config/ ./packages/typescript-config/
COPY apps/api-backend/ ./apps/api-backend/

# Generate Prisma client
RUN cd packages/db && bunx prisma generate --schema=prisma/schema.prisma

# ─── Stage 3: Production runner ───────────────────────────────────────────────
FROM oven/bun:1.3.3-alpine AS runner

WORKDIR /app

ENV NODE_ENV=production

COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/packages ./packages
COPY --from=builder /app/apps ./apps
COPY --from=builder /app/package.json ./

WORKDIR /app/apps/api-backend

EXPOSE 4000

CMD ["bun", "run", "src/index.ts"]
4 changes: 2 additions & 2 deletions apps/api-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"openai": "^6.22.0"
},
"devDependencies": {
"bun-types": "latest"
"@types/bun": "latest"
},
"module": "src/index.js"
}
}
Loading