mulesoft-labs / api-console-cli

A CLI tools for the API console.
Other
14 stars 15 forks source link

Failed to build in node:lts-alpine #39

Closed yq314 closed 4 years ago

yq314 commented 5 years ago

I'm trying to build api-console in docker, based on node:lts-alpine but it failed with this error of no much use:

info: Found 2 build configurations.
info: (es5-bundle) Initializing the build...
info: (es5-bundle) Adding custom elements adapter.
info: (es6-bundle) Initializing the build...
info: (es6-bundle) Building...
info: (es5-bundle) Building...
info: (es6-bundle) Build complete in 224.651 seconds
info: (es5-bundle) Build complete in 224.696 seconds
debug: Changing working dir to /api-console
info: Generating API model from /api-console/api.raml, using RAML 1.0 parser
debug: Initializing AMF library...
debug: AMF ready.
debug: Running API parser...
error:
error: undefined
error: Error
    at nbb.d.lS (/usr/local/lib/node_modules/api-console-cli/node_modules/amf-client-js/amf.js:1805:195)
    at nbb.d.ee (/usr/local/lib/node_modules/api-console-cli/node_modules/amf-client-js/amf.js:1815:187)
    at nbb.d.Ol (/usr/local/lib/node_modules/api-console-cli/node_modules/amf-client-js/amf.js:4404:358)
    at mbb.d.Nu (/usr/local/lib/node_modules/api-console-cli/node_modules/amf-client-js/amf.js:3742:158)
    at mbb.d.gb (/usr/local/lib/node_modules/api-console-cli/node_modules/amf-client-js/amf.js:3742:246)
    at mbb.d.R (/usr/local/lib/node_modules/api-console-cli/node_modules/amf-client-js/amf.js:2453:374)
    at eg.d.Xza (/usr/local/lib/node_modules/api-console-cli/node_modules/amf-client-js/amf.js:4288:211)
    at /usr/local/lib/node_modules/api-console-cli/node_modules/amf-client-js/amf.js:1022:267
    at u.R (/usr/local/lib/node_modules/api-console-cli/node_modules/amf-client-js/amf.js:2442:216)
    at /usr/local/lib/node_modules/api-console-cli/node_modules/amf-client-js/amf.js:2419:317
    at u.R (/usr/local/lib/node_modules/api-console-cli/node_modules/amf-client-js/amf.js:2442:216)
    at DY.bE (/usr/local/lib/node_modules/api-console-cli/node_modules/amf-client-js/amf.js:2416:65)
    at /usr/local/lib/node_modules/api-console-cli/node_modules/amf-client-js/amf.js:2720:428
error:
debug: Cleaning up temporaty dir...
debug: Removing /tmp/tmp-44kSGBFWuWXPkJ

My Dockerfile is as simple as this:

FROM node:lts-alpine

ENV API_CONSOLE_CLI_VERSION 1.0.14
ENV API_CONSOLE_VERSION v5.0.2
ENV MAIN_API_FILE "api.raml"

WORKDIR /api-console

COPY ./raml /api-console/raml

RUN apk add --no-cache --virtual git && \
    npm install -g api-console-cli@${API_CONSOLE_CLI_VERSION} && \
    NODE_OPTIONS=--max_old_space_size=2048 api-console build --no-ga --verbose -t "RAML 1.0" -a /api-console/${MAIN_API_FILE}

EXPOSE 8081

CMD ["sh", "-c", "api-console serve build/ --open"]

Appreciate if anyone could point me to where I can debug further?

jarrodek commented 5 years ago

Hi, I am sorry for late response. This is an error generated by the AMF parser. This just means that parser cannot parse the API file. Is it possible that pats are set incorrectly?

You can pass --verbose option to generate a lot of output that may help with debug.

yq314 commented 5 years ago

Hi, @jarrodek thanks for the reply.

The same API file compiles fine on my Mac so I don't think it's a problem. It only fails in the docker environment based on node:lts-alpine, and the output is already verbose...

It generates a lot of debug logs but it's all fine until the AMF step and the error message is simply undefined... I'm not familiar with AMF, is there a way to debug into AMF to see what is happening?

yq314 commented 5 years ago

I've tried node:lts, node:lts-slim and node:lts-alpine all getting the same error

yq314 commented 5 years ago

I'm seeing a few warnings in the verbose log, not sure if that matters:

npm WARN deprecated bower@1.8.8: We don't recommend using Bower for new projects. Please consider Yarn and Webpack or Parcel. You can read how to migrate legacy project here: https://bower.io/blog/2017/how-to-migrate-away-from-bower/
npm WARN deprecated sw-precache@5.2.1: Please migrate to Workbox: https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
npm WARN deprecated sw-toolbox@3.6.0: Please migrate to Workbox: https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
/usr/local/bin/api-console -> /usr/local/lib/node_modules/api-console-cli/bin/api-console-cli.js

> core-js@2.6.9 postinstall /usr/local/lib/node_modules/api-console-cli/node_modules/core-js
> node scripts/postinstall || echo "ignore"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: google-closure-compiler-osx@20181008.0.0 (node_modules/api-console-cli/node_modules/google-closure-compiler-osx):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for google-closure-compiler-osx@20181008.0.0: wanted {"os":"darwin","arch":"x64,x86"} (current: {"os":"linux","arch":"x64"})
jarrodek commented 5 years ago

Hi, This warning messages are unrelated. I am not really sure what is happening and why. It must be related to AMF library. I will try to reproduce this in a container and see what is happening.

jdeanda commented 5 years ago

Has the source of the issue been discovered? I'm encountering the same exact error when I run 'NODE_OPTIONS=--max_old_space_size=4096 api-console build -t "RAML 1.0" --verbose -a ../../../raml/third-party/v1/transaction.raml'.

As a side note... dt2js and raml2html have no problems parsing the files and generating the correct results.

hubandr commented 4 years ago

Could #35 be the reason for this issue? Have you tried -a without any "../" ?

jarrodek commented 4 years ago

The version 2.0.0 now has completely different build process where this issue is not detected anymore.