Meteor Build command fails

Description:

I am trying to build Rocket.Chat 3.9.0 source in Dockerfile, but meteor build command fails

Here are the contents of my Dockerfile:

FROM ubuntu:18.04
RUN apt-get update
# Meteor requirements
RUN apt-get install g++ build-essential git curl -y

# Steps from Github workflow
RUN set +e METEOR_SYMLINK_TARGET=$(readlink ~/.meteor/meteor) METEOR_TOOL_DIRECTORY=$(dirname "$METEOR_SYMLINK_TARGET")
RUN set -e

# Install meteor
RUN curl https://install.meteor.com | sed s/--progress-bar/-sL/g | /bin/sh
# Install nodejs 12
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash
RUN apt-get install nodejs -y

WORKDIR /usr/local/src/rocketchat
# Copy Rocket.Chat project to workdir, assuming that nodemodules is in dockerignore
COPY . .

RUN meteor npm install
RUN meteor build --allow-superuser --directory build

Steps to reproduce:

  1. Clone repo and checkout 3.9.0 tag: git clone https://github.com/RocketChat/Rocket.Chat.git && git checkout tags/3.9.0
  2. Create Dockerfile in project root
  3. Run docker build .

Expected behavior:

I expect meteor build --allow-superuser --directory build run smoothly, and generate output in “./build” directory.

Actual behavior:

meteor build --allow-superuser --directory build fails with strange error:

cp: cannot stat '/usr/local/src/rocketchat'$'\r''/node_modules/@rocket.chat/livechat/build/.': No such file or directory
internal/fs/utils.js:269
    throw err;
    ^

Error: ENOENT: no such file or directory, open 'index.html'

Server Setup Information:

  • Version of Rocket.Chat Server: 3.9.0
  • Operating System: Docker WSL2 on Windows
  • Deployment Method: docker
  • Number of Running Instances: 0
  • DB Replicaset Oplog: 0
  • NodeJS Version: 12.20.0
  • MongoDB Version: Not installed

Client Setup Information

  • Desktop App or Browser Version: No
  • Operating System: No

Additional context

I looked at Github workflow configuration, according to it, my Dockerfile looks fine.

I tried to move livechat devDependency to dependency, but it didn’t help.

I tried this approach on 3.9.0 and 3.8.2 tags, always same result.

I tried to manually install all of this in my WSL2 Ubuntu 18.04 environment, and faced the same problem.

Relevant logs:

Step 13/13 : RUN meteor build --allow-superuser --directory build
 ---> Running in 66f208a4a4df

Even with METEOR_ALLOW_SUPERUSER or --allow-superuser, permissions in your app
directory will be incorrect if you ever attempt to perform any Meteor tasks as
a normal user. If you need to fix your permissions, run the following command
from the root of your project:

  sudo chown -Rh <username> .meteor/local

jalik:ufs: updating npm dependencies -- mkdirp, spark-md5...
Livechat: updating npm dependencies -- uglify-js...
: not foundsrc/rocketchat/packages/rocketchat-livechat/plugin/build.sh: 5: /usr/local/src/rocketchat/packages/rocketchat-livechat/plugin/build.sh:
: not foundsrc/rocketchat/packages/rocketchat-livechat/plugin/build.sh: 7: /usr/local/src/rocketchat/packages/rocketchat-livechat/plugin/build.sh:
: not foundsrc/rocketchat/packages/rocketchat-livechat/plugin/build.sh: 10: /usr/local/src/rocketchat/packages/rocketchat-livechat/plugin/build.sh:
: not foundsrc/rocketchat/packages/rocketchat-livechat/plugin/build.sh: 13: /usr/local/src/rocketchat/packages/rocketchat-livechat/plugin/build.sh:
: not foundsrc/rocketchat/packages/rocketchat-livechat/plugin/build.sh: 17: /usr/local/src/rocketchat/packages/rocketchat-livechat/plugin/build.sh:
cp: cannot stat '/usr/local/src/rocketchat'$'\r''/node_modules/@rocket.chat/livechat/build/.': No such file or directory
internal/fs/utils.js:269
    throw err;
    ^

Error: ENOENT: no such file or directory, open 'index.html'
    at Object.openSync (fs.js:462:3)
    at Object.readFileSync (fs.js:364:35)
    at [eval]:1:35
    at Script.runInThisContext (vm.js:120:18)
    at Object.runInThisContext (vm.js:309:38)
    at Object.<anonymous> ([eval]-wrapper:10:26)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at evalScript (internal/process/execution.js:94:25)
    at internal/main/eval_string.js:23:3 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: 'index.html'
}
/./private/livechatetchat/packages/rocketchat-livechat/plugin/build.sh: 22: cd: can't cd to /usr/local/src/rocketchat
cp: cannot stat '../../public/livechat/index.html': No such file or directory
/root/.meteor/packages/meteor-tool/.1.11.1.nmm7cg.gs54++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/meteor-
promise/promise_server.js:218
      throw error;
      ^

Error: Couldn't parse stack frame: '  errno: -2,'
    at /root/.meteor/packages/meteor-tool/.1.11.1.nmm7cg.gs54++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/utils/tools/utils/pars
