I'm trying ompile archive node.js executable into one executable using node-packer. For my all packages, executables of node.js are in {projectRoot}/node_modedules/.bin

The project structure as follow:

|- node_modules
|   |-- .bin
|       |--- executable with source code 
|- compiled-bin
|   |-- compiled executable

I wrote a shell script to do it.
Hope you can review it:

for filepath in ./node_modules/.bin/*; do
    export baseName="${filepath##*/}"
    nodec $filepath --clean-tmpdir --make-args=-j10 --output=./compile-bin/$baseName.out  
    chmod +x ./compile-bin/$baseName.out 

This is dockerfile, I used to run the above script in container:

FROM node:8.3.0 as package

WORKDIR /usr/src/app
COPY . /usr/src/app

# Install dependencies
RUN apt-get update
RUN apt-get install -y -q --no-install-recommends \
  build-essential \
  python \
  make \
  squashfs-tools \
  gcc \
  g++ \
  clang-3.5 \

# Install nodec compiler
RUN curl -L http://enclose.io/nodec/nodec-linux-x64.gz | gunzip > /usr/local/bin/nodec
RUN chmod +x /usr/local/bin/nodec

# Install npm packages
RUN npm i --no-optional \
  && ls -lh 

# Run build scripts
RUN mkdir compile-bin \
  && chmod +x ./build-script \
  && sync \
  && ./build-script

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.