Zero icon indicating copy to clipboard operation
Zero copied to clipboard

[Bug] docker-compose.prod.yml not working

Open SerhiiMandrykin opened this issue 5 months ago • 7 comments
trafficstars

Bug Description

The "production" docker compose file not working.

First, it looks like something is wrong with the Dockerfiles.

docker/app/Dockerfile:

# ========================================
# Base Stage: Alpine Linux with Bun
# ========================================
FROM oven/bun:alpine AS base

# ========================================
# Dependencies Stage: Install Dependencies
# ========================================
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install turbo globally
RUN bun install -g turbo

COPY package.json bun.lock turbo.json ./   <-- There is no bun.lock, please fix!
RUN mkdir -p apps packages
...

It results with the next issue:

serhii@ubuntu-horse:~/Zero$ docker compose -f docker-compose.prod.yaml --env-file .env up -d --build
WARN[0000] The "REDIS_URL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "RESEND_API_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "AI_SYSTEM_PROMPT" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GROQ_API_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_ELEVENLABS_AGENT_ID" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_IMAGE_PROXY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_POSTHOG_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_POSTHOG_HOST" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_IMAGE_API_URL" variable is not set. Defaulting to a blank string. 
Compose can now delegate builds to bake for better performance.
 To do so, set COMPOSE_BAKE=true.
[+] Building 0.9s (7/17)                                                                                                     docker:default
 => [migrations internal] load build definition from Dockerfile                                                                        0.0s
 => => transferring dockerfile: 1.17kB                                                                                                 0.0s
 => [migrations internal] load metadata for docker.io/oven/bun:alpine                                                                  0.8s
 => [migrations internal] load .dockerignore                                                                                           0.0s
 => => transferring context: 607B                                                                                                      0.0s
 => [migrations deps 1/7] FROM docker.io/oven/bun:alpine@sha256:b5d37e653d1b86f23c15ecac4f3f9b4a5572045f16258637e033a2b16b317926       0.0s
 => [migrations internal] load build context                                                                                           0.0s
 => => transferring context: 4.38kB                                                                                                    0.0s
 => CACHED [migrations deps 2/7] WORKDIR /app                                                                                          0.0s
 => ERROR [migrations deps 3/7] COPY package.json bun.lock turbo.json ./                                                               0.0s
------
 > [migrations deps 3/7] COPY package.json bun.lock turbo.json ./:
------
failed to solve: failed to compute cache key: failed to calculate checksum of ref 1e33501f-943d-4c85-8ec1-be81c5f9d5ac::d3g6kmvvmv0ke65wlvkztemnz: "/bun.lock": not found

The same goes for docker/db/Dockerfile

After fixing docker/app/Dockerfile and docker/db/Dockerfile I have the next output:

serhii@ubuntu-horse:~/Zero$ docker compose -f docker-compose.prod.yaml --env-file .env up -d --build
WARN[0000] The "AI_SYSTEM_PROMPT" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GROQ_API_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_IMAGE_API_URL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_POSTHOG_HOST" variable is not set. Defaulting to a blank string. 
WARN[0000] The "REDIS_URL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "RESEND_API_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_ELEVENLABS_AGENT_ID" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_IMAGE_PROXY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_POSTHOG_KEY" variable is not set. Defaulting to a blank string. 
Compose can now delegate builds to bake for better performance.
 To do so, set COMPOSE_BAKE=true.