e-stack.ts:186:11
    at Array.some (<anonymous>)
    at parseStackFrames (/root/.meteor/packages/meteor-tool/.1.11.1.nmm7cg.gs54++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/util
s/tools/utils/parse-stack.ts:118:10)
    at Object.parse (/root/.meteor/packages/meteor-tool/.1.11.1.nmm7cg.gs54++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/utils/to
ols/utils/parse-stack.ts:64:21)
    at Object.exception (/tools/utils/buildmessage.js:534:29)
    at /tools/isobuild/bundler.js:2195:22
    at Function._.each._.forEach (/root/.meteor/packages/meteor-tool/.1.11.1.nmm7cg.gs54++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/d
ev_bundle/lib/node_modules/underscore/underscore.js:186:9)
    at JsImage.load (/tools/isobuild/bundler.js:2048:7)
    at /tools/isobuild/isopack.js:477:16
    at Object.enterJob (/tools/utils/buildmessage.js:388:12)
    at /tools/isobuild/isopack.js:467:20
    at Function._.each._.forEach (/root/.meteor/packages/meteor-tool/.1.11.1.nmm7cg.gs54++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/d
ev_bundle/lib/node_modules/underscore/underscore.js:191:9)
    at Isopack.ensurePluginsInitialized (/tools/isobuild/isopack.js:455:7)
    at /tools/isobuild/compiler.js:381:16
    at Array.forEach (<anonymous>)
    at /tools/isobuild/compiler.js:380:26
    at Object.enterJob (/tools/utils/buildmessage.js:388:12)
    at /tools/isobuild/compiler.js:376:16
    at /tools/isobuild/compiler.js:186:28
    at Slot.withValue (/root/.meteor/packages/meteor-tool/.1.11.1.nmm7cg.gs54++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/dev_bundle/l
ib/node_modules/@wry/context/lib/context.js:73:29)
    at Object.withCache (/root/.meteor/packages/meteor-tool/.1.11.1.nmm7cg.gs54++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/fs/t
ools/fs/files.ts:1659:39)
    at /tools/isobuild/compiler.js:185:11
    at Function._.each._.forEach (/root/.meteor/packages/meteor-tool/.1.11.1.nmm7cg.gs54++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/d
ev_bundle/lib/node_modules/underscore/underscore.js:186:9)
    at Object.compile (/tools/isobuild/compiler.js:180:5)
    at /tools/isobuild/isopack-cache.js:354:30
    at Object.enterJob (/tools/utils/buildmessage.js:388:12)
    at IsopackCache._loadLocalPackage (/tools/isobuild/isopack-cache.js:309:18)
    at /tools/isobuild/isopack-cache.js:243:16
    at Function.time (/root/.meteor/packages/meteor-tool/.1.11.1.nmm7cg.gs54++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/tool-en
v/tools/tool-env/profile.ts:284:12)
    at /tools/isobuild/isopack-cache.js:242:17
    at Object.enterJob (/tools/utils/buildmessage.js:388:12)
    at IsopackCache._ensurePackageLoaded (/tools/isobuild/isopack-cache.js:233:20)
    at /tools/isobuild/isopack-cache.js:75:14
    at /tools/packaging/package-map.js:57:7
    at Function._.each._.forEach (/root/.meteor/packages/meteor-tool/.1.11.1.nmm7cg.gs54++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/d
ev_bundle/lib/node_modules/underscore/underscore.js:191:9)
    at exports.PackageMap.eachPackage (/tools/packaging/package-map.js:49:7)
    at IsopackCache.buildLocalPackages (/tools/isobuild/isopack-cache.js:74:24)
    at /tools/project-context.js:890:25
    at Object.enterJob (/tools/utils/buildmessage.js:388:12)
    at ProjectContext._buildLocalPackages (/tools/project-context.js:889:18)
    at /tools/project-context.js:300:9
    at Object.enterJob (/tools/utils/buildmessage.js:388:12)
    at ProjectContext._completeStagesThrough (/tools/project-context.js:290:18)
    at /tools/project-context.js:282:12
    at Function.run (/root/.meteor/packages/meteor-tool/.1.11.1.nmm7cg.gs54++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/tool-env
/tools/tool-env/profile.ts:289:14)
    at ProjectContext.prepareProjectForBuild (/tools/project-context.js:281:13)
    at /tools/cli/commands.js:1012:20
    at Object.capture (/tools/utils/buildmessage.js:283:5)
    at Object.main.captureAndExit (/tools/cli/main.js:275:29)
    at buildCommand (/tools/cli/commands.js:1009:8)
    at /tools/cli/commands.js:950:25
    at Function.run (/root/.meteor/packages/meteor-tool/.1.11.1.nmm7cg.gs54++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/tool-env
/tools/tool-env/profile.ts:289:14)
    at /tools/cli/commands.js:948:18
    at /root/.meteor/packages/meteor-tool/.1.11.1.nmm7cg.gs54++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/
meteor-promise/fiber_pool.js:43:40
 => awaited here:
    at Promise.await (/root/.meteor/packages/meteor-tool/.1.11.1.nmm7cg.gs54++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/dev_bundle/li
b/node_modules/meteor-promise/promise_server.js:60:12)
    at /tools/cli/main.js:1529:7
The command '/bin/sh -c meteor build --allow-superuser --directory build' returned a non-zero code: 1