Я пытаюсь создать приложение, используя dockerfile и docker_compose. Все выглядит нормально, пока не придет команда yarn
, которая не создает модуль_узла и не устанавливает зависимости.
docker -компонентный файл:
version: '2'
services:
mdisassistant:
env_file: .env
build:
context: .
args:
- APP_NAME=${APP_NAME}
- APP_USER=app
ports:
- ${APP_PORT}:${APP_PORT}
Dockerfile:
FROM node:10.15.2-alpine
ARG APP_NAME
ARG APP_USER
RUN adduser -D -s /bin/false -h /home/$APP_USER $APP_USER $APP_USER
ENV HOME=/home/$APP_USER
WORKDIR $HOME/$APP_NAME
COPY . .
RUN chown $APP_USER:$APP_USER -R $HOME
USER $APP_USER
RUN whoami
RUN yarn install
RUN ls -la
RUN pwd
RUN yarn build
CMD ["node", "./dist/index.js"]
Вывод:
Building mdisassistant
Step 1/15 : FROM node:10.15.2-alpine
---> 072459fe4d8a
Step 2/15 : ARG APP_NAME
---> Using cache
---> 4c30b08b312d
Step 3/15 : ARG APP_USER
---> Using cache
---> 9631ef748cd7
Step 4/15 : RUN adduser -D -s /bin/false -h /home/$APP_USER $APP_USER $APP_USER
---> Using cache
---> f5d045ca5282
Step 5/15 : ENV HOME=/home/$APP_USER
---> Using cache
---> 32c4f9457b9e
Step 6/15 : WORKDIR $HOME/$APP_NAME
---> Using cache
---> a8d71a9f563f
Step 7/15 : COPY . .
---> d4ef17f02a9f
Step 8/15 : RUN chown $APP_USER:$APP_USER -R $HOME
---> Running in f6c194316e12
Removing intermediate container f6c194316e12
---> f6742a0c10df
Step 9/15 : USER $APP_USER
---> Running in ec22ed655aa5
Removing intermediate container ec22ed655aa5
---> af800732027d
Step 10/15 : RUN whoami
---> Running in ba9fa81a95a3
app
Removing intermediate container ba9fa81a95a3
---> ebf0f6a4f8a7
Step 11/15 : RUN yarn install
---> Running in 4d5e76dd1508
yarn install v1.13.0
[1/4] Resolving packages...
[2/4] Fetching packages...
Removing intermediate container 4d5e76dd1508
---> 1785eec9829e
Step 12/15 : RUN ls -la
---> Running in b0f3f1b1e5fc
total 92
drwxr-sr-x 1 app app 4096 Mar 21 02:52 .
drwxr-sr-x 1 app app 4096 Mar 21 02:52 ..
-rw-r--r-- 1 app app 1610 Mar 21 02:05 .dockerignore
-rw-r--r-- 1 app app 62 Mar 21 00:56 .env.example
drwxr-xr-x 1 app app 4096 Mar 21 02:52 .git
-rw-r--r-- 1 app app 1610 Mar 20 23:56 .gitignore
-rw-r--r-- 1 app app 333 Mar 21 02:52 Dockerfile
-rw-r--r-- 1 app app 1060 Mar 20 23:56 LICENSE
-rw-r--r-- 1 app app 681 Mar 20 23:56 README.md
-rw-r--r-- 1 app app 280 Mar 21 02:35 docker-compose.yml
-rw-r--r-- 1 app app 614 Mar 21 01:57 package.json
drwxr-xr-x 1 app app 4096 Mar 21 01:05 src
-rw-r--r-- 1 app app 44193 Mar 21 01:20 yarn.lock
Removing intermediate container b0f3f1b1e5fc
---> eb6fbee4548f
Step 13/15 : RUN pwd
---> Running in 92b3d6d20201
/home/app/mdisassistant
Removing intermediate container 92b3d6d20201
---> 853d9879da99
Step 14/15 : RUN yarn build
---> Running in 205ef8079386
yarn run v1.13.0
$ ncc build src/index.js -o dist -m
/bin/sh: ncc: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: Service 'mdisassistant' failed to build: The command '/bin/sh -c yarn build' returned a non-zero code: 1
Как решить эту проблему?