strapi-tool-dockerize: npm run build fails

Hello

I was just trying your dockerize tool but I run into a problem. Everything goes fine, creates .env, Dockerfile, compose file etc… but when I actually run docker-compose up -d I get below error

[+] Running 0/1
 ⠿ strapi Error                                                                                                                                                                                 2.2s
[+] Building 0.6s (12/12) FINISHED                                                                                                                                                                   
 => [internal] load build definition from Dockerfile                                                                                                                                            0.0s
 => => transferring dockerfile: 32B                                                                                                                                                             0.0s
 => [internal] load .dockerignore                                                                                                                                                               0.0s
 => => transferring context: 34B                                                                                                                                                                0.0s
 => [internal] load metadata for docker.io/library/node:16                                                                                                                                      0.0s
 => [1/8] FROM docker.io/library/node:16                                                                                                                                                        0.0s
 => [internal] load build context                                                                                                                                                               0.0s
 => => transferring context: 297B                                                                                                                                                               0.0s
 => CACHED [2/8] RUN apt-get update && apt-get install libvips-dev -y                                                                                                                           0.0s
 => CACHED [3/8] WORKDIR /opt/                                                                                                                                                                  0.0s
 => CACHED [4/8] COPY ./package.json ./package-lock.json ./                                                                                                                                     0.0s
 => CACHED [5/8] RUN npm install                                                                                                                                                                0.0s
 => CACHED [6/8] WORKDIR /opt/app                                                                                                                                                               0.0s
 => CACHED [7/8] COPY ./ .                                                                                                                                                                      0.0s
 => ERROR [8/8] RUN npm run build                                                                                                                                                               0.5s
------
 > [8/8] RUN npm run build:
#0 0.465 npm ERR! Missing script: "build"
#0 0.465 npm ERR! 
#0 0.465 npm ERR! To see a list of scripts, run:
#0 0.465 npm ERR!   npm run
#0 0.466 
#0 0.466 npm ERR! A complete log of this run can be found in:
#0 0.466 npm ERR!     /root/.npm/_logs/2022-07-28T10_11_26_066Z-debug-0.log
------
failed to solve: executor failed running [/bin/sh -c npm run build]: exit code: 1

Any idea why this is failing?

When I do everything manually, it works fine. npm run build is there.

Update: this is the debug log output


0 verbose cli /home/codeagency/.nvm/versions/node/v18.5.0/bin/node /home/codeagency/.nvm/versions/node/v18.5.0/bin/npm
1 info using npm@8.15.0
2 info using node@v18.5.0
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:/home/codeagency/.nvm/versions/node/v18.5.0/lib/node_modules/npm/npmrc Completed in 0ms
6 timing config:load:builtin Completed in 0ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:/home/codeagency/docker/strapi-v4-local/.npmrc Completed in 0ms
10 timing config:load:project Completed in 2ms
11 timing config:load:file:/home/codeagency/.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:/home/codeagency/.nvm/versions/node/v18.5.0/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:credentials Completed in 1ms
17 timing config:load:setEnvs Completed in 0ms
18 timing config:load Completed in 5ms
19 timing npm:load:configload Completed in 5ms
20 timing npm:load:mkdirpcache Completed in 2ms
21 timing npm:load:mkdirplogs Completed in 0ms
22 verbose title npm run build
23 verbose argv "run" "build"
24 timing npm:load:setTitle Completed in 1ms
25 timing config:load:flatten Completed in 1ms
26 timing npm:load:display Completed in 2ms
27 verbose logfile logs-max:10 dir:/home/codeagency/.npm/_logs
28 verbose logfile /home/codeagency/.npm/_logs/2022-07-28T10_16_24_435Z-debug-0.log
29 timing npm:load:logFile Completed in 3ms
30 timing npm:load:timers Completed in 0ms
31 timing npm:load:configScope Completed in 0ms
32 timing npm:load Completed in 13ms
33 silly logfile start cleaning logs, removing 1 files
34 silly logfile done cleaning log files
35 timing command:run Completed in 3ms
36 verbose stack Error: Missing script: "build"
36 verbose stack
36 verbose stack To see a list of scripts, run:
36 verbose stack   npm run
36 verbose stack     at RunScript.run (/home/codeagency/.nvm/versions/node/v18.5.0/lib/node_modules/npm/lib/commands/run-script.js:98:13)
36 verbose stack     at async module.exports (/home/codeagency/.nvm/versions/node/v18.5.0/lib/node_modules/npm/lib/cli.js:78:5)
37 verbose cwd /home/codeagency/docker/strapi-v4-local
38 verbose Linux 5.15.0-41-generic
39 verbose node v18.5.0
40 verbose npm  v8.15.0
41 error Missing script: "build"
41 error
41 error To see a list of scripts, run:
41 error   npm run
42 verbose exit 1
43 timing npm Completed in 23ms
44 verbose code 1
45 error A complete log of this run can be found in:
45 error     /home/codeagency/.npm/_logs/2022-07-28T10_16_24_435Z-debug-0.log

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

@Eventyret Hey, sorry, but i am having the same issue. node_modules is in dockerignore and still problems with sharp. I am running Ubuntu 22.04. Strapi runs fine locally, but no matter how i try to run it in docker, it refuses to get past the sharp issue.

You would need to post your dockerfile, dockerignore and docker-compose please ☺️

@Eventyret the fix for my case was I was in the wrong folder. I got it mixed up with git which also create a folder when you clone. Then when you run npx command, it also creates a folder for you so I got stuff nested and confused.

Probably you are also running the command outside your project folder and that’s why it gives that error.

Thank you for replying @Eventyret !

This is what I did:

1 - created an empty folder 2 - ran npx @strapi-community/dockerize 3 - ran docker-compose up -d 4 - got the build error.

I have a .env and package.json file and I’m using NPM with Node v16.13.2

Step 1 is the project it needs to be in a strapi project folder