Skip to content

Commit

Permalink
feat:npm配置同时配置node用户配置和全局配置; 增加配置选项
Browse files Browse the repository at this point in the history
  • Loading branch information
wakefun committed Jul 5, 2024
1 parent dde3cf8 commit 89d565f
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 48 deletions.
15 changes: 15 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
registry=https://registry.npmmirror.com
disturl=https://registry.npmmirror.com/-/binary/node/
# node-sass预编译二进制文件下载地址
sass_binary_site=https://registry.npmmirror.com/-/binary/node-sass
# sharp预编译共享库, 截止2022-09-20 [email protected]的预编译共享库并未同步到镜像, 入安装失败可切换到[email protected]使用
sharp_libvips_binary_host=https://registry.npmmirror.com/-/binary/sharp-libvips
python_mirror=https://registry.npmmirror.com/-/binary/python/
electron_mirror=https://registry.npmmirror.com/-/binary/electron/
electron_builder_binaries_mirror=https://registry.npmmirror.com/-/binary/electron-builder-binaries/
# 无特殊配置参考{pkg-name}_binary_host_mirror={mirror}
canvas_binary_host_mirror=https://registry.npmmirror.com/-/binary/canvas
node_sqlite3_binary_host_mirror=https://registry.npmmirror.com/-/binary/sqlite3
better_sqlite3_binary_host_mirror=https://registry.npmmirror.com/-/binary/better-sqlite3
# phantomjs
phantomjs-cdnurl=https://repo.huaweicloud.com/phantomjs/
13 changes: 7 additions & 6 deletions 10/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@ FROM node:10-buster-slim
LABEL org.opencontainers.image.authors="wakefun"
LABEL org.opencontainers.image.documentation="https://github.com/wakefun/docker-node-cn/blob/main/README.MD"

ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin

USER root
COPY --chown=root:root apt/buster.http /etc/apt/sources.list
RUN apt-get update \
&& apt-get install -y apt-transport-https ca-certificates gnupg \
# 添加软件密钥,因为该版本的node官方已经drop了,后续没有基于新的debian底包更新,所以会有key缺失的情况导致apt-get update失败
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0E98404D386FA1D9 6ED0E7B82643E131
COPY --chown=root:root apt/buster /etc/apt/sources.list
COPY --chown=node:node .npmrc /home/node/.npmrc
RUN mkdir -p /home/node/.npm-global/etc \
&& cat /home/node/.npmrc >> {}/etc/npmrc'
USER node
RUN mkdir -p /home/node/node-cn
WORKDIR /home/node/node-cn
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin
RUN npm config set registry https://registry.npmmirror.com \
&& yarn config set registry=https://registry.npmmirror.com \
&& npm version >> .node-cn-info \
&& yarn versions >> .node-cn-info
RUN npm version >> .node-cn-info
ONBUILD RUN cat /home/node/node-cn/.node-cn-info
15 changes: 8 additions & 7 deletions 12/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ FROM node:12-bullseye-slim
LABEL org.opencontainers.image.authors="wakefun"
LABEL org.opencontainers.image.documentation="https://github.com/wakefun/docker-node-cn/blob/main/README.MD"

ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin

USER root
COPY --chown=root:root apt/bullseye.http /etc/apt/sources.list
RUN apt-get update && apt-get install -y apt-transport-https ca-certificates
COPY --chown=root:root apt/bullseye /etc/apt/sources.list
COPY --chown=node:node .npmrc /home/node/.npmrc
RUN mkdir -p /home/node/.npm-global/etc \
&& cat /home/node/.npmrc >> {}/etc/npmrc'
USER node
RUN mkdir -p /home/node/node-cn
WORKDIR /home/node/node-cn
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin
RUN npm config set registry https://registry.npmmirror.com \
&& yarn config set registry=https://registry.npmmirror.com \
&& npm i -g pnpm@6 \
&& npm version >> .node-cn-info \
&& yarn versions >> .node-cn-info
RUN npm i -g pnpm@6 \
&& npm version >> .node-cn-info
ONBUILD RUN cat /home/node/node-cn/.node-cn-info
15 changes: 8 additions & 7 deletions 14/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ FROM node:14-bullseye-slim
LABEL org.opencontainers.image.authors="wakefun"
LABEL org.opencontainers.image.documentation="https://github.com/wakefun/docker-node-cn/blob/main/README.MD"

ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin

USER root
COPY --chown=root:root apt/bullseye.http /etc/apt/sources.list
RUN apt-get update && apt-get install -y apt-transport-https ca-certificates
COPY --chown=root:root apt/bullseye /etc/apt/sources.list
COPY --chown=node:node .npmrc /home/node/.npmrc
RUN mkdir -p /home/node/.npm-global/etc \
&& cat /home/node/.npmrc >> {}/etc/npmrc'
USER node
RUN mkdir -p /home/node/node-cn
WORKDIR /home/node/node-cn
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin
RUN npm config set registry https://registry.npmmirror.com \
&& yarn config set registry=https://registry.npmmirror.com \
&& npm i -g pnpm@7 \
&& npm version >> .node-cn-info \
&& yarn versions >> .node-cn-info
RUN npm i -g pnpm@7 \
&& npm version >> .node-cn-info
ONBUILD RUN cat /home/node/node-cn/.node-cn-info
15 changes: 8 additions & 7 deletions 16/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ FROM node:16-bookworm-slim
LABEL org.opencontainers.image.authors="wakefun"
LABEL org.opencontainers.image.documentation="https://github.com/wakefun/docker-node-cn/blob/main/README.MD"

ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin

