码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 团队vue基础镜像选择思考


    前端镜像可以考虑使用nginx或者openresty;

    镜像 大小 说明
    nginx:1.20.2-alpine 8.41 MB 最小最新版本
    nginx:1.21.4 50.95 MB 最新版本
    nginx:stable 1.20.2 52.27 MB 稳定版本
    openresty/openresty:1.19.9.1-4-alpine 33.14 MB 最小最新版本
    openresty/openresty:1.19.9.1-4-alpine-fat 109.68 MB 最小最新功能最全版本

    vue工程

    分阶段打包脚本:

    FROM node:17.3.0
    #FROM node:latest
    WORKDIR /data/cycube/
    COPY . /data/cycube/
    RUN npm config set registry=https://packages.aliyun.com/61516fe9bdfa1bd1b630ac57/npm/npm-registry/
    RUN npm install
    RUN npm run build
    ######################分阶段构建######################
    FROM registry.cn-shanghai.aliyuncs.com/cycube/app:nginx-1.20.2-alpine
    EXPOSE 80
    COPY --from=0 /data/cycube/dist/ /usr/share/nginx/html/
    COPY --from=0 /data/cycube/nginx.conf /etc/nginx/conf.d/default.conf
    RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo Asia/Shanghai > /etc/timezone
    ENTRYPOINT ["nginx"]
    CMD ["-g","daemon off;"]

    运行成功;

    openresty

    FROM openresty/openresty:1.19.9.1-4-alpine
    EXPOSE 80
    COPY ./dist/ /usr/share/nginx/html/
    COPY nginx_front.conf /etc/nginx/conf.d/default.conf
    ENV TZ=Asia/Shanghai
    RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
    ENTRYPOINT ["nginx"]
    CMD ["-g","daemon off;"]

    配置文件:

    server {
    listen 80;
    server_name localhost;
    root /usr/share/nginx/html/;
    location / {
    try_files $uri $uri/ @router;
    index index.html;
    }
    location /test {
    default_type text/html;
    content_by_lua_block {
    ngx.say("<p>hello, openresty!!!</p>")
    }
    }
    error_page 404 /404.html;
    error_page 500 503 504 /50x.html;
    location = /50x.html {
    root /usr/share/nginx/html;
    }
    error_page 502 =200 @jump_to_error;
    location @jump_to_error {
    default_type application/json;
    return 200 '{"ret":503,"msg":"服务器正在重启,请稍候"}';
    }
    }

    打包,

    docker build -t frontrest:v1 -f Dockerfile2resty ./

    测试;

    docker run --name frontrest:v1 -p 80:80 -d frontrest:v1

    lua写的快速接口运行:

    file

    正常前端访问:

    file

    小结

    最终采用openresty作为前端的基础镜像,后续一些短平快的接口实现,直接使用lua搞定;基础镜像大了一部分,但是能力也大大增加了。

    因为前端node版本不同,打包结果和耗时比较随机,这里跟前端妹子约定了版本号,后续的开发环境的版本也使用这个 node:17.3.0

    参考资料

    openresty作为网关
    https://blog.csdn.net/Xavider/article/details/103544222

    原创不易,关注诚可贵,转发价更高!转载请注明出处,让我们互通有无,共同进步,欢迎沟通交流。

  • 相关阅读:
    强化学习(DQN)教程
    C++设计模式---单例模式
    机器学习笔记之高斯过程(二)高斯过程回归——权重空间角度
    十四、使用 Vue Router 开发单页应用(2)
    我31岁,做美工一月8K,后面我该咋办?
    【Reinforcement Learning】actor-critic学习
    Netty
    java经典例题30道——(26-30)
    数商云B2B商城系统订货功能为新能源汽车行业赋能,打造高质量发展生态圈
    【0基础学Java第二课】数据类型与变量
  • 原文地址:https://www.cnblogs.com/snidget/p/16076560.html
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号