diff --git a/js/examples/langchain-express/.env.example b/js/examples/langchain-express/.env.example new file mode 100644 index 000000000..9847a1df1 --- /dev/null +++ b/js/examples/langchain-express/.env.example @@ -0,0 +1 @@ +OPENAI_API_KEY= \ No newline at end of file diff --git a/js/examples/langchain-express/README.md b/js/examples/langchain-express/README.md index b394b2552..57483a0f1 100644 --- a/js/examples/langchain-express/README.md +++ b/js/examples/langchain-express/README.md @@ -16,7 +16,9 @@ Open [http://localhost:3000](http://localhost:3000) with your browser to see the ## Getting Started With Docker-Compose -Ensure that Docker is installed and running. Run the command `docker compose up` to spin up services for the frontend, backend, and Phoenix. Once those services are running, open [http://localhost:3000](http://localhost:3000) to use the chat interface. When you're finished, run `docker compose down` to spin down the services. +Copy the `.env.example` file to `.env` and set your `OPENAI_API_KEY`. + +Ensure that Docker is installed and running. Run the command `docker compose up` to spin up services for the frontend, backend, and Phoenix. Once those services are running, open [http://localhost:3000](http://localhost:3000) to use the chat interface and [http://localhost:6006](http://localhost:6006) to view the Phoenix UI. When you're finished, run `docker compose down` to spin down the services. ## Learn More diff --git a/js/examples/langchain-express/backend/.dockerignore b/js/examples/langchain-express/backend/.dockerignore new file mode 100644 index 000000000..b512c09d4 --- /dev/null +++ b/js/examples/langchain-express/backend/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/js/examples/langchain-express/backend/Dockerfile b/js/examples/langchain-express/backend/Dockerfile index 86acb6256..d083c3286 100644 --- a/js/examples/langchain-express/backend/Dockerfile +++ b/js/examples/langchain-express/backend/Dockerfile @@ -6,13 +6,13 @@ FROM base AS deps RUN apk add --no-cache libc6-compat WORKDIR /app COPY package.json ./ -RUN npm i +RUN npm i --quiet # Rebuild the source code only when needed FROM base AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules -COPY . /app/ +COPY . . RUN npm run build # Production image, copy all the files and run the server @@ -20,7 +20,7 @@ FROM base AS runner WORKDIR /app ENV NODE_ENV production COPY --from=builder /app/dist ./dist -COPY package*.json ./ -RUN npm i --production +COPY --from=deps /app/node_modules ./node_modules +COPY package.json ./ EXPOSE 8000 CMD ["node", "--import", "./dist/instrumentation.cjs", "./dist/index.cjs"] diff --git a/js/examples/langchain-express/compose.yml b/js/examples/langchain-express/compose.yml index 6b54c5b33..ef76c8901 100644 --- a/js/examples/langchain-express/compose.yml +++ b/js/examples/langchain-express/compose.yml @@ -5,9 +5,12 @@ services: ports: - "6006:6006" backend: - build: backend + build: + context: backend + dockerfile: Dockerfile ports: - "8000:8000" + env_file: .env environment: - OPENAI_API_KEY=${OPENAI_API_KEY} - COLLECTOR_ENDPOINT=http://phoenix:6006/v1/traces @@ -18,7 +21,9 @@ services: timeout: 1s retries: 5 frontend: - build: frontend + build: + context: frontend + dockerfile: Dockerfile ports: - "3000:3000" depends_on: diff --git a/js/examples/langchain-express/frontend/.dockerignore b/js/examples/langchain-express/frontend/.dockerignore new file mode 100644 index 000000000..b512c09d4 --- /dev/null +++ b/js/examples/langchain-express/frontend/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/js/examples/langchain-express/frontend/Dockerfile b/js/examples/langchain-express/frontend/Dockerfile index f69d0ea58..1496439fb 100644 --- a/js/examples/langchain-express/frontend/Dockerfile +++ b/js/examples/langchain-express/frontend/Dockerfile @@ -7,7 +7,7 @@ FROM base AS deps RUN apk add --no-cache libc6-compat WORKDIR /app COPY package.json ./ -RUN npm i +RUN npm i --quiet # Rebuild the source code only when needed FROM base AS builder diff --git a/js/examples/llama-index-express/.env.example b/js/examples/llama-index-express/.env.example new file mode 100644 index 000000000..9847a1df1 --- /dev/null +++ b/js/examples/llama-index-express/.env.example @@ -0,0 +1 @@ +OPENAI_API_KEY= \ No newline at end of file diff --git a/js/examples/llama-index-express/README.md b/js/examples/llama-index-express/README.md index 82f4b8a51..4032f3f12 100644 --- a/js/examples/llama-index-express/README.md +++ b/js/examples/llama-index-express/README.md @@ -14,7 +14,9 @@ Open [http://localhost:3000](http://localhost:3000) with your browser to see the ## Getting Started With Docker-Compose -Ensure that Docker is installed and running. Run the command `docker compose up` to spin up services for the frontend, backend, and Phoenix. Once those services are running, open [http://localhost:3000](http://localhost:3000) to use the chat interface. When you're finished, run `docker compose down` to spin down the services. +Copy the `.env.example` file to `.env` and set your `OPENAI_API_KEY`. + +Ensure that Docker is installed and running. Run the command `docker compose up` to spin up services for the frontend, backend, and Phoenix. Once those services are running, open [http://localhost:3000](http://localhost:3000) to use the chat interface and [http://localhost:6006](http://localhost:6006) to view the Phoenix UI. When you're finished, run `docker compose down` to spin down the services. ## Learn More diff --git a/js/examples/llama-index-express/backend/.dockerignore b/js/examples/llama-index-express/backend/.dockerignore new file mode 100644 index 000000000..b512c09d4 --- /dev/null +++ b/js/examples/llama-index-express/backend/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/js/examples/llama-index-express/backend/Dockerfile b/js/examples/llama-index-express/backend/Dockerfile index e04d00815..2f2383e29 100644 --- a/js/examples/llama-index-express/backend/Dockerfile +++ b/js/examples/llama-index-express/backend/Dockerfile @@ -6,7 +6,7 @@ FROM base AS deps RUN apk add --no-cache libc6-compat WORKDIR /app COPY package*.json ./ -RUN npm ci +RUN npm i --quiet # Rebuild the source code only when needed FROM base AS builder @@ -20,7 +20,7 @@ FROM base AS runner WORKDIR /app ENV NODE_ENV production COPY --from=builder /app/dist ./dist +COPY --from=deps /app/node_modules ./node_modules COPY package*.json ./ -RUN npm i --production EXPOSE 8000 CMD ["node", "--import", "./dist/instrumentation.cjs", "./dist/index.cjs"] diff --git a/js/examples/llama-index-express/compose.yml b/js/examples/llama-index-express/compose.yml index 6b54c5b33..d615f4441 100644 --- a/js/examples/llama-index-express/compose.yml +++ b/js/examples/llama-index-express/compose.yml @@ -17,6 +17,7 @@ services: interval: 5s timeout: 1s retries: 5 + env_file: .env frontend: build: frontend ports: diff --git a/js/examples/llama-index-express/frontend/.dockerignore b/js/examples/llama-index-express/frontend/.dockerignore new file mode 100644 index 000000000..b512c09d4 --- /dev/null +++ b/js/examples/llama-index-express/frontend/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/js/examples/llama-index-express/frontend/Dockerfile b/js/examples/llama-index-express/frontend/Dockerfile index 912c0b084..0b8bd258d 100644 --- a/js/examples/llama-index-express/frontend/Dockerfile +++ b/js/examples/llama-index-express/frontend/Dockerfile @@ -7,7 +7,7 @@ FROM base AS deps RUN apk add --no-cache libc6-compat WORKDIR /app COPY package*.json ./ -RUN npm ci +RUN npm i --quiet # Rebuild the source code only when needed FROM base AS builder