Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
02f8b00
added the github workflows to build the images
haouarihk Apr 8, 2025
c5cc08e
added helpful scripts to easily trigger the build workflows
haouarihk Apr 8, 2025
3751a0e
readme adding easier docker usage.
haouarihk Apr 8, 2025
b733075
adding support for multiple platforms
haouarihk Apr 8, 2025
d455fa6
added bulid enviroment variables
haouarihk Apr 8, 2025
09a1332
use @/lib/prisma instead of reinitializing prisma client.
haouarihk Apr 8, 2025
8386d81
fixed a logic bug here
haouarihk Apr 8, 2025
fd265b4
added postinstall for prisma to generate types
haouarihk Apr 8, 2025
4f2caac
build a standalone app
haouarihk Apr 8, 2025
9e85db8
fixed bug with libssl1.1 not found
haouarihk Apr 8, 2025
d7368c4
updated releases action
haouarihk Apr 8, 2025
63077fe
fixed bug with docker tags retrival
haouarihk Apr 8, 2025
9fb71c7
fixed bug repository name must be lowercase
haouarihk Apr 8, 2025
e67998e
why is this bug taking me soo long to fix
haouarihk Apr 8, 2025
957901e
forgot to uncomment this
haouarihk Apr 8, 2025
a80a6b8
reverting this change
haouarihk Apr 8, 2025
35700a1
added prisma files for a db push workaround
haouarihk Apr 8, 2025
846aa15
added prisma migration (for the run.dockerfile)
haouarihk Apr 8, 2025
adc0fcb
npm install -g prisma before switching users
haouarihk Apr 8, 2025
48947e9
added OLLAMA_BASE_URL env var
haouarihk Apr 8, 2025
9571fb6
reverting this
haouarihk Apr 8, 2025
02e7939
making validFrom optional
haouarihk Apr 8, 2025
31715f3
catching errors coming from calculating cost
haouarihk Apr 8, 2025
c6ecfb4
special case getModelCost for ollama
haouarihk Apr 8, 2025
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
13 changes: 13 additions & 0 deletions .env.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
OPENAI_API_KEY=
ANTHROPIC_API_KEY=
COHERE_API_KEY=
MISTRAL_API_KEY=
GROQ_API_KEY=

OLLAMA_BASE_URL=

# Dummy database URL
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres

# Build standalone
BUILD_STANDALONE=true
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ COHERE_API_KEY=your_cohere_api_key_here
MISTRAL_API_KEY=your_mistral_api_key_here
GROQ_API_KEY=your_groq_api_key_here

OLLAMA_BASE_URL=

DATABASE_URL=
60 changes: 60 additions & 0 deletions .github/workflows/docker-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Docker Nightly Build

on:
push:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '23'

- name: Install pnpm
run: npm install -g pnpm

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

- name: Use .env.build instead of .env
run: cp .env.build .env

- name: Install dependencies
run: pnpm install

- name: Build the project
run: pnpm run build

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

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=nightly

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: run.Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
59 changes: 59 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Docker Release Build

on:
push:
tags:
- 'v*-alpha'
- 'v*'

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '23'

- name: Install pnpm
run: npm install -g pnpm

- name: Checkout code
uses: actions/checkout@v3

- name: Use .env.build instead of .env
run: cp .env.build .env

- name: Extract Docker tags
run: |
chmod +x ./scripts/_github_action_tags_extractor.sh
./scripts/_github_action_tags_extractor.sh "${{ github.ref_name }}"

- name: Install dependencies
run: pnpm install

- name: Build the project
run: pnpm run build

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

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: run.Dockerfile
push: true
tags: ${{ env.DOCKER_TAGS }}
platforms: linux/amd64,linux/arm64
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ FROM node:18-alpine

WORKDIR /app

RUN apk add --no-cache libc6-compat
RUN apk update
RUN apk add --no-cache libc6-compat openssl

# Install pnpm
RUN npm install -g pnpm

# Copy package.json and pnpm-lock.yaml
COPY package.json pnpm-lock.yaml ./

# Install dependencies
RUN pnpm install
RUN pnpm fetch

# Copy the rest of the application
COPY . .

# Install dependencies
RUN pnpm install

# Generate Prisma Client
RUN pnpm prisma generate

Expand Down
54 changes: 53 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,58 @@ We are live on ProductHunt today, please upvote us if you find this useful! 🙏
- **AI Library**: Vercel AI SDK
- **Styling**: Tailwind CSS with shadcn/ui components

## Getting Started


## Getting Started (Using Docker Compose)

1. Create a new file named `docker-compose.yaml` in your project directory
2. Copy and paste the YAML configuration below into the file
3. Open a terminal in the project directory
4. Run the command:
```bash
docker compose up
```
(Optional: Add `-d` flag to run in detached mode)

