bolt.diy: 🐞 Docker compose up failing

Describe the bug

Environment: Windows 11 Docker OS: Linux

When attempting to build and bring up a local docker container, failures occur. See steps below

Link to the Bolt URL that caused the error

n/a

Steps to reproduce

I execute the following commands:

docker compose build
docker compose up

Expected behavior

The docker container should be running and I should be access the web application

Screen Recording / Screenshot

image

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

I have all firewalls disabled…as far as I know

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17

Most upvoted comments

Ok I found the issue for the docker compose. However it doesn’t solve the Ollama problem.

.env.local is expected into /app. So I have added a volume binding like so:

services:
  bolt-app:
    build:
      context: .
      dockerfile: Dockerfile
    env_file:
      - .env.local
    volumes:
      - ./.env.local:/app/.env.local
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=production
      # Add any other environment variables your app needs
      - OPENAI_API_KEY=${OPENAI_API_KEY}
      # - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
      # - GROQ_API_KEY=${GROQ_API_KEY}
      # - OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY}
    command: pnpm run start

Same issue with me.
The env file is properly named : .env.local. I am using docker compose without any change except uncommenting openAI api key line.
And please note that I am using WSL2.

Container is launching but:

  1. env file is not taken into consideration therefore openAI doesn’t work
  2. When Ollama provider is selected, bolt complains about Anthropic key not being available.

There are several trackers reporting similar issues. But I couldn’t make it work at all with current main branch.

[EDIT] Same error directly on Windows (not using WSL2).

Here are the logs:

PS C:\Users\bastien\bolt> docker compose up
time="2024-10-28T13:50:37+01:00" level=warning msg="The \"OPENAI_API_KEY\" variable is not set. Defaulting to a blank string."
[+] Running 2/0
 ✔ Network bolt_default       Created                                                                                                                                                                                                                                              0.0s
 ✔ Container bolt-bolt-app-1  Created                                                                                                                                                                                                                                              0.0s
Attaching to bolt-app-1
bolt-app-1  |
bolt-app-1  | > bolt@ start /app
bolt-app-1  | > bindings=$(./bindings.sh) && wrangler pages dev ./build/client $bindings --ip 0.0.0.0 --port 3000
bolt-app-1  |
bolt-app-1  | ./bindings.sh: line 12: .env.local: No such file or directory
bolt-app-1  |
bolt-app-1  |  ⛅️ wrangler 3.63.2 (update available 3.83.0)
bolt-app-1  | ---------------------------------------------
bolt-app-1  |
bolt-app-1  | ✨ Compiled Worker successfully
bolt-app-1  | [wrangler:inf] Ready on http://0.0.0.0:3000
[wrangler:inf] - http://127.0.0.1:3000
[wrangler:inf] - http://192.168.32.2:3000
⎔ Starting local server...
[wrangler:inf] GET / 200 OK (31ms)
[wrangler:inf] GET /assets/ReactToastify-CYivYX3d.css 200 OK (21ms)
[wrangler:inf] GET /assets/manifest-1413ea20.js 200 OK (13ms)
[wrangler:inf] GET /assets/index-CPTzpSUP.css 200 OK (32ms)
[wrangler:inf] GET /assets/root-BAISjcDY.css 200 OK (18ms)
[wrangler:inf] GET /assets/tailwind-compat-CC20SAMN.css 200 OK (22ms)
[wrangler:inf] GET /assets/xterm-lQO2bNqs.css 200 OK (181ms)
[wrangler:inf] GET /assets/theme-C4y9B7zS.js 200 OK (148ms)
[wrangler:inf] GET /assets/entry.client-ydwSl9ol.js 200 OK (156ms)
[wrangler:inf] GET /assets/components-bNrEeZYQ.js 200 OK (155ms)
[wrangler:inf] GET /assets/_index-D_NZK3VS.css 200 OK (184ms)
[wrangler:inf] GET /assets/root-CTO1zTZC.js 200 OK (8ms)
[wrangler:inf] GET /assets/_index-DOuhnEU5.js 200 OK (82ms)
[wrangler:inf] GET /assets/_index-8VnvuZ5T.js 200 OK (242ms)
[wrangler:inf] GET /assets/dark-plus-KEYLhlmT.js 200 OK (17ms)
[wrangler:inf] GET /assets/light-plus-BsvsQ1iS.js 200 OK (11ms)
[wrangler:inf] GET /assets/shellscript-BZfs-ost.js 200 OK (13ms)
[wrangler:inf] GET /assets/wasm-CsTmP73Z.js 200 OK (21ms)
LoadAPIKeyError [AI_LoadAPIKeyError]: OpenAI API key is missing. Pass it using the 'apiKey' parameter. Environment variables is not supported in this environment.
bolt-app-1  |     at loadApiKey (file:///app/node_modules/.pnpm/@ai-sdk+provider-utils@1.0.20_zod@3.23.8/node_modules/@ai-sdk/provider-utils/src/load-api-key.ts:25:11)
bolt-app-1  |     at Object.getHeaders [as headers] (file:///app/node_modules/.pnpm/@ai-sdk+openai@0.0.66_zod@3.23.8/node_modules/@ai-sdk/openai/src/openai-provider.ts:145:30)
bolt-app-1  |     at OpenAIChatLanguageModel.doStream (file:///app/node_modules/.pnpm/@ai-sdk+openai@0.0.66_zod@3.23.8/node_modules/@ai-sdk/openai/src/openai-chat-language-model.ts:391:43)
bolt-app-1  |     at fn (file:///app/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/core/generate-text/stream-text.ts:345:35)
bolt-app-1  |     at null.<anonymous> (file:///app/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/core/telemetry/record-span.ts:18:28)
bolt-app-1  |     at Object.startActiveSpan (file:///app/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/core/telemetry/noop-tracer.ts:21:14)
bolt-app-1  |     at recordSpan (file:///app/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/core/telemetry/record-span.ts:16:17)
bolt-app-1  |     at null.<anonymous> (file:///app/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/core/generate-text/stream-text.ts:311:11)
bolt-app-1  |     at _retryWithExponentialBackoff (file:///app/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/util/retry-with-exponential-backoff.ts:37:18)
bolt-app-1  |     at null.<anonymous> (file:///app/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/util/retry-with-exponential-backoff.ts:21:5) {
bolt-app-1  |   cause: undefined,
bolt-app-1  |   [Symbol(vercel.ai.error)]: true,
bolt-app-1  |   [Symbol(vercel.ai.error.AI_LoadAPIKeyError)]: true
bolt-app-1  | }
[wrangler:inf] POST /api/chat 500 Internal Server Error (15ms)

Your issue and I am almost 100% positive is because you aren’t naming your env file properly. You probably have something like .env but it is looking for .env.local.

I encountered the EXACT same error as you. But one thing you notice when you run “preview” is it will literally tell you that you are missing .env.local.

image

If you simply change your .env file name to .env.local

it will run perfect with pnmp run start

image

BOOM Goes the Dynamite!!!