node:16 docker 换小镜像
171 字
1 分钟
node:16 docker 换小镜像
现状
原来 docker node:16 的镜像加上代码在 1G 左右

替换方法
常规项目
# Dockerfile- FROM node:16+ FROM node:16.19-slim提换 node:16 为 node:16.19-slim引用 git+https:// 的项目
参考 https://git.qmpoa.com/fe/y-websocket-excel/-/merge_requests/8/diffs



"y-luckysheet": "git+https://git.qmpoa.com/fe_common_lib/y-luckysheet.git#v1.0.1",这种语法,需要在 CI 流程中将这类依赖处理好,在 Dockerfile 中拷贝进 node_modules 下
# 在上一步的基础上 script: - echo "=====start deploy======" - mkdir nm - cd nm # 将咱们自己的依赖以clone的方式放在一个临时目录下 - git clone 'https://git.qmpoa.com/fe_common_lib/y-luckysheet.git' - cd ../# DockerfileRUN npm install --registry=https://registry.npmmirror.com --ignore-scripts --production# 在依赖安装完成后,将临时目录下的内容移动到node_modules下RUN mv ./nm/y-luckysheet ./node_modules/y-luckysheet效果

node:16 docker 换小镜像
https://wangxiang.website/posts/工作/node16-docker/