Докер npm Не найден в Debian: jessie20180831 - PullRequest
0 голосов
/ 05 октября 2018

Мой Dockerfile

FROM debian:jessie-20180831 as builder
ENV BUILD_DEPS "curl git"

COPY . /go/src/chaochaogege.com/onlinecode
WORKDIR /go/src/chaochaogege.com/onlinecode
RUN apt-get update && apt-get install curl git sudo --no-install-recommends -y
RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E sh -;\
    apt-get install nodejs -y --no-install-recommends;

RUN cd ./client-side \
    && npm install && npm run build;
COPY ./sql ./client-side/dist/

RUN apt-get update && apt-get install ${BUILD_DEPS} -y --no-install-recommends;\
    curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh; \
    dep ensure -update;\
    go install;

FROM golang:1.11.1-alpine3.7
RUN mkdir -p /go/src/chaochaogege.com/onlinecode
WORKDIR /go/src/chaochaogege.com/onlinecode
COPY --from=builder /go/bin/onlinecode .
COPY --from=builder /go/src/chaochaogege.com/onlinecode/client-side/dist/* .
EXPOSE 8086
ENTRYPOINT ["onlinecode"]

Я не знаю, что случилось.На мой взгляд, я устанавливаю nodejs на уровне RUN, а затем использую npm в другом слое.

Но почему бы не работать?

Я уверен, что есть несколько вопросов-дубликатов, но все они не решают мою проблему.

Полагаю, возможно, что npm можно использовать только в том же слое докеров?Поэтому я изменяю Dockerfile на следующее:

FROM debian:jessie-20180831 as builder
ENV BUILD_DEPS "curl git"

COPY . /go/src/chaochaogege.com/onlinecode
WORKDIR /go/src/chaochaogege.com/onlinecode
RUN apt-get update && apt-get install curl git sudo --no-install-recommends -y
RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E sh -;\
    apt-get install nodejs -y --no-install-recommends;\
    npm --version; \
    cd ./client-side \
    && npm install && npm run build;

COPY ./sql ./client-side/dist/

RUN apt-get update && apt-get install ${BUILD_DEPS} -y --no-install-recommends;\
    curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh; \
    dep ensure -update;\
    go install;

FROM golang:1.11.1-alpine3.7
RUN mkdir -p /go/src/chaochaogege.com/onlinecode
WORKDIR /go/src/chaochaogege.com/onlinecode
COPY --from=builder /go/bin/onlinecode .
COPY --from=builder /go/src/chaochaogege.com/onlinecode/client-side/dist/* .
EXPOSE 8086
ENTRYPOINT ["onlinecode"]

Но также получаю результат

npm не найден

Журнал ошибок

Step 6/15 : RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E sh -; apt-get install nodejs -y --no-install-recommends; npm --version; cd ./client-side && npm install && npm run build;

---> [Warning] Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.

---> Running in 2788863ccf8a

Reading package lists...

Building dependency tree...

Reading state information...

The following extra packages will be installed:

libc-ares2 libv8-3.14.5

The following NEW packages will be installed:

libc-ares2 libv8-3.14.5 nodejs

0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.

Need to get 1990 kB of archives.

After this operation, 7495 kB of additional disk space will be used.

Get:1 http://deb.debian.org/debian/ jessie/main libc-ares2 amd64 1.10.0-2+deb8u2 [72.5 kB]

Get:2 http://deb.debian.org/debian/ jessie/main libv8-3.14.5 amd64 3.14.5.8-8.1 [1269 kB]

Get:3 http://deb.debian.org/debian/ jessie/main nodejs amd64 0.10.29~dfsg-2 [648 kB]

[91mdebconf: delaying package configuration, since apt-utils is not installed

[0mFetched 1990 kB in 1s (1874 kB/s)

Selecting previously unselected package libc-ares2:amd64.

(Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 9841 files and directories currently installed.)

Preparing to unpack .../libc-ares2_1.10.0-2+deb8u2_amd64.deb ...

Unpacking libc-ares2:amd64 (1.10.0-2+deb8u2) ...

Selecting previously unselected package libv8-3.14.5.

Preparing to unpack .../libv8-3.14.5_3.14.5.8-8.1_amd64.deb ...

Unpacking libv8-3.14.5 (3.14.5.8-8.1) ...

Selecting previously unselected package nodejs.

Preparing to unpack .../nodejs_0.10.29~dfsg-2_amd64.deb ...

Unpacking nodejs (0.10.29~dfsg-2) ...

Setting up libc-ares2:amd64 (1.10.0-2+deb8u2) ...

Setting up libv8-3.14.5 (3.14.5.8-8.1) ...

Setting up nodejs (0.10.29~dfsg-2) ...

update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode

Processing triggers for libc-bin (2.19-18+deb8u10) ...

[91m/bin/sh: 1: npm: not found

1 Ответ

0 голосов
/ 06 октября 2018

С apt-get install nodejs вы устанавливаете только узел, но не npm сам.Вы можете проверить файлы nodejs в индексе пакета debian .

Для установки npm вам необходимо установить пакет npm .

Итак, чтобы исправить ваш Dockerfile, отредактируйте эту строку:

apt-get install nodejs -y --no-install-recommends;

С:

apt-get install nodejs npm -y --no-install-recommends;

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...