Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.
TypeScript agent-harnessagent-harness-engineeringai-engineeringai-observabilityamd-gpuclaude-codeclickhousecodexcoding-agentcoding-agentscursorgenaigpu-monitoringllm-observabilityllmopsnvidia-smiobservabilityopen-sourceopenaiopentelemetry
[Fix]: Reduce docker image size by from 3.5 GB to 601 MB (~83.26% reduction) (#812)
Aman Agarwalab45bdc8255f
diff --git a/src/client/.dockerignore b/src/client/.dockerignorenew file mode 100644index 00000000..841264b7--- /dev/null+++ b/src/client/.dockerignore@@ -0,0 +1,83 @@+# Dependencies+node_modules+npm-debug.log*+yarn-debug.log*+yarn-error.log*++# Build outputs+.next+out++# Environment files+.env*.local+.env++# Development files+.git+.gitignore+README.md+*.md++# IDE and editor files+.vscode+.idea+*.swp+*.swo++# OS generated files+.DS_Store+.DS_Store?+._*+.Spotlight-V100+.Trashes+ehthumbs.db+Thumbs.db++# Test files+coverage+__tests__+*.test.js+*.test.ts+*.spec.js+*.spec.ts++# Logs+logs+*.log+lerna-debug.log*++# Runtime data+pids+*.pid+*.seed+*.pid.lock++# Coverage directory used by tools like istanbul+coverage+*.lcov++# ESLint cache+.eslintcache++# Optional npm cache directory+.npm++# Optional REPL history+.node_repl_history++# Output of 'npm pack'+*.tgz++# Yarn Integrity file+.yarn-integrity++# parcel-bundler cache (https://parceljs.org/)+.cache+.parcel-cache++# Docker files+Dockerfile*+docker-compose*++# Documentation+docs\ No newline at end of filediff --git a/src/client/Dockerfile b/src/client/Dockerfileindex 10c5af06..d882baa9 100644--- a/src/client/Dockerfile+++ b/src/client/Dockerfile@@ -1,9 +1,24 @@# Use an alpine as a base image-FROM alpine as builder+FROM alpine AS builder# Installing node and npmRUN apk add --update nodejs npm++# Installing extra packages+RUN apk add --no-cache python3 py3-pip pipx rust cargo build-base+++# Create a virtual environment+RUN python3 -m venv /app/client/venv++# Install litellm inside the virtual environment+RUN /app/client/venv/bin/pip install --no-cache-dir litellm++RUN find /app/client/venv -name '*.pyc' -delete && \+ find /app/client/venv -name '__pycache__' -type d -exec rm -r {} +++# Set the working directory in the containerWORKDIR /app/client@@ -18,30 +33,33 @@ RUN npm install && npm run buildFROM alpine# Installing extra packages-RUN apk add --no-cache nodejs npm bash openssl python3 py3-pip pipx rust cargo build-base--# Create a virtual environment-RUN python3 -m venv /app/client/venv+RUN apk add nodejs bash openssl python3-# Install litellm inside the virtual environment-RUN /app/client/venv/bin/pip install --no-cache-dir litellm# Set the working directory in the containerWORKDIR /app/client# Copy only necessary files from the builder stage-COPY --from=builder /app/client/.next ./.next-COPY --from=builder /app/client/package.json ./package.json-COPY --from=builder /app/client/package-lock.json ./package-lock.json++# Copying python virtual environment+COPY --from=builder /app/client/venv ./venv+# Copying the standalone next.js build+COPY --from=builder /app/client/.next/standalone ./+# Standalone build doesn't copy public, static, prisma, scriptsCOPY --from=builder /app/client/public ./public+COPY --from=builder /app/client/.next/static ./.next/staticCOPY --from=builder /app/client/prisma ./prisma+COPY --from=builder /app/client/scripts ./scripts+# Copying prisma client, prisma and prisma cli (.bin) from builder stage+COPY --from=builder /app/client/node_modules/@prisma ./node_modules/@prisma+COPY --from=builder /app/client/node_modules/.bin ./node_modules/.bin+COPY --from=builder /app/client/node_modules/prisma ./node_modules/prisma# Execute entrypoint script to generate NextAuth.js secret and run commands-COPY --from=builder /app/client/scripts ./scriptsRUN chmod +x ./scripts/entrypoint.sh# Install Prisma globally-RUN npm install -g prisma+# RUN npm install -g [email protected]# Expose the port that Next.js will run onEXPOSE ${DOCKER_PORT:-3000}diff --git a/src/client/next.config.js b/src/client/next.config.jsindex 20b04e5f..de3be89b 100644--- a/src/client/next.config.js+++ b/src/client/next.config.js@@ -1,5 +1,6 @@/** @type {import('next').NextConfig} */const nextConfig = {+ output: "standalone",images: {remotePatterns: [{diff --git a/src/client/package-lock.json b/src/client/package-lock.jsonindex bd6d4460..fc6e519b 100644--- a/src/client/package-lock.json+++ b/src/client/package-lock.json@@ -1,12 +1,12 @@{"name": "openlit",- "version": "1.14.0",+ "version": "1.14.1","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "openlit",- "version": "1.14.0",+ "version": "1.14.1","dependencies": {"@anthropic-ai/sdk": "^0.21.1","@clickhouse/client": "^1.1.0",diff --git a/src/client/package.json b/src/client/package.jsonindex 23e54b50..12582d0d 100644--- a/src/client/package.json+++ b/src/client/package.json@@ -1,6 +1,6 @@{"name": "openlit",- "version": "1.14.0",+ "version": "1.14.1","private": true,"scripts": {"dev": "next dev",diff --git a/src/client/scripts/entrypoint.sh b/src/client/scripts/entrypoint.shindex 718e29bb..8fe35051 100755--- a/src/client/scripts/entrypoint.sh+++ b/src/client/scripts/entrypoint.sh@@ -8,6 +8,7 @@ export NEXTAUTH_SECRET=$(openssl rand -base64 32)echo "NEXTAUTH_SECRET=$NEXTAUTH_SECRET" >> /etc/environmentecho "NEXTAUTH_URL=http://localhost:${DOCKER_PORT:-3000}" >> /etc/environmentecho "SQLITE_DATABASE_URL=${SQLITE_DATABASE_URL:-file:../data/data.db}" >> /etc/environment+echo "PATH=./node_modules/.bin:$PATH" >> /etc/environment# Environment variables for DB configecho "INIT_DB_USERNAME=${INIT_DB_USERNAME}" >> /etc/environment@@ -31,4 +32,4 @@ crond &export PORT=${DOCKER_PORT:-3000}# Start the Next.js application-exec node --max_old_space_size=512 $(which npm) start+exec node --max_old_space_size=512 server.js