Docker 构建 vue 项目失败: vue-cli-service: not found 作者: Chuwen 时间: 2021-12-28 分类: Docker 评论 报错内容: ``` => ERROR [project_nginx frontend 7/7] RUN npm run build 0.6s ------ > [project_nginx frontend 7/7] RUN npm run build: #34 0.523 #34 0.523 > project-web@0.1.0 build /app #34 0.523 > vue-cli-service build #34 0.523 #34 0.528 sh: vue-cli-service: not found #34 0.534 npm ERR! code ELIFECYCLE #34 0.534 npm ERR! syscall spawn #34 0.534 npm ERR! file sh #34 0.535 npm ERR! errno ENOENT #34 0.537 npm ERR! project-web@0.1.0 build: `vue-cli-service build` #34 0.538 npm ERR! spawn ENOENT #34 0.538 npm ERR! #34 0.538 npm ERR! Failed at the project-web@0.1.0 build script. #34 0.538 npm ERR! This is probably not a problem with npm. There is likely additional logging output above. #34 0.542 #34 0.542 npm ERR! A complete log of this run can be found in: #34 0.542 npm ERR! /root/.npm/_logs/2021-12-28T02_12_13_429Z-debug.log ------ failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c npm run build]: exit code: 1 ``` 找到相关的问题:https://github.com/vuejs/vue-cli/issues/5107 解决办法,从你的 Dockerfile 把这行 `ENV NODE_ENV production` 去除就可以了
docker-compose build 报错 failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: write 作者: Chuwen 时间: 2021-12-27 分类: Docker 评论 报错信息:failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: write /var/lib/docker/buildkit/content/ingest/9e291301cada8545e8af2716ad4b51d25c1c394c7d56537588545a27b1af6caa/total: no space left on device ```shell ➜ project git:(docker) ✗ docker-compose build [+] Building 131.6s (6/7) [+] Building 136.5s (7/7) FINISHED => [project_nginx internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 1.31kB 0.0s => [project_php internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 1.31kB 0.0s => [project_nginx internal] load .dockerignore 0.0s => => transferring context: 193B 0.0s => [project_php internal] load .dockerignore 0.0s => => transferring context: 193B 0.0s => [project_nginx internal] load metadata for docker.io/shine09/php-fpm:73 1.4s => CANCELED [project_nginx internal] load metadata for docker.io/library/composer:latest 133.3s => ERROR [project_nginx internal] load metadata for docker.io/library/nginx:alpine 1.9s ------ > [project_nginx internal] load metadata for docker.io/library/nginx:alpine: ------ failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: write /var/lib/docker/buildkit/content/ingest/9e291301cada8545e8af2716ad4b51d25c1c394c7d56537588545a27b1af6caa/total: no space left on device ``` 造成这个问题的原因是,空间不足了 尝试过清理遗留的容器、镜像,但是空间大小仍然没有改变 原来需要使用 `docker builder prune` 去清理 > Docker 18.09 引入了 BuildKit ,提升了构建过程的性能、安全、存储管理等能力。 > > 用以是删除 build cache。 运行结果: ```shell ➜ roject git:(docker) ✗ docker builder prune WARNING! This will remove all dangling build cache. Are you sure you want to continue? [y/N] y Deleted build cache objects: 060s6iobx2shjaur2mxdud5uk loa6pcyqmg11ym2sx51uo5mp1 ykgerexwlp929jappel9z6xbw btwou3o6i0irgz416802igzmr z35xnktojiru2ek6k6jx1fixi zvtbk67q6efiteclfhqxpwwn4 ql0t8d9ey0t31lys5nrdl5ki6 ncrhcutzyt24ug4ppeb2odxks ejrrwsegogolzr54exkj6j0y3 z6ma19hnezpbnmhomdv73pvnp n0z6lqel7uogkns227vepz080 kv0wjg3sg239d12b0s73chcws 7xignroaqqcqsz8i3hdyub7c8 ijytq7jyunw3m2w7b8awpad6s rdfb818hs23cb7l4fxd3mxes6 k9hwj0nn8bqt7o610n8w3sd6z qanccc59jlimvhns3ic9c1pk6 xyn0xlzgx5lbold0fwe88i473 le0bhembbcwtvzhroyf92bx9i poga60u5n1xl9gjxzk1rgp9lz kctx61rkwuglfac4trup453cm vuphn2d9cqskavhul6ydgeuqz bu2wr9kq2sw3reftlahoh9phe 6dtt297kn1in1dooprwtmby41 ww3mcb8wr0mxeo2uhdop4glqp icosuea3s1de78t8yx31aa0da j4fsvxwwa8fdc34w5uv991hzr j3k3r9h1p5eosjfpvhxynpzzx 1c0vo3skwezjlpnvl42hnco1u bb9vb28l9tn54ag2ljo2naefy kzzaw7m93ut1buj25qjozqv7a kjrnlbs9g79qnd6n4i38o9s4j g67e155v4wxeazfnmc6rq6dk3 b5yuon9rxo6syloq9dwqhcf7j oqati1aj4uof1a6d576qsip6o thwdqppga6i6j83liem4sgkhq bv8mleimb82wnoga7ynudrlay 3yaxulepeia74fua7l5qodsg6 ebjvv9c4gc3207m6jaskblhdx xe19sev0kllyueg0sljdh7sro 2655yecp46266g2e4r1078xwp 9mfmn9hn4iois86o784baw7eb ya4voiv79edyfgy25i2cz9rn6 xkyaincdmwcnuctukty3wzy2c to1wbodnkrcrvt137sprfwl87 gxbmdx9tv3zmuyiodfrj2wpu6 0in53gnwih744wiy7m0c0fp7v iah58nlbbxidi3p6f89ekvvpb eaet1zsbdmvc6gp7f3cjghd8n 4wva5bqyv6xvp8fqjao8vwyzv cmo0gaad2guwpqr1scyjbw68a xinmrl0m7asw8umb9sp14pbgr m9gvvbuozgfwx07i2gx7pm733 iger8gj8r6mh5deywqycqzp0y x1bgxl4vvofqcu05ddjwhaps3 zkyi2k6v9stlnq3edv4rsfni9 zbayx6yb6jo0bq12viig50hfl yq8f7bq6l9r42vu06xbzx7zck 9bagz8pt8gi07xn17ev0ibrlk sx36yf96z8mcorw05cfxzyb5y oivdne6d7n9y727gd1ygrgz61 7yo2s648ou7k9ukxa5lzg3drj tmaiy4wcix9ozby5n17ckxhkq wx8xj4obo38xieuk8ij65pc8b 0lkfs4by1chxdrfcdqojrtqfk 4bwup6q8mpr5nybq6ykkueuxx thn4ntkx71m135e7dq5lxl47f nudgk7acvd3txrhx9a3mkqcp7 ug0i27yka96at7pbl999g2mpn 9bhvgkajhwl49hvx649ldh0nv syci6cpr8yxh14myibd8jnj1j slgfmgr8gix7scda1ah7m69s3 o0e7w3c47a7jnjwz0xtd9hba6 la598f701zjjje7v3fajqttou ipsajnw8s6f0bnn8zj3t8lhl1 7zpoxctmlu1s0ag4vnt9dv7tp gvbpryxerb50b3ypgakghs04k g6whd57o2dvx4zfpfghagreh4 crlfatxx3qygnc1kh2sgofaz5 kzhx9qq9tlgfnnb7mixruuc1t khcwtjoovt654w9hms1u7qrux 61t5ylrq9abx7mretz0ychnt5 jeor27taqeql0dtpnhhyj0jdf j8ob85u00seposa9x2sftcel7 9n51q2l1b9tfx5egqb6jhdrs9 hwbs1e3d89w9zs8ynt9bmhk3c 7petri052vigslcacydlu0dye 6btuxpf4hlicdt15srcumle3r vwsb5wlfy6muv40iw0g7t0sj3 rm84nqpnhberfz22t4soxwzzg maq02kqqq4qljq3g38e0yhcmc el7khby49sazdgb5ye9biw7di y879m9qh4p01thm9vw24p5k23 shf7twld7fqrrnmoyg7ot2htg ztgnpbw3yhwzkjrsc0egi2n9g 2o97ep47lux0hr6a6ey5q319m iiinckra4ufnp3e5j6vttx1gv z0wa3npzfjbrx2ct5g28g9k19 jw4s5xxhczay547ybw04gemve khp4tlij3mjriujk2oto55w1t qkxdeliyqg8jizqcvwdgatkhz 9wo5drszq2alqn4i7v12tdv9a d94ypppyuuh5wb4ab4y81p8cg izc5xrv7smmx598zwcbf94mrs v06yztvgr63zrvmuclddhl60r 02opuxw6sw1nktnemvg3tdbfn ehe60fc9zm3kvu7k63di4u72r 0d520f54vvmtjq3ifnon1oxte v6xmogq5qvmmysg8a8i6zojrb h9t2vx8z177o3gfe1j8zhj8sy qo56gtd2pgk8j2rmeoa3q2z6x 4lr3jz7oy304ifvkfymx68uq6 l3qjj0rlzb9it64dqstasxzqo zjwzbdoulk3syrefhojtvjnye huk8zv42tbejdmbw9vf8yebm6 us4zg6el0mlr1wpbteeoby77m c4wjprfiiiojk9hyqhtcwe20v 0cu7b1sijs07jzbk0jue3g84e 93dg4l5q8twmty4w09cpaj2c3 x1hsak9a8jkgz24a0191ylfrh v5sjttfws18bzmc85elchbz8c knqjbh2d89u35canp5tud1onb mui3faeth4hjocy3g23hn03q0 kef6dtg73sivql1yb33p2f2bc x59oqktfqrvxppzdi5idxawid 5mgjgorlv06qb7u3nyickehyf mwgssq8qcmrvtzsuzwyrhnlon expgls0lg5spy7zm36pbjgbtq pd2p1owc094mh3cepjfhx61wp 40dw6txh2y0m1qz0x7ljnuda1 n9ttqu1b10gar6skbtbcdmkz6 d0bhpu1i47u5v1hrtnv6xtmto t42k89ahijz7kt88n312dp7ie m2fnh6b4rvligmy534k3b5i4g 3sz7ifqqmqb8u7h4dzfb3p0pt 7oy23bxctl6udzops0cgan9f5 q4t1oacd7kkqmolg9amzi6c06 r14d7mv8kk04lw4inehjr30co 1yw32u510v9ia9q82e24zdzec k2d5y17vc797q55te0s93ng2d u98ihfbrovpu4gtz0o3ocvmdu wrmkh9r63pxu6zqom3jmm684h vdlq4td01wb0v0dlv5e645msr c01eigahfjl25it8mr4jgmyfe qi2dfoa10k1q3w908ff99y07i kc6l4dm5cjalce2nm8afg349u jhlrvpibkfwf5hl9w9tdfb7qz ex3mpt19ldl898di6hmueb5it tbc40vjsw7tcayngonr1j60ju pzendv6s4i4ajuuvr8xkpyug0 ubzt145l9oqu1yoh68d5720fz ukljll2u7sdxqdehli9556liz scn48e0posg6ebai2e1ohraul fsowwv2hmura2xjei48mk19lr uey1ddckh3eas3kr17gfzszdy v2cxja0qfp659gkps8rycfi1w kb3nw6rkn80yh5nanxxs3vtoj s5nl7t61uhz9udozu2n2ybglt qgj2kqetk75uxdy25jemgn4pn lp7nq01xn1yt436g0xrmqtpwn f1kar6e70mu2hltix40hi3bz9 mulq11grm4jc3cycm9yfoji8f jh8yjfmdtoddl8ul5os6yfjkh cm64vyh57q48w1hegejdn7h5t i1kf4jgvb7fhrrwi39eauw41r 8vdtew68la07uwyw75dtstohx 02wz1kvr1i64v8eqe99dp0v6m xi3euq2sqyrp2qwayyptle59q wbofdgiikgafx3t03u6qcgsqy 8rz0wz6qlgo3qbq4dyrtelzv2 bwhyya3my59whrt06vo0tybmq ofgs5q1aytq65mnkpxhkvpvz8 o051qqlmixkbydp32at9ywjbw xojddj4qbj1kkqj4m89mf52jk 8omgo4zj1faipn7dwrjh73i86 kl1rm7ko5wrn0xax1xfde12a6 zeqbzkiuh3gx690whqh9tg8hx n409wb8voerzplv6a1e71swc5 i5h1545b7hbbxzc0x9a9tirfq 5jf54s9cgr3q6uesowrh33uhf 17q2ni2fqgoxvok5xy686qb56 xvgniaph43znc9s7ellhjouvh 99mls6hwpjxk82516dkkxfgbv affvc8fl2lwb95cn0v7wopvtg w0f55bx3fz36lt7wliy8a5dpj 162wf8qykmh5qyi5szmn1n72t 8k6ytmk9bw4rg41j7jwlejyce w86qjxpkvgijz2pq81i2snbuw zka85ldhfv8ibidpbm566a0nv 2kh4vnmaszknztw1ewfofhdlw gezx9k593ltk0uwhdksiiga1e 4yiyfrmxxdvmmto45ayfk4a79 79rxqbdun5vojf46tyrttauto lc0lsk2pc8yg2gfws3d3xwvhi kylmvhy0fgsqhm7gcoirtft9q 0glows7a14lq8xufi2yq78lxh j5b0toxyufowzxu2efj2l5zjd vw7dsy8ywwy6mcue3vtaaajg8 35nfrgzxn00zhfr3swxerbmn6 k3ux3auubx4vrvy3xa30axb73 uxsshp1p572czc291qz6gwyjk iokjegfv1zry15y9skkhcropf p14c8enho5zarrkxzilwajxtq l96bwj3dvch2xsbpxkssprhc7 uqsiazay6ytazb6v7n7dnacgs 92enlx6nyigh9mcxloel45g8h 73xiq05fhplchr5053lwno7ul 8kggdgen3fe5m3ougm340lxtm y60oao32vmv3tkrv36q6yy6lx omggb7adx9zs5l8guricsti71 0yj4a33ypjkxe693hanpe8d13 h9w3qvmq0ue8q6azl905nuod1 ib91ovlhzcjiz91akx2lrvsl6 r6dwipr8elffmpo59ui0q3el7 Total reclaimed space: 7.761GB ```
Git 在当前仓库中添加子模块(与其他 git 仓库相关联 作者: Chuwen 时间: 2021-12-27 分类: 编程工具 评论 [TOC] ## 起步 假设你有 2 个仓库: - 前端:`git@10.0.0.1:project/rear-end.git` - 后端:`git@10.0.0.1:project/front-end.git` 想要在后端的仓库中,关联前端的仓库地址,那么我们可以使用 Git 工具 - 子模块 > 相关文档:[https://git-scm.com/book/zh/v2/Git-工具-子模块](https://git-scm.com/book/zh/v2/Git-工具-子模块) ### 开始使用子模块 > 我们现在从头开始弄,从开始拉后端项目代码开始 ```shell git clone git@10.0.0.1:project/front-end.git cd front-end # 用这个的话就会在当前项目路径下创建一个 rear-end 名字的文件夹 git submodule add git@10.0.0.1:project/rear-end.git # 如果你要指定文件夹名字(如 web),就这么做 git submodule add git@10.0.0.1:project/rear-end.git web # 上述操作完成后,会在项目根目录下出现 .gitmodules 文件和 web 文件夹 # 然后将这两个文件添加 git add .gitmodules web # 提交信息 git commit -m "提交信息" # 推送到远程仓库地址 git push ``` ## 假设其他成员拉取代码 1. 第一种 ```shell git clone git@10.0.0.1:project/front-end.git cd front-end # 这时候发现 web 目录是空的 ls web # 我们需要先出实话子模块 git submodule init # 然后更新 git submodule update ``` 2. 第 2 种 > 我希望拉取代码时,直接也把子模块也拉取进来,那么我们就可以这么做 > > `git clone` 命令传递 `--recurse-submodules` 选项,它就会自动初始化并更新仓库中的每一个子模块, 包括可能存在的嵌套子模块。 ```shell git clone --recurse-submodules git@10.0.0.1:project/front-end.git ``` ## 如果你不想在子目录中手动抓取与合并,那么还有种更容易的方式。 > 运行 `git submodule update --remote`,Git 将会进入子模块然后抓取并更新。 --- 个人简单记录,如果有误请指正!
Linux 搭建网关服务器,使内网服务器访问公网 作者: Chuwen 时间: 2021-12-26 分类: Linux 评论 有这么一个需求: - 其中 1 台主机,可以访问公网 - 其它 2 台主机,不能访问公网,但是这几台主机处于同一个局域网可以相互访问 大概就是如下图的拓扑图 ![](https://cdn.nowtime.cc/2021/12/26/724184458.png) 想要实现的就是,主机 2、主机 3 能够通过**主机 1**访问到公网 ## 首先在可以访问公网的服务器上配置网关服务器 - 系统:`CentOS Linux release 8.3.2011` - 局域网网段:`192.168.58.0/24` - 本机局域网 IP:`192.168.58.3` ```shell # step 1:关闭并永久禁用firewalld服务 systemctl stop firewalld systemctl disable firewalld # step 2:安装iptables-services yum -y install iptables-services # step 3:开启内核转发 vim /etc/sysctl.conf #添加一条规则 net.ipv4.ip_forward = 1 sysctl -p #使之生效 # step 4:配置iptables转发规则,主要下这个网段要改为你的局域网网段 iptables -t nat -A POSTROUTING -s 192.168.58.0/24 -j MASQUERADE #step 5:保存iptables规则 service iptables save #如果不执行save,重启失效 ``` ## 配置其它不能访问公网的服务器的网关地址 - 假设网卡是:`eth0` 1. 查看本机器的 IP 地址 `ip addr`,如图所示,这台机器的局域网 IP 是 `192.168.58.4` ![](https://cdn.nowtime.cc/2021/12/26/2380189393.png) 2. 修改网卡的网关地址 `vi /etc/sysconfig/network-scripts/ifcfg-eth0` 未修改前是长这样的: ![](https://cdn.nowtime.cc/2021/12/26/2461410265.png) 我们需要改成这样 ``` BOOTPROTO="static" IPADDR="192.168.58.4" PREFIX="24" # 请注意这里是网关地址 GATEWAY="192.168.58.3" # DNS 服务器改成能服务的就行(也就是说内网/公网 IP DNS 服务器都可以) DNS1="223.5.5.5" ``` ![](https://cdn.nowtime.cc/2021/12/26/3508620127.png) 3.然后重启即可生效 ## 测试访问 ![](https://cdn.nowtime.cc/2021/12/26/2846226688.png) ---- 参考文章:https://blog.51cto.com/u_11451275/3225436
VirtualBox 使多个虚拟机处在同一个局域网 作者: Chuwen 时间: 2021-12-26 分类: VirtualBox 评论 这里以 macOS 下举例子了,Windows 平台找到类似的菜单设置即可 1. 打开:管理 -> 主机网络管理器 ![](https://cdn.nowtime.cc/2021/12/26/2674229541.png) 2. 然后创建 ![](https://cdn.nowtime.cc/2021/12/26/3323344547.png) 3. 假设我们创建得到的是 **vboxnet2**,然后按照图中进行配置,配置完成后点击 应用 即可 > 需要启用 DHCP 服务器,不然主机没办法自动获取到 IP 地址 ![](https://cdn.nowtime.cc/2021/12/26/2085154264.png) 4. 选择一个你创建的虚拟机,然后点击设置 ![](https://cdn.nowtime.cc/2021/12/26/2135993309.png) 5. 配置网络,然后点击 OK 保存 ![](https://cdn.nowtime.cc/2021/12/26/1545287098.png) 6. 进入虚拟机查看 IP 地址,使用 `ip addr` 命令查看 ![](https://cdn.nowtime.cc/2021/12/26/995892544.png) 7. 如果你有多个虚拟机想要在同一个局域网,那么再从**第 4 步骤**再设置其它虚拟机即可,配置好后,可以通过 `ip addr` 获取本机的 IP 地址,然后用另一台虚拟机使用 ping 命令看是否能够 ping 通 ![](https://cdn.nowtime.cc/2021/12/26/2444902860.png) 希望能这片够对你有所帮助,我也是前前后后花了许多时间去理解,现在大致能够知道怎么去使用,甚至搭建一个旁路由