USER root
COPY --chown=root:root apt/bookworm.http /etc/apt/sources.list
RUN apt-get update && apt-get install -y apt-transport-https ca-certificates
COPY --chown=root:root apt/bookworm /etc/apt/sources.list
COPY --chown=node:node .npmrc /home/node/.npmrc
RUN mkdir -p /home/node/.npm-global/etc \
&& cat /home/node/.npmrc >> {}/etc/npmrc'
USER node
RUN mkdir -p /home/node/node-cn
WORKDIR /home/node/node-cn
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin
RUN npm config set registry https://registry.npmmirror.com \
&& yarn config set registry=https://registry.npmmirror.com \
&& npm i -g pnpm \
&& npm version >> .node-cn-info \
&& yarn versions >> .node-cn-info
RUN npm i -g pnpm \
&& npm version >> .node-cn-info
ONBUILD RUN cat /home/node/node-cn/.node-cn-info
15 changes: 8 additions & 7 deletions 18/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ FROM node:18-bookworm-slim
LABEL org.opencontainers.image.authors="wakefun"
LABEL org.opencontainers.image.documentation="https://github.com/wakefun/docker-node-cn/blob/main/README.MD"

ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin

USER root
COPY --chown=root:root apt/bookworm.http /etc/apt/sources.list
RUN apt-get update && apt-get install -y apt-transport-https ca-certificates
COPY --chown=root:root apt/bookworm /etc/apt/sources.list
COPY --chown=node:node .npmrc /home/node/.npmrc
RUN mkdir -p /home/node/.npm-global/etc \
&& cat /home/node/.npmrc >> {}/etc/npmrc'
USER node
RUN mkdir -p /home/node/node-cn
WORKDIR /home/node/node-cn
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin
RUN npm config set registry https://registry.npmmirror.com \
&& yarn config set registry=https://registry.npmmirror.com \
&& npm i -g pnpm \
&& npm version >> .node-cn-info \
&& yarn versions >> .node-cn-info
RUN npm i -g pnpm \
&& npm version >> .node-cn-info
ONBUILD RUN cat /home/node/node-cn/.node-cn-info
17 changes: 9 additions & 8 deletions 20/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ FROM node:20-slim
LABEL org.opencontainers.image.authors="wakefun"
LABEL org.opencontainers.image.documentation="https://github.com/wakefun/docker-node-cn/blob/main/README.MD"

ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin

USER root
COPY --chown=root:root apt/bookworm.http /etc/apt/sources.list
RUN apt-get update && apt-get install -y apt-transport-https ca-certificates
COPY --chown=root:root apt/bookworm /etc/apt/sources.list
COPY --chown=node:node .npmrc /home/node/.npmrc
RUN mkdir -p /home/node/.npm-global/etc \
&& cat /home/node/.npmrc >> {}/etc/npmrc'
USER node
RUN mkdir -p /home/node/node-cn
WORKDIR /home/node/node-cn
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin
RUN npm config set registry https://registry.npmmirror.com \
&& yarn config set registry=https://registry.npmmirror.com \
&& npm i -g pnpm \
&& npm version >> .node-cn-info \
&& yarn versions >> .node-cn-info

RUN npm i -g pnpm \
&& npm version >> .node-cn-info
ONBUILD RUN cat /home/node/node-cn/.node-cn-info
14 changes: 8 additions & 6 deletions 8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@ FROM node:8-buster-slim
LABEL org.opencontainers.image.authors="wakefun"
LABEL org.opencontainers.image.documentation="https://github.com/wakefun/docker-node-cn/blob/main/README.MD"

ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin

USER root
COPY --chown=root:root apt/buster.http /etc/apt/sources.list
RUN apt-get update \
&& apt-get install -y apt-transport-https ca-certificates gnupg \
# 添加软件密钥,因为该版本的node官方已经drop了,后续没有基于新的debian底包更新,所以会有key缺失的情况导致apt-get update失败
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0E98404D386FA1D9 6ED0E7B82643E131
COPY --chown=root:root apt/buster /etc/apt/sources.list
COPY --chown=node:node .npmrc /home/node/.npmrc
RUN mkdir -p /home/node/.npm-global/etc \
&& cat /home/node/.npmrc >> {}/etc/npmrc'
USER node
RUN mkdir -p /home/node/node-cn
WORKDIR /home/node/node-cn
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin
RUN npm config set registry https://registry.npmmirror.com \
&& yarn config set registry=https://registry.npmmirror.com \
&& npm version >> .node-cn-info \
&& yarn versions >> .node-cn-info
RUN npm version >> .node-cn-info
ONBUILD RUN cat /home/node/node-cn/.node-cn-info

0 comments on commit 89d565f

Please sign in to comment.