很多服务器内网环境安装东西简直是无法安装,上网上搜一般都是yum install,老子他妈有yum用你bb?这里采用docker镜像制作好导出到服务器上。
第一步先离线安装docker https://www.jianshu.com/p/1c9b7ff05aae
第二步制作服务镜像
这时候很容易就FROM node:14.19.0开始造镜像,结果打包完成一个g,根本不能够上线。换了基础镜像alpine:latest。
Alpine Linux 是一个社区开发的面向安全应用的轻量级Linux发行版。大小只有5m,适合用来做Docker镜像https://www.alpinelinux.org/。
FROM alpine:latest
RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories \ #更换淘宝镜像源
&& apk add --no-cache --update nodejs npm git bash nginx\ #下载依赖方便又快捷
&& node -v \
&& npm -v
WORKDIR /home
RUN npm install n -g \
&& n 14.19.0 \
&& git init\
&& git config --global user.name "name "\
&& git config --global user.password "password"\
&& git clone https://name :password@gitee.com/???/vue.git \
&& cd vue \
npm install --registry=https://registry.npm.taobao.org \
# && git checkout test \
# && npm run build \
# && cd dist-test \
制作镜像时一些长用命令
docker build -t nb:6 . #制作镜像
#docker container prune #删除不用的镜像
# docker run -it -v /home/dist:/home/vue/dist-test/ --name nb nb:6
#将打包后的文件夹挂载到服务器的tomcat下
在本地制作好镜像通过堡垒机上传到服务器,在服务器导入。
docker save 0fdf2b4c26d3 > hangge_server.tar
docker load < hangge_server.tar
#我们还可以同时将多个 image 打包成一个文件,比如下面将镜像库中的 postgres 和 mongo 打包:
docker save -o images.tar postgres:9.6 mongo:3.4