[+] Building 4.1s (11/17)                                                                                                    docker:default
 => [migrations internal] load build definition from Dockerfile                                                                        0.0s
 => => transferring dockerfile: 1.17kB                                                                                                 0.0s
 => [migrations internal] load metadata for docker.io/oven/bun:alpine                                                                  0.4s
 => [migrations internal] load .dockerignore                                                                                           0.0s
 => => transferring context: 607B                                                                                                      0.0s
 => [migrations deps 1/7] FROM docker.io/oven/bun:alpine@sha256:b5d37e653d1b86f23c15ecac4f3f9b4a5572045f16258637e033a2b16b317926       1.9s
 => => resolve docker.io/oven/bun:alpine@sha256:b5d37e653d1b86f23c15ecac4f3f9b4a5572045f16258637e033a2b16b317926                       0.0s
 => => sha256:62356f85e740912b51294bb45438d2f2104105a250d5457364e42d4ef5a16627 36.40MB / 36.40MB                                       1.2s
 => => sha256:77d6ce0ce6b39652cebc70726cbc3c4b3c9843d2293835d631954feb7d78f0fc 297B / 297B                                             0.4s
 => => sha256:88dfff2e7338a6e3a112f5997d3d979e690d1cd93285de2bdf89f007320ff20b 4.03kB / 4.03kB                                         0.0s
 => => sha256:fd61622f12a6f0c01b3fe0e0c04a6fd4704a04983a95a35d61027af3d37437a5 1.43kB / 1.43kB                                         0.0s
 => => sha256:0a9a5dfd008f05ebc27e4790db0709a29e527690c21bcbcd01481eaeb6bb49dc 3.63MB / 3.63MB                                         0.4s
 => => sha256:b5d37e653d1b86f23c15ecac4f3f9b4a5572045f16258637e033a2b16b317926 1.61kB / 1.61kB                                         0.0s
 => => extracting sha256:0a9a5dfd008f05ebc27e4790db0709a29e527690c21bcbcd01481eaeb6bb49dc                                              0.1s
 => => sha256:59cf7c754d50140d27a6e6d033ff46a1f80adb60aa6e60166b6b5b364ecb9fc8 186B / 186B                                             0.6s
 => => sha256:fd02ec838fb13dc5769ce3c9d94799c9aa015d3daf597889f582f48e41b39da3 3.35MB / 3.35MB                                         0.7s
 => => sha256:0e2ec7292a19733bcb7c0ef6fed0cef77e00d43e5df05639411df86c53d880c2 141B / 141B                                             0.8s
 => => extracting sha256:62356f85e740912b51294bb45438d2f2104105a250d5457364e42d4ef5a16627                                              0.4s
 => => extracting sha256:77d6ce0ce6b39652cebc70726cbc3c4b3c9843d2293835d631954feb7d78f0fc                                              0.0s
 => => extracting sha256:59cf7c754d50140d27a6e6d033ff46a1f80adb60aa6e60166b6b5b364ecb9fc8                                              0.0s
 => => extracting sha256:fd02ec838fb13dc5769ce3c9d94799c9aa015d3daf597889f582f48e41b39da3                                              0.0s
 => => extracting sha256:0e2ec7292a19733bcb7c0ef6fed0cef77e00d43e5df05639411df86c53d880c2                                              0.0s
 => [migrations internal] load build context                                                                                           0.0s
 => => transferring context: 4.38kB                                                                                                    0.0s
 => [migrations deps 2/7] WORKDIR /app                                                                                                 0.1s
 => [migrations deps 3/7] COPY package.json turbo.json ./                                                                              0.0s
 => [migrations deps 4/7] COPY packages/db/package.json ./packages/db/                                                                 0.0s
 => [migrations deps 5/7] COPY packages/tsconfig/base.json ./packages/tsconfig/base.json                                               0.0s
 => [migrations deps 6/7] COPY packages/tsconfig/package.json ./packages/tsconfig/                                                     0.0s
 => ERROR [migrations deps 7/7] RUN bun install --omit dev --ignore-scripts &&     bun install --omit dev --ignore-scripts drizzle-ki  1.5s
------                                                                                                                                      
 > [migrations deps 7/7] RUN bun install --omit dev --ignore-scripts &&     bun install --omit dev --ignore-scripts drizzle-kit drizzle-orm postgres:                                                                                                                                   
0.127 bun install v1.2.14 (6a363a38)                                                                                                        
0.131 Resolving dependencies                                                                                                                
1.489 Resolved, downloaded and extracted [156]
1.489 error: Workspace dependency "@zero/tsconfig" not found
1.489 
1.489 Searched in "./*"
1.489 
1.489 Workspace documentation: https://bun.sh/docs/install/workspaces
1.489 
------
failed to solve: process "/bin/sh -c bun install --omit dev --ignore-scripts &&     bun install --omit dev --ignore-scripts drizzle-kit drizzle-orm postgres" did not complete successfully: exit code: 1

Steps to Reproduce

  1. Clone this repo
  2. Create .env file accorting to the docs
  3. Run docker compose -f docker-compose.prod.yaml --env-file .env up -d

Expected Behavior

Everything works

Actual Behavior

Nothing works

What browsers are you seeing the problem on?

No response

Application Version

main branch

Environment Information

  • OS: Mac OS
  • Docker

Relevant Log Output

serhii@ubuntu-horse:~/Zero$ docker compose -f docker-compose.prod.yaml --env-file .env up -d --build
WARN[0000] The "REDIS_URL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "RESEND_API_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "AI_SYSTEM_PROMPT" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GROQ_API_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_ELEVENLABS_AGENT_ID" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_IMAGE_PROXY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_POSTHOG_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_POSTHOG_HOST" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_IMAGE_API_URL" variable is not set. Defaulting to a blank string. 
Compose can now delegate builds to bake for better performance.
 To do so, set COMPOSE_BAKE=true.
