🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(docker): remove the need for runtime variables at build time (#1067)
Yash Khare0c1942c2b388
diff --git a/.env.dev.example b/.env.dev.exampleindex 284dbcd75f..d4644213ec 100644--- a/.env.dev.example+++ b/.env.dev.example@@ -29,4 +29,8 @@ S3_ENDPOINT=S3_ACCESS_KEY_ID=S3_SECRET_ACCESS_KEY=S3_BUCKET_NAME=-S3_REGION=\ No newline at end of file+S3_REGION=++# Set during docker build of application+# Used to disable environment verification at build time+# DOCKER_BUILD=1\ No newline at end of filediff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.ymlindex 2f98ccdc6c..fae57586e7 100644--- a/.github/workflows/pipeline.yml+++ b/.github/workflows/pipeline.yml@@ -33,10 +33,6 @@ jobs:test-docker-build:runs-on: ubuntu-latestenv:- DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres- NEXTAUTH_SECRET: "secret"- SALT: "salt"- NEXTAUTH_URL: "http://localhost:3030"REGISTRY: ghcr.ioIMAGE_NAME: ${{ github.repository }}@@ -54,11 +50,6 @@ jobs:with:context: .push: false- build-args: |- DATABASE_URL=${{ env.DATABASE_URL }}- NEXTAUTH_SECRET=${{ env.NEXTAUTH_SECRET }}- NEXTAUTH_URL=${{ env.NEXTAUTH_URL }}- SALT=${{ env.SALT }}tests:runs-on: ubuntu-latest@@ -152,10 +143,6 @@ jobs:environment: "protected branches"runs-on: ubuntu-latestenv:- DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres- NEXTAUTH_SECRET: "secret"- SALT: "salt"- NEXTAUTH_URL: "http://localhost:3030"REGISTRY: ghcr.ioIMAGE_NAME: ${{ github.repository }}permissions:@@ -198,8 +185,3 @@ jobs:push: truetags: ${{ steps.meta.outputs.tags }}labels: ${{ steps.meta.outputs.labels }}- build-args: |- DATABASE_URL=${{ env.DATABASE_URL }}- NEXTAUTH_SECRET=${{ env.NEXTAUTH_SECRET }}- NEXTAUTH_URL=${{ env.NEXTAUTH_URL }}- SALT=${{ env.SALT }}diff --git a/Dockerfile b/Dockerfileindex 5dba0745be..dc11b77301 100644--- a/Dockerfile+++ b/Dockerfile@@ -1,19 +1,11 @@# Base imageFROM node:20-alpine AS base-ARG DATABASE_URL-ARG NEXTAUTH_SECRET-ARG NEXTAUTH_URL-ARG SALT# It's important to update the index before installing packages to ensure you're getting the latest versions.# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.RUN apk update && apk upgrade --no-cache libcrypto3 libssl3 libc6-compatFROM base AS deps-ARG DATABASE_URL-ARG NEXTAUTH_SECRET-ARG NEXTAUTH_URL-ARG SALTWORKDIR /app@@ -29,10 +21,6 @@ RUN \# Rebuild the source code only when neededFROM base AS builder-ARG DATABASE_URL-ARG NEXTAUTH_SECRET-ARG NEXTAUTH_URL-ARG SALTWORKDIR /appCOPY --from=deps /app/node_modules ./node_modules@@ -46,6 +34,9 @@ RUN rm -f ./src/middleware.ts# Uncomment the following line in case you want to disable telemetry during the build.ENV NEXT_TELEMETRY_DISABLED 1+# Disable validation of environment variables during build+ENV DOCKER_BUILD 1+# Generate prisma clientRUN npx prisma generate@@ -54,10 +45,6 @@ RUN npm run build# Production image, copy all the files and run nextFROM base AS runner-ARG DATABASE_URL-ARG NEXTAUTH_SECRET-ARG NEXTAUTH_URL-ARG SALTRUN apk add --no-cache dumb-init@@ -66,6 +53,8 @@ WORKDIR /appENV NODE_ENV production# Uncomment the following line in case you want to disable telemetry during runtime.ENV NEXT_TELEMETRY_DISABLED 1+# Needed to re-enable validation of environment variables during runtime+ENV DOCKER_BUILD 0RUN addgroup --system --gid 1001 nodejsRUN adduser --system --uid 1001 nextjsdiff --git a/docker-compose.build.yml b/docker-compose.build.ymlindex c59c3d63eb..5349b77b64 100644--- a/docker-compose.build.yml+++ b/docker-compose.build.yml@@ -4,17 +4,11 @@ services:langfuse-server:build:dockerfile: Dockerfile- args:- - DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres- - NEXTAUTH_SECRET=mysecret- - SALT=mysalt- - NEXTAUTH_URL=http://localhost:3000depends_on:- dbports:- "3000:3000"environment:- - NODE_ENV=production- DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres- NEXTAUTH_SECRET=mysecret- SALT=mysaltdiff --git a/docker-compose.yml b/docker-compose.ymlindex 347d5d4740..c7a7e4849b 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -8,7 +8,6 @@ services:ports:- "3000:3000"environment:- - NODE_ENV=production- DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres- NEXTAUTH_SECRET=mysecret- SALT=mysaltdiff --git a/src/env.mjs b/src/env.mjsindex 9fd9e2be6e..d8f8692534 100644--- a/src/env.mjs+++ b/src/env.mjs@@ -125,4 +125,7 @@ export const env = createEnv({// Database exportsDB_EXPORT_PAGE_SIZE: process.env.DB_EXPORT_PAGE_SIZE,},+ // Skip validation in Docker builds+ // DOCKER_BUILD is set in Dockerfile+ skipValidation: process.env.DOCKER_BUILD === "1",});