Dockerfile
FROM ubuntu:22.04
# wget https://nodejs.org/dist/v16.17.0/node-v16.17.0-linux-x64.tar.gz
# wget https://github.com/yarnpkg/yarn/releases/download/v1.22.19/yarn-v1.22.19.tar.gz
ENV PATH=/usr/local/node/bin:$PATH \
NODE_VERSION=v16.17.0
ADD node-${NODE_VERSION}-linux-x64.tar.gz /usr/local
RUN ln -s /usr/local/node-${NODE_VERSION}-linux-x64 /usr/local/node \
&& node --version \
&& npm --version \
&& npm config set registry https://registry.npm.taobao.org \
&& npm install -g yarn \
&& yarn --version
WORKDIR /data/apps/node
制作镜像
# docker build -t uhub.service.ucloud.cn/base/ubuntu-node:v16.17.0 .
build代码
# docker run --rm -v /data/apps/node:/data/apps/node uhub.service.ucloud.cn/base/ubuntu-node:v16.17.0 npm i
# docker run --rm -v /data/apps/node:/data/apps/node uhub.service.ucloud.cn/base/ubuntu-node:v16.17.0 npm run build