```yaml
services:
cursorlens:
image: ghcr.io/haouarihk/cursorlens:latest
ports:
- "3000:3000"
environment:
- DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres
# restart: unless-stopped
depends_on:
db:
condition: service_healthy

db:
image: postgres:14
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
volumes:
- postgres_data:/var/lib/postgresql/data
# restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5

volumes:
postgres_data:
```
CursorLens provides different images for various release types:

- `nightly`: Latest development build
- `alpha`: Pre-release versions
- `stable`: Production-ready releases


## Getting Started (From Source)

For detailed installation instructions, please refer to our [Installation Guide](https://www.cursorlens.com/docs/getting-started/installation).

Expand Down Expand Up @@ -143,6 +194,7 @@ If you encounter any issues or have questions, please file an issue on the GitHu

For more detailed information, please visit our [documentation](https://www.cursorlens.com/docs/project/introduction).


---

Happy coding with Cursor Lens!
3 changes: 3 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const IsStandalone = process.env.BUILD_STANDALONE == "true";

/** @type {import('next').NextConfig} */
const nextConfig = {
typescript: {
ignoreBuildErrors: true,
},
output: IsStandalone ? "standalone" : undefined,
};

module.exports = nextConfig;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"test:coverage": "vitest run --coverage",
"test:ui": "vitest --ui",
"seed": "tsx prisma/seed.ts",
"update-log-costs": "tsx scripts/update-log-costs.ts"
"update-log-costs": "tsx scripts/update-log-costs.ts",
"postinstall": "npx prisma generate"
},
"prisma": {
"seed": "tsx prisma/seed.ts"
Expand Down
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ model ModelCost {
model String
inputTokenCost Float
outputTokenCost Float
validFrom DateTime
validFrom DateTime?
validTo DateTime?

@@unique([provider, model, validFrom])
Expand Down
32 changes: 32 additions & 0 deletions run.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This docker image does not build the application, it just runs it

FROM node:18-alpine

WORKDIR /app

RUN apk update
RUN apk add --no-cache libc6-compat openssl

ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

RUN npm install -g prisma

USER nextjs

COPY --chown=nextjs:nodejs ./public ./public
COPY --chown=nextjs:nodejs ./.next/standalone ./
COPY --chown=nextjs:nodejs ./.next/static ./.next/static
COPY --chown=nextjs:nodejs ./scripts ./scripts
RUN chmod -R 777 .next

# Copy the Prisma schema.
COPY --chown=nextjs:nodejs ./prisma ./prisma




CMD ["sh", "scripts/_docker_run.sh"]
10 changes: 10 additions & 0 deletions scripts/_docker_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

# Run migrations
npx prisma migrate deploy

# Seed the database
npx prisma db seed

# Start the application
node server.js
55 changes: 55 additions & 0 deletions scripts/_github_action_tags_extractor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

# Exit on error
set -e

# Check if tag name is provided
if [ -z "$1" ]; then
echo "Error: Tag name is required"
echo "Usage: $0 <tag_name>"
exit 1
fi

# Function to extract version from tag
extract_version() {
local tag=$1
# Remove 'v' prefix and any suffix after '-'
echo "$tag" | sed -E 's/^v//' | sed -E 's/-.*$//'
}

# Function to check if tag is alpha
is_alpha() {
local tag=$1
[[ "$tag" == *"-alpha" ]]
}

TAG_NAME=$1

# Extract version
VERSION=$(extract_version "$TAG_NAME")

# Convert repository name to lowercase
REPO_NAME=$(echo "$GITHUB_REPOSITORY" | tr '[:upper:]' '[:lower:]')

# Initialize tags array
TAGS=()

# Add appropriate tags based on tag type
if is_alpha "$TAG_NAME"; then
# For alpha releases
TAGS+=("ghcr.io/$REPO_NAME:$VERSION-alpha")
TAGS+=("ghcr.io/$REPO_NAME:alpha")
else
# For regular releases
TAGS+=("ghcr.io/$REPO_NAME:$VERSION")
TAGS+=("ghcr.io/$REPO_NAME:latest")
fi

# Convert array to comma-separated string
TAGS_STRING=$(IFS=,; echo "${TAGS[*]}")

# Export the tags as environment variable
echo "DOCKER_TAGS=$TAGS_STRING" >> $GITHUB_ENV

# Print for debugging
echo "Extracted tags: $TAGS_STRING"
21 changes: 21 additions & 0 deletions scripts/alpha-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

if [ -z "$1" ]; then
echo "Usage: $0 <version>"
echo "Example: $0 1.0.0"
exit 1
fi

VERSION=$1

# Validate version format (semantic versioning)
if ! [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Version must follow semantic versioning (e.g., 1.0.0)"
exit 1
fi

# Create and push the tag
git tag -a "v$VERSION-alpha" -m "Alpha release v$VERSION"
git push origin "v$VERSION-alpha"

echo "Created and pushed alpha release tag v$VERSION-alpha"
Loading