Build Image with Dockerfile fails

Describe the issue/error/question

I have problems building an n8n docker image with the dockerfile. Running the dockerfile fails with this errormessage:

What is the error message (if any)?

Alexanders-MacBook-Pro:n8n alex$ docker build -t n8n_cust -f docker/images/n8n-custom/Dockerfile .
[+] Building 5.5s (14/26)                                                                                                                                                                                                                                                                                                                 
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                                                 0.1s
 => => transferring dockerfile: 120B                                                                                                                                                                                                                                                                                                 0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                                                                                                    0.1s
 => => transferring context: 2B                                                                                                                                                                                                                                                                                                      0.0s
 => [internal] load metadata for docker.io/n8nio/base:16                                                                                                                                                                                                                                                                             0.5s
 => [internal] load build context                                                                                                                                                                                                                                                                                                    0.5s
 => => transferring context: 846.12kB                                                                                                                                                                                                                                                                                                0.5s
 => CACHED [stage-1 1/5] FROM docker.io/n8nio/base:16@sha256:5ed0cee768089444ab0f77efb75323b5455185c542253a8b885a8c16b926fc9b                                                                                                                                                                                                        0.0s
 => CACHED [builder  2/18] COPY turbo.json package.json .npmrc pnpm-lock.yaml pnpm-workspace.yaml tsconfig.json ./                                                                                                                                                                                                                   0.0s
 => CACHED [builder  3/18] COPY scripts ./scripts                                                                                                                                                                                                                                                                                    0.0s
 => CACHED [builder  4/18] COPY packages ./packages                                                                                                                                                                                                                                                                                  0.0s
 => CACHED [builder  5/18] COPY patches ./patches                                                                                                                                                                                                                                                                                    0.0s
 => CACHED [builder  6/18] RUN apk add --update libc6-compat jq                                                                                                                                                                                                                                                                      0.0s
 => CACHED [builder  7/18] RUN corepack enable && corepack prepare --activate                                                                                                                                                                                                                                                        0.0s
 => CACHED [builder  8/18] RUN chown -R node:node .                                                                                                                                                                                                                                                                                  0.0s
 => CACHED [builder  9/18] RUN pnpm install --frozen-lockfile                                                                                                                                                                                                                                                                        0.0s
 => ERROR [builder 10/18] RUN pnpm build                                                                                                                                                                                                                                                                                             4.3s
------                                                                                                                                                                                                                                                                                                                                    
 > [builder 10/18] RUN pnpm build:
