当前位置: 首页 > news >正文

nofx 前端自己build 镜像脚本

1. Dockerfile:

FROM nginx:1.25.4

MAINTAINER bc l

COPY ./dist /usr/share/nginx/html

COPY ./nginx.conf /etc/nginx/nginx.conf

# 设置容器启动时运行Nginx
CMD ["nginx", "-g", "daemon off;"]

2. nginx.conf

worker_processes auto; worker_rlimit_nofile 65535; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { multi_accept on; worker_connections 65535; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; # 限制body大小 client_max_body_size 500m; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; server { listen 80; server_name localhost; # 开启gzip压缩 gzip on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_types text/plain application/x-javascript application/javascript application/json text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png image/svg+xml application/octet-stream; # 限制外网访问内网 actuator 相关路径 location ~ ^(/[^/]*)?/actuator(/.*)?$ { return 403; } location / { root /usr/share/nginx/html; # docker映射路径 不允许更改 try_files $uri $uri/ /index.html; index index.html index.htm; } location /api/ { proxy_pass http://Your ip:8080/api/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # Increase timeout for long-running API calls proxy_connect_timeout 300s; proxy_send_timeout 300s; proxy_read_timeout 300s; } location /health { return 200 "OK\n"; add_header Content-Type text/plain; access_log off; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }

3. 更新脚本

#!/bin/bash # 容器名称 # 子应用名 quant-web CONTAINER_NAME="quant-web" FULL_IMAGE_NAME="quant-web:1.0.0" # 检查容器是否存在 function check_container_exists { local container_id=$(docker ps -aq --filter name="$1") if [[ -n "$container_id" ]]; then echo "容器 $1 存在" return 0 else echo "容器 $1 不存在" return 1 fi } # 停止并删除容器 function stop_and_remove_container { local container_name=$1 echo "正在停止并删除容器 $container_name..." docker stop "$container_name" && docker rm -f "$container_name" && docker rmi -f "$FULL_IMAGE_NAME" } # 执行docker build function build_image { rm -rf dist unzip dist.zip echo "正在构建Docker镜像..." # 假设Dockerfile在当前目录下 docker build -t "$FULL_IMAGE_NAME" . docker run -d -p 80:80 --network=host --privileged=true --name $CONTAINER_NAME $FULL_IMAGE_NAME echo "quant-web容器已启动!" } # 主逻辑 if check_container_exists "$CONTAINER_NAME"; then stop_and_remove_container "$CONTAINER_NAME" build_image else build_image fi
http://www.jsqmd.com/news/504065/

相关文章:

  • 快速内容创作:Wan2.2-T2V-A5B在社交媒体视频中的应用
  • 亿百特E22 LoRa模块透明传输与定点传输实战指南
  • STK船舶航线规划避坑指南:用Python自动添加航路点的5个关键细节
  • ClearerVoice-Studio语音分离功能体验:轻松分离多人对话,识别超准
  • 【前沿解析】2026年3月19日:AI自主化演进的双重突破——MiniMax M2.7自我进化模型与小鹏第二代VLA端到端自动驾驶
  • Temu核价自动化实战:凌风工具箱智能核价参数详解与配置指南
  • 视频中间件协议转换揭秘:如何用1个H5接口对接大华所有设备(RTSP/GB28181/ONVIF互转)
  • 中国香港中文大学深圳分校全球首创视频广告植入新技术
  • PLC控制箱出问题?这套排查逻辑更高效
  • SAM3部署实战:在CUDA 11.8环境下绕过官方高版本限制
  • DAMO-YOLO作品集:多张图片识别效果展示,感受AI视觉魅力
  • Windows Cleaner:如何彻底解决C盘爆红问题?
  • AD9361 CMOS双端口TDD模式实战:如何实现64Msps基带I/Q数据接收(含增益优化技巧)
  • 大模型时代的职业风口,2026年最值得入局的AI新职业:从训练师到算法研究员
  • Blender3mfFormat深度解析:技术原理与应用实践指南
  • 北京交通大学等机构推出3D场景编辑新方法
  • 仅限首批200名开发者获取:存算一体芯片C语言指令集封装黄金模板(含IEEE 1801-UPF电源域感知接口)
  • Unity游戏实时翻译引擎:突破多语言障碍的全流程解决方案
  • 从基础到应用:全面解析向量与矩阵范数的计算与选择
  • Qwen-Image+RTX4090D效果展示:Qwen-VL对工程CAD图纸的层级结构识别与功能说明生成
  • Matplotlib 3D绘图进阶技巧:如何让你的图形旋转起来并添加动态效果
  • 6万部剧只火96部:AI漫剧出海是内卷时代的唯一解药
  • 用PyBullet给Jaka机械臂实现招手动作:从URDF导入到完整仿真流程
  • 智慧医院行业内主流的ICU远程探视系统品牌推荐
  • 收藏这篇!大模型Skill开发实战:从模糊需求到高质量AI工具的转化艺术
  • 华硕笔记本硬件调控工具G-Helper:从痛点到解决方案的全面指南
  • 2026机车冶金行业耐用加长铣头推荐清单:万向铣头、双向铣头、后缩式角度头、扁铣头、直角铣头、重点、侧铣头、加长铣头选择指南 - 优质品牌商家
  • 告别加密格式:用Python脚本一键解密网易云NCM歌曲(附完整源码)
  • Retinaface+CurricularFace应用案例:智能门禁系统快速搭建指南
  • 无需编译的KD树库:Nanoflann如何加速三维空间搜索