Error building docker image

Hi, I’ve follow the suggestion in this discussion to build a docker image of theia with inside my extensions: How do I build a docker image with my unpublished extension?

But I got this error:

#16 390.0 warning "@theia/cli > @theia/application-manager > font-awesome-webpack > less-loader@2.2.3" has incorrect peer dependency "less@^2.3.1".
#16 437.4 [4/4] Building fresh packages...
#16 539.3 Done in 538.72s.
#16 540.2 yarn run v1.22.4
#16 540.3 $ /home/theia/node_modules/.bin/theia build
#16 542.1 Failed to resolve module: filenamify
#16 572.6 (node:1569) DeprecationWarning: Tapable.apply is deprecated. Call apply on the plugin directly instead
#16 572.6 
#16 772.2 Error: webpack exited with an unexpected signal: SIGKILL.
#16 772.2     at ChildProcess.<anonymous> (/home/theia/node_modules/@theia/application-manager/lib/application-process.js:60:28)
#16 772.2     at ChildProcess.emit (events.js:315:20)
#16 772.2     at maybeClose (internal/child_process.js:1021:16)
#16 772.2     at Socket.<anonymous> (internal/child_process.js:443:11)
#16 772.2     at Socket.emit (events.js:315:20)
#16 772.2     at Pipe.<anonymous> (net.js:674:12)
#16 772.5 error Command failed with exit code 1.
#16 772.5 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
------
failed to solve with frontend dockerfile.v0: failed to build LLB: executor failed running [/bin/sh -c yarn --pure-lockfile &&     NODE_OPTIONS="--max_old_space_size=4096" yarn theia build &&     yarn theia download:plugins &&     yarn --production &&     yarn autoclean --init &&     echo *.ts >> .yarnclean &&     echo *.ts.map >> .yarnclean &&     echo *.spec.* >> .yarnclean &&     yarn autoclean --force &&     yarn cache clean]: runc did not terminate sucessfully

And I can’t find the reason. I’m able to correctly run the sample browser app with this extension. Currently mi file structure is this:

-project_folder\
  ->browser-app\
  ->electron-app\
  ->extension1\
     ->all extension1 files
  ->extension2
      ->all extension2 files
  Dockerfile
  latest.package.json

The latest.package.json:

"dependencies": {
    "@theia/callhierarchy": "latest",
    "@theia/debug": "latest",
    "@theia/editor-preview": "latest",
    "@theia/file-search": "latest",
    "@theia/getting-started": "latest",
    "@theia/git": "latest",
    "@theia/markers": "latest",
    "@theia/messages": "latest",
    "@theia/mini-browser": "latest",
    "@theia/navigator": "latest",
    "@theia/outline-view": "latest",
    "@theia/plugin": "latest",
    "@theia/plugin-ext": "latest",
    "@theia/plugin-ext-vscode": "latest",
    "@theia/preferences": "latest",
    "@theia/preview": "latest",
    "@theia/search-in-workspace": "latest",
    "@theia/terminal": "latest",
    "@theia/vsx-registry": "latest",
    "extension1": "./extension1",
    "extension2": "./extension2"
},

The dockerfile:

ARG NODE_VERSION=12.18.3
FROM node:${NODE_VERSION}-alpine
RUN apk add --no-cache make pkgconfig gcc g++ python libx11-dev libxkbfile-dev
ARG version=latest
WORKDIR /home/theia
ADD $version.package.json ./package.json
ADD extension2/ extension2
ADD extension1/ extension1
ARG GITHUB_TOKEN
RUN mkdir extensions
RUN yarn --pure-lockfile && \
    NODE_OPTIONS="--max_old_space_size=4096" yarn theia build && \
    yarn theia download:plugins && \
    yarn --production && \
    yarn autoclean --init && \
    echo *.ts >> .yarnclean && \
    echo *.ts.map >> .yarnclean && \
    echo *.spec.* >> .yarnclean && \
    yarn autoclean --force && \
    yarn cache clean