#14 1.833 
#14 1.833 > [email protected] build /home/node
#14 1.833 > turbo run build
#14 1.833 
#14 2.354  WARNING  cannot find a .git folder. Falling back to manual file hashing (which may be slower). If you are running this build in a pruned directory, you can ignore this message. Otherwise, please initialize a git repository in the root of your monorepo
#14 2.605 • Packages in scope: @n8n_io/eslint-config, n8n, n8n-core, n8n-design-system, n8n-editor-ui, n8n-node-dev, n8n-nodes-base, n8n-workflow
#14 2.605 • Running build in 8 packages
#14 2.605 • Remote caching disabled
#14 2.607 n8n-design-system:build: cache miss, executing 1d64579158a23b67
#14 2.607 n8n-workflow:build: cache miss, executing fa92c54a6ec3f4bc
#14 4.067 n8n-design-system:build: 
#14 4.067 n8n-design-system:build: > [email protected] build /home/node/packages/design-system
#14 4.067 n8n-design-system:build: > vite build
#14 4.067 n8n-design-system:build: 
#14 4.071 n8n-workflow:build: 
#14 4.071 n8n-workflow:build: > [email protected] build /home/node/packages/workflow
#14 4.071 n8n-workflow:build: > tsc -p tsconfig.build.json
#14 4.071 n8n-workflow:build: 
#14 4.081 n8n-workflow:build: sh: tsc: not found
#14 4.095 n8n-workflow:build:  ELIFECYCLE  Command failed.
#14 4.134 n8n-workflow:build: ERROR: command finished with error: command (/home/node/packages/workflow) pnpm run build exited (1)
#14 4.145 n8n-design-system:build:  ELIFECYCLE  Command failed.
#14 4.164 
#14 4.164  Tasks:    0 successful, 1 total
#14 4.164 Cached:    0 cached, 1 total
#14 4.164   Time:    2.087s 
#14 4.164 
#14 4.164 command (/home/node/packages/workflow) pnpm run build exited (1)
#14 4.165  ERROR  run failed: command  exited (1)
#14 4.192  ELIFECYCLE  Command failed with exit code 1.
------```

## Information on your n8n setup
- **n8n version: 0.217.2
- **Database you're using (default: SQLite): sqlite
- **Running n8n with the execution process [own(default), main]:**
- **Running n8n via [Docker, npm, n8n.cloud, desktop app]:**


Can you please help me what I'am missing here? Thanks!

Hey @Alexander_Berndt,

It looks like something is missing, are you using our custom image without changes?

Hello Jon,
yes, its the n8n-custom Dockerfile provided in the git-repo of n8n. No changes from my site.

Hey @Alexander_Berndt,

I guess I have another question then :slightly_smiling_face: if there are no changes why are you using the custom image?

I am not sure why it is saying something is missing it could be that we forgot to update something although last time I made a custom image I didn’t follow that approach so I will give it a go once I have a coffee to see if I hit the same issue.

Hi Jon,

I’am happy you ask :slight_smile:
Normally we do some light gui color changes and implement our self designed nodes. For this, we modify the n8n-custom Dockerfile. This procedure failed with this update (last was 0.193. as far as I remember), so I decided to try out the shipped n8n-custom Dockerfile without any changes to check if the problem is on my side.

1 Like

Hey @Alexander_Berndt,

Sorry for the delay it is been a busy day, I have given this a go and oddly enough on my Mac it is all good.

 ~/code/javascript/n8n-io-tmp/n8n | master .................. 7s | 01:53:16 pm
> docker build -t n8n-custom -f docker/images/n8n-custom/Dockerfile .

[+] Building 298.5s (27/27) FINISHED
 => [internal] load build definition from Dockerfile                       0.0s
 => => transferring dockerfile: 1.80kB                                     0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 191B                                          0.0s
 => [internal] load metadata for docker.io/n8nio/base:16                   3.4s
 => [internal] load build context                                          1.3s
 => => transferring context: 24.27MB                                       1.3s
 => [builder  1/18] FROM docker.io/n8nio/base:16@sha256:5ed0cee768089444  14.1s
 => => resolve docker.io/n8nio/base:16@sha256:5ed0cee768089444ab0f77efb75  0.0s
 => => sha256:5ed0cee768089444ab0f77efb75323b5455185c5422 2.38kB / 2.38kB  0.0s
 => => sha256:4aaa86babb897d7e4681d70f01c80e0145dba095550 1.62kB / 1.62kB  0.0s
 => => sha256:6b13ed9707d08e1cd218fd5b59a0bd657c25034d044 7.29kB / 7.29kB  0.0s
 => => sha256:a9eaa45ef418e883481a13c7d84fa9904f2ec56789c 3.26MB / 3.26MB  0.8s
 => => sha256:f4b29973f215f1a2fa1660e079d82585c55c2c82 36.62MB / 36.62MB  11.7s
 => => sha256:dc47093e946419f96a64c8bda5bd725b3d28a3771ad 2.41MB / 2.41MB  4.3s
 => => extracting sha256:a9eaa45ef418e883481a13c7d84fa9904f2ec56789c52a87  0.3s
 => => sha256:9903ed942feca9a23884ff22ab7510ca7e3ed63e193e573 449B / 449B  1.2s
 => => sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d 32B / 32B  1.4s
 => => sha256:51f1f9c57035d2014c14000214725ec127d9e701ee947e5 229B / 229B  1.6s
 => => sha256:2c0b651d04a94571500f5d3133c8187408d2cea7 26.72MB / 26.72MB  12.2s
 => => extracting sha256:f4b29973f215f1a2fa1660e079d82585c55c2c829224bb35  1.0s
 => => extracting sha256:dc47093e946419f96a64c8bda5bd725b3d28a3771adea704  0.1s
 => => extracting sha256:9903ed942feca9a23884ff22ab7510ca7e3ed63e193e573e  0.0s
 => => extracting sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6  0.0s
 => => extracting sha256:51f1f9c57035d2014c14000214725ec127d9e701ee947e57  0.0s
 => => extracting sha256:2c0b651d04a94571500f5d3133c8187408d2cea7bb61c57b  0.8s
 => [builder  2/18] COPY turbo.json package.json .npmrc pnpm-lock.yaml pn  0.3s
 => [builder  3/18] COPY scripts ./scripts                                 0.0s
 => [builder  4/18] COPY packages ./packages                               0.3s
 => [builder  5/18] COPY patches ./patches                                 0.0s
 => [builder  6/18] RUN apk add --update libc6-compat jq                   1.2s
 => [builder  7/18] RUN corepack enable && corepack prepare --activate     2.6s
 => [builder  8/18] RUN chown -R node:node .                               3.6s
 => [builder  9/18] RUN pnpm install --frozen-lockfile                    43.4s
 => [builder 10/18] RUN pnpm build                                       170.2s
 => [builder 11/18] RUN rm -rf node_modules                                5.8s
 => [builder 12/18] RUN jq 'del(.pnpm.patchedDependencies)' package.json   0.2s
 => [builder 13/18] RUN jq '{name: .name, version: .version}' packages/ed  0.2s
 => [builder 14/18] RUN jq '{name: .name, version: .version}' packages/de  0.2s
 => [builder 15/18] RUN NODE_ENV=production pnpm install --prod --no-opt  37.3s
 => [builder 16/18] RUN find . -type f -name "*.ts" -o -name "*.js.map" -  2.5s
 => [builder 17/18] RUN rm -rf packages/@n8n_io/eslint-config packages/ed  0.3s
 => [builder 18/18] RUN rm -rf patches .npmrc *.yaml node_modules/.cache   1.9s
 => [stage-1 2/5] COPY --from=builder /home/node /usr/local/lib/node_modu  4.1s
 => [stage-1 3/5] RUN ln -s /usr/local/lib/node_modules/n8n/packages/cli/  0.3s
 => [stage-1 4/5] COPY docker/images/n8n-custom/docker-entrypoint.sh /     0.0s
 => [stage-1 5/5] RUN  mkdir .n8n &&  chown node:node .n8n                 0.2s
 => exporting to image                                                     3.2s
 => => exporting layers                                                    3.2s
 => => writing image sha256:b32c383a380c2d4b4e079f71d9579c911191cd5982bfe  0.0s
 => => naming to docker.io/library/n8n-custom                              0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them

 ~/code/javascript/n8n-io-tmp/n8n | master ............... 5m 0s | 01:58:19 pm
> docker run -it --name test -p 9999:5678 n8n-custom
UserSettings were generated and saved to: /home/node/.n8n/config
Migrations in progress, please do NOT stop the process.
Initializing n8n process
Migrations finished.
n8n ready on 0.0.0.0, port 5678
Version: 0.217.2

Editor is now accessible via:
http://localhost:5678/

Press "o" to open in Browser.

This doesn’t really help you but at least we know it should be working, It could be worth just trying again maybe something odd happened locally? Out of interest in Docker Desktop under Preferences > Resources > Advanced what do you have Memory set to?

Hello Jon,
thank you for your support. I will doublecheck again.
Memory is set to 8GB, maybe it`s worth to try to double the amount.

Hey @Alexander_Berndt,

I had mine set to 5GB I think I increased it from the default because I was hitting issues so I suspect you have more than enough.

The error is in this line

Which would imply that somehow typescript wasn’t installed in the cached pnpm install --frozen-lockfile step.

@Alexander_Berndt Can you please try running the same build command again, but with --no-cache ?

Hello @Jon , hello @netroy ,

something weird happened here. I further investigated my docker desktop and found that there was an update stuck at some point. I tried to restart docker desktop many times and tried to get the update done, but it still hangs there, but without any notice why no progress was made.

So after some tries, I decided to restart my Mac and then fortunately the update goes through and docker desktop startet normally.

Trying the build again with success. So I think maybe it was a problem with the cache and the reboot cleard it, or the problem was caused by docker desktop and the stucked update. For now, the build was done.

Time to check if it possible to create my customized custom-n8n image.

Many thanks to you both for your help and investigation! Very appreciated.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.