[+] Building 0.9s (7/17)                                                                                                     docker:default
 => [migrations internal] load build definition from Dockerfile                                                                        0.0s
 => => transferring dockerfile: 1.17kB                                                                                                 0.0s
 => [migrations internal] load metadata for docker.io/oven/bun:alpine                                                                  0.8s
 => [migrations internal] load .dockerignore                                                                                           0.0s
 => => transferring context: 607B                                                                                                      0.0s
 => [migrations deps 1/7] FROM docker.io/oven/bun:alpine@sha256:b5d37e653d1b86f23c15ecac4f3f9b4a5572045f16258637e033a2b16b317926       0.0s
 => [migrations internal] load build context                                                                                           0.0s
 => => transferring context: 4.38kB                                                                                                    0.0s
 => CACHED [migrations deps 2/7] WORKDIR /app                                                                                          0.0s
 => ERROR [migrations deps 3/7] COPY package.json bun.lock turbo.json ./                                                               0.0s
------
 > [migrations deps 3/7] COPY package.json bun.lock turbo.json ./:
------
failed to solve: failed to compute cache key: failed to calculate checksum of ref 1e33501f-943d-4c85-8ec1-be81c5f9d5ac::d3g6kmvvmv0ke65wlvkztemnz: "/bun.lock": not found

After fixing docker/app/Dockerfile and docker/db/Dockerfile:

serhii@ubuntu-horse:~/Zero$ docker compose -f docker-compose.prod.yaml --env-file .env up -d --build
WARN[0000] The "AI_SYSTEM_PROMPT" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GROQ_API_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_IMAGE_API_URL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_POSTHOG_HOST" variable is not set. Defaulting to a blank string. 
WARN[0000] The "REDIS_URL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "RESEND_API_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_ELEVENLABS_AGENT_ID" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_IMAGE_PROXY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_POSTHOG_KEY" variable is not set. Defaulting to a blank string. 
Compose can now delegate builds to bake for better performance.
 To do so, set COMPOSE_BAKE=true.
[+] Building 4.1s (11/17)                                                                                                    docker:default
 => [migrations internal] load build definition from Dockerfile                                                                        0.0s
 => => transferring dockerfile: 1.17kB                                                                                                 0.0s
 => [migrations internal] load metadata for docker.io/oven/bun:alpine                                                                  0.4s
 => [migrations internal] load .dockerignore                                                                                           0.0s
 => => transferring context: 607B                                                                                                      0.0s
 => [migrations deps 1/7] FROM docker.io/oven/bun:alpine@sha256:b5d37e653d1b86f23c15ecac4f3f9b4a5572045f16258637e033a2b16b317926       1.9s
 => => resolve docker.io/oven/bun:alpine@sha256:b5d37e653d1b86f23c15ecac4f3f9b4a5572045f16258637e033a2b16b317926                       0.0s
 => => sha256:62356f85e740912b51294bb45438d2f2104105a250d5457364e42d4ef5a16627 36.40MB / 36.40MB                                       1.2s
 => => sha256:77d6ce0ce6b39652cebc70726cbc3c4b3c9843d2293835d631954feb7d78f0fc 297B / 297B                                             0.4s
 => => sha256:88dfff2e7338a6e3a112f5997d3d979e690d1cd93285de2bdf89f007320ff20b 4.03kB / 4.03kB                                         0.0s
 => => sha256:fd61622f12a6f0c01b3fe0e0c04a6fd4704a04983a95a35d61027af3d37437a5 1.43kB / 1.43kB                                         0.0s
 => => sha256:0a9a5dfd008f05ebc27e4790db0709a29e527690c21bcbcd01481eaeb6bb49dc 3.63MB / 3.63MB                                         0.4s
 => => sha256:b5d37e653d1b86f23c15ecac4f3f9b4a5572045f16258637e033a2b16b317926 1.61kB / 1.61kB                                         0.0s
 => => extracting sha256:0a9a5dfd008f05ebc27e4790db0709a29e527690c21bcbcd01481eaeb6bb49dc                                              0.1s
 => => sha256:59cf7c754d50140d27a6e6d033ff46a1f80adb60aa6e60166b6b5b364ecb9fc8 186B / 186B                                             0.6s
 => => sha256:fd02ec838fb13dc5769ce3c9d94799c9aa015d3daf597889f582f48e41b39da3 3.35MB / 3.35MB                                         0.7s
 => => sha256:0e2ec7292a19733bcb7c0ef6fed0cef77e00d43e5df05639411df86c53d880c2 141B / 141B                                             0.8s
 => => extracting sha256:62356f85e740912b51294bb45438d2f2104105a250d5457364e42d4ef5a16627                                              0.4s
 => => extracting sha256:77d6ce0ce6b39652cebc70726cbc3c4b3c9843d2293835d631954feb7d78f0fc                                              0.0s
 => => extracting sha256:59cf7c754d50140d27a6e6d033ff46a1f80adb60aa6e60166b6b5b364ecb9fc8                                              0.0s
 => => extracting sha256:fd02ec838fb13dc5769ce3c9d94799c9aa015d3daf597889f582f48e41b39da3                                              0.0s
 => => extracting sha256:0e2ec7292a19733bcb7c0ef6fed0cef77e00d43e5df05639411df86c53d880c2                                              0.0s
 => [migrations internal] load build context                                                                                           0.0s
 => => transferring context: 4.38kB                                                                                                    0.0s
 => [migrations deps 2/7] WORKDIR /app                                                                                                 0.1s
 => [migrations deps 3/7] COPY package.json turbo.json ./                                                                              0.0s
 => [migrations deps 4/7] COPY packages/db/package.json ./packages/db/                                                                 0.0s
 => [migrations deps 5/7] COPY packages/tsconfig/base.json ./packages/tsconfig/base.json                                               0.0s
 => [migrations deps 6/7] COPY packages/tsconfig/package.json ./packages/tsconfig/                                                     0.0s
 => ERROR [migrations deps 7/7] RUN bun install --omit dev --ignore-scripts &&     bun install --omit dev --ignore-scripts drizzle-ki  1.5s