FROM node:${NODE_VERSION}-alpine
# See : https://github.com/theia-ide/theia-apps/issues/34
RUN addgroup theia && \
    adduser -G theia -s /bin/sh -D theia;
RUN chmod g+rw /home && \
    mkdir -p /home/project && \
    chown -R theia:theia /home/theia && \
    chown -R theia:theia /home/project;
RUN apk add --no-cache git openssh bash
ENV HOME /home/theia
WORKDIR /home/theia
COPY --from=0 --chown=theia:theia /home/theia /home/theia
EXPOSE 3000
ENV SHELL=/bin/bash \
    THEIA_DEFAULT_PLUGINS=local-dir:/home/theia/plugins
ENV USE_LOCAL_GIT true
USER theia
ENTRYPOINT [ "node", "/home/theia/src-gen/backend/main.js", "/home/project", "--hostname=0.0.0.0" ]

Have someone and hint on what the problem could be?

I do not know much about the Docker part, but local npm dependencies should be like this, right?

    "extension1": "file:./extension1",
    "extension2": "file:../path/to/extension2"

I have seen this error entry today in a completely different build log, but it did not cause any problem.

I will give a try but the path is resolved correctly, otherwise it would give an error. I’ve used this path because it is explained like this in the thread I linked.

About filenamify, I googled and I saw it is a common problem but it should block the build

Did you mean should not?


Can you share the rest of the build log? Maybe there is another error before the SIGKILL.

There is a common issue I usually commit; I import the Theia modules from src instead of lib. Something like this:

diff --git a/examples/api-samples/src/browser/label/sample-dynamic-label-provider-command-contribution.ts b/examples/api-samples/src/browser/label/sample-dynamic-label-provider-command-contribution.ts
index ed941899e..22220dfa1 100644
--- a/examples/api-samples/src/browser/label/sample-dynamic-label-provider-command-contribution.ts
+++ b/examples/api-samples/src/browser/label/sample-dynamic-label-provider-command-contribution.ts
@@ -16,7 +16,7 @@
 
 import { injectable, inject, interfaces } from 'inversify';
 import { Command, CommandContribution, CommandRegistry, CommandHandler } from '@theia/core';
-import { FrontendApplicationContribution, LabelProviderContribution } from '@theia/core/lib/browser';
+import { FrontendApplicationContribution, LabelProviderContribution } from '@theia/core/src/browser';
 import { SampleDynamicLabelProviderContribution } from './sample-dynamic-label-provider-contribution';
 
 export namespace ExampleLabelProviderCommands {

Such a programmer mistake results in this error:

@theia/example-browser: error Command failed with exit code 1.
Error: Command failed: yarn run build
(node:36432) DeprecationWarning: Tapable.apply is deprecated. Call apply on the plugin directly instead

Error: webpack exited with an unexpected code: 2.
    at ChildProcess.<anonymous> (/Users/akos.kitta/git/theia/dev-packages/application-manager/lib/application-process.js:67:28)
    at ChildProcess.emit (events.js:223:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
error Command failed with exit code 1.
error Command failed with exit code 1.

This is the cause:

lerna ERR! ERROR in ../api-samples/lib/browser/label/sample-dynamic-label-provider-command-contribution.js
lerna ERR! Module not found: Error: Can't resolve '@theia/core/src/browser' in '/Users/akos.kitta/git/theia/examples/api-samples/lib/browser/label'
lerna ERR!  @ ../api-samples/lib/browser/label/sample-dynamic-label-provider-command-contribution.js 30:16-50
lerna ERR!  @ ../api-samples/lib/browser/api-samples-frontend-module.js
lerna ERR!  @ ./src-gen/frontend/index.js
lerna ERR! Child worker:

Maybe, it is an import issue in your extension, but it would be good to see the rest of your output.