Results 1 to 3 of 3

Thread: npm build dependencies in docker

  1. #1
    Sencha User
    Join Date
    Nov 2010
    Location
    Canton, GA, USA
    Posts
    164

    Default npm build dependencies in docker

    The Getting Started page lists NodeJS and NPM as the only dependencies but Java and bash are required as well. I suspect I'm missing something else but I'm not sure what.

    A simple Dockerfile to test with:
    Code:
    FROM alpine:latest
    RUN apk add npm expect openjdk11-jre bash
    COPY scripts/npm-login /usr/local/bin
    RUN npm-login
    RUN rm /usr/local/bin/npm-login
    RUN npm install -g @sencha/ext-gen
    RUN ext-gen app -t universalmodern -m theme-material -n App
    RUN cd app && npm run build
    RUN cat /app/sencha-error-*.log
    The "npm run build" is failing when I "docker build" this.
    Code:
    ...
    Step 8/9 : RUN cd app && npm run build
     ---> Running in d9ad4e7adab7
    
    
    > [email protected] build /app
    > npm run clean && cross-env webpack --env.profile=desktop --env.environment=production --env.treeshake=yes
    
    
    
    
    > [email protected] clean /app
    > rimraf build
    
    
    i [ext]: ext-webpack-plugin v7.0.2, Ext JS v7.0.0 Community Edition, Sencha Cmd v7.0.0.40, webpack v4.39.3n/a
    i [ext]: Starting production build for extjs
    i [ext]: Processing Build Descriptor : desktop (production environment)
    i [ext]:  [ERR] WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.google.gson.internal.bind.ReflectiveTypeAdapterFactory (file:/app/node_modules/@sencha/cmd/dist/lib/closure-compiler-v20180610.jar) to field java.io.File.path WARNING: Please consider reporting this to the maintainers of com.google.gson.internal.bind.ReflectiveTypeAdapterFactory WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release
    i [ext]:  [ERR] Warning: Nashorn engine is planned to be removed from a future JDK release
    i [ext]:  [ERR] Warning: Nashorn engine is planned to be removed from a future JDK release
    i [ext]:  [ERR] Warning: Nashorn engine is planned to be removed from a future JDK release
    i [ext]: Loading compiler context
    i [ext]: Loading app json manifest...
    i [ext]:  [ERR] Warning: Nashorn engine is planned to be removed from a future JDK release
    i [ext]:  [ERR] Warning: Nashorn engine is planned to be removed from a future JDK release
    i [ext]:  [ERR] Warning: Nashorn engine is planned to be removed from a future JDK release
    i [ext]: Processing data with CmdJavascriptCompressor
    i [ext]: Writing concatenated output to file /build/production/App/generatedFiles/desktop/app.js
    i [ext]:  [ERR] Warning: Nashorn engine is planned to be removed from a future JDK release
    i [ext]:  [ERR] Warning: Nashorn engine is planned to be removed from a future JDK release
    i [ext]: Writing content to /build/temp/production/App/slicer-temp/bootstrap.json
    i [ext]: Writing content to /build/temp/production/App/slicer-temp/bootstrap.js
    i [ext]:  [ERR] Warning: Nashorn engine is planned to be removed from a future JDK release
    i [ext]: Writing content to /build/production/App/generatedFiles/desktop.json
    i [ext]: [ERR]
    i [ext]: [ERR] BUILD FAILED [ERR] com.sencha.exceptions.ExProcess: Failed creating background process
    i [ext]: [ERR]  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    i [ext]: [ERR]  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    i [ext]: [ERR]  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    i [ext]: [ERR]  at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    i [ext]: [ERR]  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    i [ext]: [ERR]  at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    ...
    The exception information in the error file contains the text below. I'm not certain but I think it's trying to run that node binary executable down at app/node_modules/@sencha/cmd/dist/bin/linux-x64/node/node.

    Code:
    Exception information:
    =======================
    /app/node_modules/@sencha/cmd/dist/plugin.xml:333: The following error occurred while executing this line:
    /app/node_modules/@sencha/cmd/dist/ant/build/app/build-impl.xml:292: The following error occurred while executing this line:
    /app/node_modules/@sencha/cmd/dist/ant/build/app/sass-impl.xml:205: The following error occurred while executing this line:
    /app/node_modules/@sencha/cmd/dist/ant/build/app/sass-impl.xml:240: com.sencha.exceptions.ExProcess: Failed creating background process
         at com.sencha.ant.AntScript.execute(AntScript.java:121)
         at com.sencha.command.plugin.PluginManager.execute(PluginManager.java:104)
         at com.sencha.command.plugin.PluginManager.executeReverseFirst(PluginManager.java:145)
         at com.sencha.command.environment.BuildEnvironment.execute(BuildEnvironment.java:309)
         at com.sencha.command.environment.AppOrPackageEnvironment.execute(AppOrPackageEnvironment.java:729)
    ...
    Caused by: Failed creating background process
    ...
    Caused by: Cannot run program "/app/node_modules/@sencha/cmd/dist/bin/linux-x64/node/node" (in directory "/app/node_modules/@sencha/cmd/dist"): error=2, No such file or directory
    ...
    Caused by: error=2, No such file or directory
    Anyone have a suggestion on what is missing?

  2. #2
    Sencha User
    Join Date
    Nov 2010
    Location
    Canton, GA, USA
    Posts
    164

    Default

    Figured it out. The build is trying to run node_modules/@sencha/cmd/dist/bin/linux-x64/node/node but that executable is linked against glibc which isn't used on Alpine linux. I was able to hack around it by replacing that executable with a link to the instance of node installed via the normal package tools. Not pretty but working.

    The Dockerfile below is building for me now. The same logic should be usable under GitLab-CI too. Cheers!

    Code:
    FROM alpine:latest
    
    # Need NPM for the build, Expect for login, Java and Bash for Cmd
    RUN apk add npm expect openjdk11-jre bash
    
    # Log into the 
    COPY scripts/npm-login /usr/local/bin
    RUN npm-login && rm /usr/local/bin/npm-login
    
    # Install the ext-gen too. Replace this with a COPY of the code later.
    RUN npm install -g @sencha/ext-gen
    RUN ext-gen app -t universalmodern -m theme-material -n App
    RUN sed -i 's/--env.profile=desktop //' /app/package.json
    
    # ***Hack*** to deal with the version of NodeJS in Cmd requiring glibc
    RUN rm /app/node_modules/@sencha/cmd/dist/bin/linux-x64/node/node
    RUN ln -s /usr/bin/node /app/node_modules/@sencha/cmd/dist/bin/linux-x64/node/node
    
    # Build into /app/build/production/App/
    RUN cd app && npm run build

  3. #3
    Sencha User
    Join Date
    Nov 2010
    Location
    Canton, GA, USA
    Posts
    164

    Default

    The issue is that the node binary pulled with Cmd via npm is linked against glibc which isn't used with Alpine Linux. So, another missing dependency is glibc but I was able to just remove node_modules/@sencha/cmd/dist/bin/linux-x64/node/node and replace it with a soft-link to /usr/bin/node and the build is working now.

    Below is a job definition in my .gitlab-ci.yml file that builds the webapp.

    Code:
    build:app:
      extends:
        - .with:alpine
      stage: build
      variables:
        NPM_REGISTRY: 'https://sencha.myget.org/F/community/npm/'
        NPM_SCOPE: '@sencha'
      script:
        - apk add --update npm expect openjdk11-jdk bash
        - cd app
        - if [ -z "$NPM_USER" ]; then echo "NPM_USER not set!"; exit 1; fi
        - if [ -z "$NPM_PASS" ]; then echo "NPM_PASS not set!"; exit 1; fi
        - if [ -z "$NPM_MAIL" ]; then echo "NPM_MAIL not set!"; exit 1; fi
        - |
          /usr/bin/expect <<EOD
            spawn npm login --registry=$NPM_REGISTRY --scope=$NPM_SCOPE
            expect {
                "Username:" {send "$NPM_USER\r"; exp_continue}
                "Password:" {send "$NPM_PASS\r"; exp_continue}
                "Email: (this IS public)" {send "$NPM_MAIL\r"; exp_continue}
            }
          EOD
        - npm install
        - rm node_modules/@sencha/cmd/dist/bin/linux-x64/node/node
        - ln -s /usr/bin/node node_modules/@sencha/cmd/dist/bin/linux-x64/node/node
        - npm run build
      artifacts:
        paths:
          - app/build/production
        expire_in: 1 day
      cache:
        key: ${CI_COMMIT_REF_SLUG}
        paths:
          - app/node_modules/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •