Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yarn build-docker failed (copy-db-files.js) - Error: Missing or invalid database #1735

Closed
benricok opened this issue Jan 6, 2023 · 1 comment

Comments

@benricok
Copy link

benricok commented Jan 6, 2023

Hi there, awesome app!

I wanted to deploy umami via docker on an arm64 machine (oracle cloud instance), but realised no arm64 image is available officially. So, I proceded to build the image with the docker file and got a yarn build error.

Steps I followed:

  1. Clone repository
  2. Edit docker-compose.yml to replace the image tag with build: .
---
version: '3'
services:
  umami:
    build: .
    #image: ghcr.io/umami-software/umami:postgresql-latest
    ports:
      - "3000:3000"
    environment:
      DATABASE_URL: postgresql://umami:umami@db:5432/umami
      DATABASE_TYPE: postgresql
      HASH_SALT: replace-me
    depends_on:
      - db
    restart: always
  db:
    image: postgres:12-alpine
    environment:
      POSTGRES_DB: umami
      POSTGRES_USER: umami
      POSTGRES_PASSWORD: umami
    volumes:
      - ./sql/schema.postgresql.sql:/docker-entrypoint-initdb.d/schema.postgresql.sql:ro
      - umami-db-data:/var/lib/postgresql/data
    restart: always
volumes:
  umami-db-data:
  1. Run docker compose up -d

Error:

[+] Building 181.0s (16/23)                                                                                                                                                                                                        
 => [internal] load build definition from Dockerfile                                                                                                                                                                          0.1s
 => => transferring dockerfile: 1.60kB                                                                                                                                                                                        0.0s
 => [internal] load .dockerignore                                                                                                                                                                                             0.1s
 => => transferring context: 109B                                                                                                                                                                                             0.0s
 => [internal] load metadata for docker.io/library/node:16-alpine                                                                                                                                                             0.0s
 => [runner  1/12] FROM docker.io/library/node:16-alpine                                                                                                                                                                      0.2s
 => [internal] load build context                                                                                                                                                                                             1.0s
 => => transferring context: 3.09MB                                                                                                                                                                                           0.9s
 => [deps 2/5] RUN apk add --no-cache libc6-compat                                                                                                                                                                            3.0s
 => [runner  2/12] WORKDIR /app                                                                                                                                                                                               0.4s
 => [runner  3/12] RUN addgroup --system --gid 1001 nodejs                                                                                                                                                                    0.8s
 => [runner  4/12] RUN adduser --system --uid 1001 nextjs                                                                                                                                                                     0.6s
 => [runner  5/12] RUN yarn add npm-run-all dotenv prisma                                                                                                                                                                    43.2s
 => [deps 3/5] WORKDIR /app                                                                                                                                                                                                   0.1s
 => [deps 4/5] COPY package.json yarn.lock ./                                                                                                                                                                                 0.1s
 => [deps 5/5] RUN yarn install --frozen-lockfile                                                                                                                                                                           152.2s
 => [builder 3/5] COPY --from=deps /app/node_modules ./node_modules                                                                                                                                                          16.1s 
 => [builder 4/5] COPY . .                                                                                                                                                                                                    0.8s 
 => ERROR [builder 5/5] RUN yarn build-docker                                                                                                                                                                                 4.9s 
------                                                                                                                                                                                                                             
 > [builder 5/5] RUN yarn build-docker:                                                                                                                                                                                            
#0 1.379 yarn run v1.22.19                                                                                                                                                                                                         
#0 1.532 $ npm-run-all build-db build-tracker build-geo build-app                                                                                                                                                                  
#0 2.847 $ npm-run-all copy-db-files build-db-client                                                                                                                                                                               
#0 4.019 $ node scripts/copy-db-files.js                                                                                                                                                                                           
#0 4.551 /app/scripts/copy-db-files.js:19                                                                                                                                                                                          
#0 4.551   throw new Error('Missing or invalid database');
#0 4.551   ^
#0 4.551 
#0 4.551 Error: Missing or invalid database
#0 4.551     at Object.<anonymous> (/app/scripts/copy-db-files.js:19:9)
#0 4.551     at Module._compile (node:internal/modules/cjs/loader:1165:14)
#0 4.551     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1219:10)
#0 4.551     at Module.load (node:internal/modules/cjs/loader:1043:32)
#0 4.551     at Function.Module._load (node:internal/modules/cjs/loader:878:12)
#0 4.551     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
#0 4.551     at node:internal/main/run_main_module:22:47
#0 4.586 error Command failed with exit code 1.
#0 4.589 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
#0 4.633 ERROR: "copy-db-files" exited with 1.
#0 4.668 error Command failed with exit code 1.
#0 4.669 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
#0 4.706 ERROR: "build-db" exited with 1.
#0 4.740 error Command failed with exit code 1.
#0 4.744 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
------
failed to solve: executor failed running [/bin/sh -c yarn build-docker]: exit code: 1

I'm not sure if this is a bug or just the fact that I'm building it on arm64, any suggestions?

@lnxd
Copy link
Contributor

lnxd commented Jan 12, 2023

Hello,

This container doesn't support arm yet (see #272, #531, #593, #1671) and for a similar reason, unless you set a target platform, it won't build on arm either. As I see it you currently have three options:

Option 1

Easiest way (with some overhead, and if you can use a compose file version older than 3) would be to use the target platform option. I'm not sure on your setup, as it doesn't support swarm mode, but it works flawlessly on my arm64 Mac even though I'm using an unsupported compose file version.

For this you can either add it directly:

...
services:
  umami:
    platform: linux/amd64
    ports:
 ...

Or build it. But as it works for me I can't test whether building it as amd64 allows it to run when adding the platform option while using the prebuilt image:

build:
  context: "."
  platforms:
    - "linux/amd64"

Option 2

Someone has submitted a PR where they appear to be able to get it to successfully build for arm, if it builds for arm it might run without issue.

Option 3

Wait for arm support to be officially introduced, it appears there's a lot of activity regarding this so somebody might be working on it.

@benricok benricok closed this as completed Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants