Recently, it was discovered that the node.js image written before could not be executed. After checking the problem, it was found that alpine’s node-npm dependency package was renamed. It was node-npm, but now it’s NPM, so just change the Dockerfile.

FROM alpine:latest
# Install nodeJS environment, domestic use Ali cloud image acceleration, otherwise too slow, package server in foreign can not change.
RUN echo "http://mirrors.aliyun.com/alpine/edge/main/" > /etc/apk/repositories \
    && echo "http://mirrors.aliyun.com/alpine/edge/community/" >> /etc/apk/repositories \
    && apk update \
    && apk add --no-cache --update nodejs npm \ # With regard to versioning, the production environment recommends locking the version
    && node -v && npm -v \
    && npm config set registry https://registry.npm.taobao.org

ENV NODE_ENV production

WORKDIR /home/app

COPY package.json /home/app/

RUN npm install --production

COPY . /home/app

EXPOSE 8080

CMD ["npm"."start"]
Copy the code

Author: Yohito Kusami

In this paper, the original address: blog. Cmyr. LTD/archives / 41…

Copyright Notice: Reprint please indicate the source!