Skip to content
Merged
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
3 changes: 2 additions & 1 deletion website/client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions website/client/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "repomix-website-client",
"private": true,
"type": "module",
"scripts": {
Expand Down
58 changes: 33 additions & 25 deletions website/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
# ==============================================================================
# Base image
# ==============================================================================
FROM node:23-alpine AS builder

# Install git and other dependencies
RUN apk add --no-cache \
git \
ca-certificates
FROM node:24-alpine AS builder

WORKDIR /app
COPY package*.json ./

# Install dependencies
RUN npm i
# Install all dependencies (including dev dependencies for build)
RUN npm ci

# Copy source code
COPY . .
Expand All @@ -21,33 +16,46 @@ COPY . .
RUN npm run build

# ==============================================================================
# Production image
# Production dependencies
# ==============================================================================
FROM node:24-alpine AS deps

WORKDIR /app
COPY package*.json ./

# Install only production dependencies
RUN npm ci --only=production --ignore-scripts && \
npm cache clean --force

# ==============================================================================
# Runtime image
# ==============================================================================
FROM node:23-alpine
FROM node:24-alpine

# Install git and ca-certificates (required by repomix for remote repository processing)
RUN apk add --no-cache git ca-certificates

# Install git and other dependencies
RUN apk add --no-cache \
git \
ca-certificates \
curl
# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001

WORKDIR /app

# Copy only necessary files
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/node_modules ./node_modules
# Copy built application
COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist

# Copy production dependencies
COPY --from=deps --chown=nodejs:nodejs /app/node_modules ./node_modules

# Set environment variables
ENV NODE_ENV=production \
PORT=8080

# Switch to non-root user
USER nodejs

# Expose port
EXPOSE 8080

# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1

# Start the server
CMD ["npm", "start"]
# Start the server directly
CMD ["node", "dist/index.js"]
4 changes: 2 additions & 2 deletions website/server/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ steps:
- '--memory'
- '2048Mi'
- '--cpu'
- '4'
- '2'
- '--min-instances'
- '0'
- '--max-instances'
- '10'
- '--timeout'
- '35s'
- '31s'
- '--ingress'
- 'all'
- '--allow-unauthenticated'
Expand Down
24 changes: 5 additions & 19 deletions website/server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions website/server/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "repomix-website-server",
"private": true,
"type": "module",
"scripts": {
Expand All @@ -15,15 +16,13 @@
"@hono/node-server": "^1.13.8",
"adm-zip": "^0.5.16",
"hono": "^4.6.20",
"pako": "^2.1.0",
"repomix": "^0.3.7",
"winston": "^3.17.0",
"zod": "^3.24.1"
},
"devDependencies": {
"@types/adm-zip": "^0.5.7",
"@types/node": "^22.13.0",
"@types/pako": "^2.0.3",
"rimraf": "^6.0.1",
"tsx": "^4.19.2",
"typescript": "^5.7.3"
Expand Down
4 changes: 2 additions & 2 deletions website/server/src/processZipFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function processZipFile(
);

// Check if the result is already cached
const cachedResult = cache.get(cacheKey);
const cachedResult = await cache.get(cacheKey);
if (cachedResult) {
return cachedResult;
}
Expand Down Expand Up @@ -123,7 +123,7 @@ export async function processZipFile(
};

// Save the result to cache
cache.set(cacheKey, packResultData);
await cache.set(cacheKey, packResultData);

return packResultData;
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions website/server/src/remoteRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function processRemoteRepo(
const cacheKey = generateCacheKey(validatedData.url, validatedData.format, validatedData.options, 'url');

// Check if the result is already cached
const cachedResult = cache.get(cacheKey);
const cachedResult = await cache.get(cacheKey);
if (cachedResult) {
return cachedResult;
}
Expand Down Expand Up @@ -100,7 +100,7 @@ export async function processRemoteRepo(
};

// Save the result to cache
cache.set(cacheKey, packResultData);
await cache.set(cacheKey, packResultData);

return packResultData;
} catch (error) {
Expand Down
20 changes: 12 additions & 8 deletions website/server/src/utils/cache.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import pako from 'pako';
import { promisify } from 'node:util';
import * as zlib from 'node:zlib';
import type { PackOptions } from '../types.js';

interface CacheEntry<T> {
const inflateAsync = promisify(zlib.inflate);
const deflateAsync = promisify(zlib.deflate);

interface CacheEntry {
value: Uint8Array; // Compressed data
timestamp: number;
}

export class RequestCache<T> {
private cache: Map<string, CacheEntry<T>> = new Map();
private cache: Map<string, CacheEntry> = new Map();
private readonly ttl: number;

constructor(ttlInSeconds = 60) {
Expand All @@ -17,7 +21,7 @@ export class RequestCache<T> {
setInterval(() => this.cleanup(), ttlInSeconds * 1000);
}

get(key: string): T | undefined {
async get(key: string): Promise<T | undefined> {
const entry = this.cache.get(key);
if (!entry) {
return undefined;
Expand All @@ -31,20 +35,20 @@ export class RequestCache<T> {

try {
// Decompress and return the data
const decompressedData = pako.inflate(entry.value, { to: 'string' });
return JSON.parse(decompressedData);
const decompressedData = await inflateAsync(entry.value);
return JSON.parse(decompressedData.toString('utf8'));
} catch (error) {
console.error('Error decompressing cache entry:', error);
this.cache.delete(key);
return undefined;
}
}

set(key: string, value: T): void {
async set(key: string, value: T): Promise<void> {
try {
// Convert data to JSON string and compress
const jsonString = JSON.stringify(value);
const compressedData = pako.deflate(jsonString);
const compressedData = await deflateAsync(Buffer.from(jsonString, 'utf8'));

this.cache.set(key, {
value: compressedData,
Expand Down
Loading