------                                                                                                                                      
 > [migrations deps 7/7] RUN bun install --omit dev --ignore-scripts &&     bun install --omit dev --ignore-scripts drizzle-kit drizzle-orm postgres:                                                                                                                                   
0.127 bun install v1.2.14 (6a363a38)                                                                                                        
0.131 Resolving dependencies                                                                                                                
1.489 Resolved, downloaded and extracted [156]
1.489 error: Workspace dependency "@zero/tsconfig" not found
1.489 
1.489 Searched in "./*"
1.489 
1.489 Workspace documentation: https://bun.sh/docs/install/workspaces
1.489 
------
failed to solve: process "/bin/sh -c bun install --omit dev --ignore-scripts &&     bun install --omit dev --ignore-scripts drizzle-kit drizzle-orm postgres" did not complete successfully: exit code: 1

SerhiiMandrykin avatar May 26 '25 14:05 SerhiiMandrykin

The build fails because critical files are missing from the packages/db directory. Here's the key error:

failed to solve: failed to compute cache key: failed to calculate checksum of ref 9b76eb2b-cf5d-46b5-af67-66e32d6ae06c::ho0py1fvagwze5scixxpe8p1k: "/packages/db/package.json": not found

The packages/db directory currently only contains a node_modules folder.

The following files/directories are missing:

  • packages/db/package.json
  • packages/db/drizzle.config.ts
  • packages/db/src/
  • packages/db/migrations/

These are essential for the migrations service, which is responsible for handling database migrations and is built via a Dockerfile expecting the above files.

This prevents the successful build of the migrations container, which in turn blocks the main zero service from starting, due to this dependency:

depends_on:
  migrations:
    condition: service_completed_successfully

vagxrth avatar May 27 '25 03:05 vagxrth

We just updated how /packages are used, we'll update the docker file soon :)

MrgSub avatar May 27 '25 03:05 MrgSub

Got it!

vagxrth avatar May 27 '25 03:05 vagxrth

Thank you!

SerhiiMandrykin avatar May 27 '25 08:05 SerhiiMandrykin

Any updates on this??

SerhiiMandrykin avatar Jun 04 '25 19:06 SerhiiMandrykin

Hey. I see some fixed now merged in the staging branch. I tried to build it, looks good but the migrations service won't work.

Here are the logs:

docker compose -f docker-compose.prod.yaml logs migrations      
WARN[0000] The "NEXT_PUBLIC_POSTHOG_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GROQ_API_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_ELEVENLABS_AGENT_ID" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_POSTHOG_HOST" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_IMAGE_PROXY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "NEXT_PUBLIC_IMAGE_API_URL" variable is not set. Defaulting to a blank string. 
migrations-1  | 
migrations-1  | > @zero/server@ db:migrate /app/apps/server
migrations-1  | > drizzle-kit migrate
migrations-1  | 
migrations-1  | sh: drizzle-kit: not found
migrations-1  |  ELIFECYCLE  Command failed.
migrations-1  |  WARN   Local package.json exists, but node_modules missing, did you mean to install?

SerhiiMandrykin avatar Jun 12 '25 08:06 SerhiiMandrykin

This issue is stale (3+ days) and will be closed.

github-actions[bot] avatar Aug 10 '25 00:08 github-actions[bot]

Closing stale issue.

github-actions[bot] avatar Aug 10 '25 00:08 github-actions[bot]