How to speed up node.js launch in Docker container

I run the official node js image inside the Docker container, and I noticed that the npm launch command runs much longer than when it is outside of Docker.

Are there any settings that I can change to make it work faster? Perhaps allocating more memory to the container?

For reference, I will embed the appropriate files below.

Dockerfile:

FROM node:8.1

WORKDIR var/www/app

# Global install yarn package manager
RUN apt-get update && apt-get install -y curl apt-transport-https && \
    curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
    echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
    apt-get update && apt-get install -y yarn

RUN npm install -g create-react-app

The command that I use to start my container is:

docker run --rm -ti \
--link api-container:api \
--name my-container -p 3000:3000 \
-v $(pwd):/var/www/app nxmohamad/my-container \
bash

and the beginning of the script is just NODE_PATH=. react-scripts start

+1
source share
1 answer

Host > VM > osxfs . - Linux "" . , , . - PHP , , .

, , , , - .

, , .

mounts Docker 17.06, "" , OSX .

, node_modules , , .

, :

docker run --rm -ti \
  --link api-container:api \
  --name my-container -p 3000:3000 \
  -v $(pwd)/index.js:/var/www/app/index.js \
  -v $(pwd)/package.json:/var/www/app/package.json \
  -v $(pwd)/src:/var/www/app/src \
  -v $(pwd)/node_modules:/var/www/app/node_modules:cached \
  nxmohamad/my-container \
  bash

Syncing

, rsync unison, , OSX Windows.

docker-sync. , ( , ), .

+2

Source: https://habr.com/ru/post/1694334/


All Articles