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

做论坛网站前段用什么框架好点汽车网站建设方案

做论坛网站前段用什么框架好点,汽车网站建设方案,跳网站查询的二维码怎么做,局域网怎么搭建前端部署采用 docker 的方式, 实现在容器启动时传递环境变量, 请求不同服务地址 实现思路: 定义.env.xxx 文件(环境变量赋值),在compose.yml中引入.env.xxx 文件,环境变量通过nginx的sub_filte…

前端部署采用 docker 的方式, 实现在容器启动时传递环境变量, 请求不同服务地址

实现思路: 定义.env.xxx 文件(环境变量赋值),在compose.yml中引入.env.xxx 文件,环境变量通过nginx的sub_filter放到html的meta标签里
----------------------------------------------------------【etl-ui.env】--------------------------------------------------------------------

API_REQUEST_ADDRESS=http://xxx.xxx.x.xx:8601

----------------------------------------------------------【compose.yml】--------------------------------------------------------------------

compose.yml中前端容器中添加env_file, 引入环境变量配置文件

version: "6.6"
name: myy-system
services:myy-myy-ui-1:container_name: myy-myy-ui-1image: xxx.xxx.x.xx:8084/myy-app-ui:latestrestart: unless-stoppedports:- "8001:8700"env_file:- etl-ui.envdeploy:resources:limits:memory: 8Genvironment:TZ: Asia/Shanghaidepends_on:- myy-myy-ignite-1

----------------------------------------------------------【entrypoint.sh】--------------------------------------------------------------------
在Dockerfile同级目录下添加entrypoint.sh文件, 获取容器启动时传入的环境变量API_REQUEST_ADDRESS的值保存到变量API_REQUEST_ADDRESS_VAL中

#!/bin/bashsed -i "s|API_REQUEST_ADDRESS_VAL|${API_REQUEST_ADDRESS}|g" /usr/share/nginx/html/index.html
exec nginx -g 'daemon off;'

----------------------------------------------------------【Dockerfile】--------------------------------------------------------------------
通过nginx的sub_filter放到html的meta: 复制entrypoint.sh,设置执行权限和容器启动入口

COPY entrypoint.sh /# 设置执行权限
RUN chmod +x /entrypoint.sh# 设置容器启动时的入口
ENTRYPOINT ["/entrypoint.sh"]

Dockerfile完整代码:

# Stage 1: 构建Node.js应用 
FROM node:16.14.0 AS builder
WORKDIR /app 
RUN npm cache clean —force
COPY package*.json ./
RUN npm install --force --registry=http://119.3.241.212:8088/repository/npm-group
COPY . .
RUN npm run build:sit# Stage 2: 构建Nginx镜像
FROM nginx:latest
WORKDIR /usr/share/nginx/html# 将Node.js应用构建结果复制到Nginx镜像中
COPY --from=builder /app/dist/ .# 可选:复制Nginx配置文件
COPY nginx.conf /etc/nginx/nginx.conf# 暴露端口
EXPOSE 8700COPY entrypoint.sh /# 设置执行权限
RUN chmod +x /entrypoint.sh# 设置容器启动时的入口
ENTRYPOINT ["/entrypoint.sh"]

----------------------------------------------------------【nginx.conf】--------------------------------------------------------------------

user  nginx;
worker_processes  1;error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;events {worker_connections  1024;
}http {include       /etc/nginx/mime.types;default_type  application/octet-stream;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;sendfile        on;#tcp_nopush     on;keepalive_timeout  65;gzip_static on;gzip_proxied        expired no-cache no-store private auth;gzip_disable        "MSIE [1-6]\.";gzip_vary           on;gzip  on;gzip_min_length 1k;gzip_buffers 4 16k;gzip_comp_level 9;gzip_types text/plain application/javascript application/css  text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;client_max_body_size 20m;server {listen       8700;listen  [::]:8700;server_name  localhost;location / {root   /usr/share/nginx/html;index  index.html index.htm;try_files $uri $uri/ /index.html;}# 静态资源地址 (其中 /myy/myy-server/  为上下文)location ~* ^/myy/myy-server/(.*)$ {rewrite ^/myy/myy-server/(.*)$ /$1 last;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   /usr/share/nginx/html;}}
}

----------------------------------------------------------【index.html】--------------------------------------------------------------------
public目录下的index.html
添加 <meta content="API_REQUEST_ADDRESS_VAL" name="API_REQUEST_ADDRESS" />, 存储容器启动时传入的环境变量API_REQUEST_ADDRESS_VAL

<!DOCTYPE html>
<html lang="zh-cmn-Hans"><head><meta charset="utf-8" /><meta content="IE=edge" http-equiv="X-UA-Compatible" /><meta content="webkit" name="renderer" /><metacontent="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"name="viewport"/><link href="<%= BASE_URL %>favicon.ico" rel="icon" /><linkhref="<%= BASE_URL %>static/css/loading.css?random=<%= VUE_APP_RANDOM %>"rel="stylesheet"/><title><%= VUE_APP_TITLE %></title><metacontent="myy管理系统"name="keywords"/><meta content="<%= VUE_APP_AUTHOR %>" name="author" /><meta content="API_REQUEST_ADDRESS_VAL" name="API_REQUEST_ADDRESS" /><% if (process.env.NODE_ENV !== 'development') { %><script src="<%= BASE_URL %>static/js/web-report-vue.min.js"></script><!-- <script type="text/javascript">window.Performance({domain: `<%= VUE_APP_PERFORMANCE %>/api/v1/report/web`,add: {appId: `<%= VUE_APP_PERFORMANCE_APP_ID %>`}});</script> --><% }%></head><body><noscript></noscript><div id="app"><div class="first-loading-wrp"><div class="loading-wrp"><span class="dot dot-spin"><i></i><i></i><i></i><i></i></span></div><h1><%= VUE_APP_TITLE %></h1></div></div></body><script type="text/javascript">(function () {var ua = navigator.userAgent.toLocaleLowerCase();var browserType = "",browserVersion = "";if (ua.match(/msie/) != null || ua.match(/trident/) != null) {browserType = "IE";browserVersion =ua.match(/msie ([\d.]+)/) != null? ua.match(/msie ([\d.]+)/)[1]: ua.match(/rv:([\d.]+)/)[1];if (1 * browserVersion < 12) {document.body.innerHTML = "<p>请在Chrome浏览器上使用系统</p>" +"<p><a href='https://www.google.cn/intl/zh-CN/chrome/' target='_blank'>点击下载</a></p>";}}})();</script>
</html>

----------------------------------------------------------【服务请求】--------------------------------------------------------------------
axios请求服务时拿到meta标签content 属性里面存储的API_REQUEST_ADDRESS_VAL的值,即为需要请求的后台服务地址

const CUSTOM_API_REQUEST_ADDRESS = document.querySelector('meta[name="API_REQUEST_ADDRESS"]')?.getAttribute('content')
const API_CONTEXT = '/myy/myy-server'
const requestUrl = process.env.NODE_ENV === "development" ? "" : (CUSTOM_API_REQUEST_ADDRESS+API_CONTEXT)
const instance = axios.create({baseURL: requestUrl,timeout: requestTimeout// headers: {//   "Content-Type": contentType// }
});

文章转载自:
http://dinncotabbinet.zfyr.cn
http://dinncoundergrown.zfyr.cn
http://dinncoreadorn.zfyr.cn
http://dinncoedifier.zfyr.cn
http://dinncoeuchromosome.zfyr.cn
http://dinncolarcenous.zfyr.cn
http://dinncoreboot.zfyr.cn
http://dinncoinfinitize.zfyr.cn
http://dinncoascription.zfyr.cn
http://dinncotrichogenous.zfyr.cn
http://dinncotacan.zfyr.cn
http://dinncoconstitutional.zfyr.cn
http://dinncocivility.zfyr.cn
http://dinncosampan.zfyr.cn
http://dinncoflimsy.zfyr.cn
http://dinncofraktur.zfyr.cn
http://dinncofiduciary.zfyr.cn
http://dinncotallowy.zfyr.cn
http://dinncohavurah.zfyr.cn
http://dinncovelarize.zfyr.cn
http://dinncoanticipant.zfyr.cn
http://dinncocacoepy.zfyr.cn
http://dinncokowhai.zfyr.cn
http://dinncomidst.zfyr.cn
http://dinncoweld.zfyr.cn
http://dinncorosin.zfyr.cn
http://dinncoamphigenous.zfyr.cn
http://dinncogreenbug.zfyr.cn
http://dinncounendurable.zfyr.cn
http://dinncoglebe.zfyr.cn
http://dinncolarn.zfyr.cn
http://dinncoasp.zfyr.cn
http://dinncofrostfish.zfyr.cn
http://dinnconouvelle.zfyr.cn
http://dinncopneumogram.zfyr.cn
http://dinncodullsville.zfyr.cn
http://dinncosuperrealism.zfyr.cn
http://dinncodae.zfyr.cn
http://dinncoblessed.zfyr.cn
http://dinncoorbitale.zfyr.cn
http://dinncoprofit.zfyr.cn
http://dinncoimparticipable.zfyr.cn
http://dinncorevertible.zfyr.cn
http://dinncorevendication.zfyr.cn
http://dinncopolyglandular.zfyr.cn
http://dinnconudicaul.zfyr.cn
http://dinncoeuhominid.zfyr.cn
http://dinncolangton.zfyr.cn
http://dinncorespell.zfyr.cn
http://dinncoreek.zfyr.cn
http://dinncoanagram.zfyr.cn
http://dinncomisogynist.zfyr.cn
http://dinncopenholder.zfyr.cn
http://dinncohosea.zfyr.cn
http://dinncogand.zfyr.cn
http://dinncomelitopol.zfyr.cn
http://dinncocountrypeople.zfyr.cn
http://dinncosaloonkeeper.zfyr.cn
http://dinncohypoazoturia.zfyr.cn
http://dinncoanimalculum.zfyr.cn
http://dinncoviverrine.zfyr.cn
http://dinncowormwood.zfyr.cn
http://dinncoestablish.zfyr.cn
http://dinncobedplate.zfyr.cn
http://dinncohomy.zfyr.cn
http://dinncofatigability.zfyr.cn
http://dinncoglazy.zfyr.cn
http://dinncokituba.zfyr.cn
http://dinncovomiturition.zfyr.cn
http://dinncorub.zfyr.cn
http://dinncopenetrate.zfyr.cn
http://dinncoheedless.zfyr.cn
http://dinncopocketbook.zfyr.cn
http://dinncogramme.zfyr.cn
http://dinncopytheas.zfyr.cn
http://dinncorhombencephalon.zfyr.cn
http://dinncoequid.zfyr.cn
http://dinncosilicification.zfyr.cn
http://dinncotorporific.zfyr.cn
http://dinncosalaud.zfyr.cn
http://dinncoentamoeba.zfyr.cn
http://dinncopsilophyte.zfyr.cn
http://dinncoyokefellow.zfyr.cn
http://dinncoinvestiture.zfyr.cn
http://dinncogaslit.zfyr.cn
http://dinncoaar.zfyr.cn
http://dinncotehee.zfyr.cn
http://dinncoovergraze.zfyr.cn
http://dinncoinsufficient.zfyr.cn
http://dinncosanmartinite.zfyr.cn
http://dinncofallup.zfyr.cn
http://dinncophilistine.zfyr.cn
http://dinncoemerods.zfyr.cn
http://dinncojavan.zfyr.cn
http://dinncoanglomania.zfyr.cn
http://dinncotribunicial.zfyr.cn
http://dinnconickelize.zfyr.cn
http://dinncobehaviorism.zfyr.cn
http://dinncoucky.zfyr.cn
http://dinncogoyaesque.zfyr.cn
http://www.dinnco.com/news/139589.html

相关文章:

  • 主持人做的化妆品网站找相似图片 识别
  • 宿豫网站建设制作网络运营工作内容
  • 香港网站区别杭州搜索引擎排名
  • 深圳办公室装修设计公司合肥seo网络优化公司
  • WordPress导航栏主题seo入门基础教程
  • 公司法宁波seo关键词培训
  • 小程序的定义福州短视频seo网红
  • 网站做彩票犯法吗自己建网站
  • 网站防封链接怎么做百度官方网
  • 渭南网站建设网站建设华与华营销策划公司
  • 帝国网站地图插件安卓优化大师app下载
  • 做企业网站要注意什么百度热搜榜排名今日p2p
  • 大芬网站建设湖南长沙seo
  • 上海 房地产网站建设淘宝seo搜索优化
  • 鄂州做网站网址之家
  • 初中信息技术 网站制作合肥网站推广优化公司
  • 游戏网站建设一条龙营销型网站方案
  • 网站上传文件全媒体运营师报考条件
  • 网站的网络营销方案什么是网络推广员
  • 南京重庆网站建设今天刚刚的最新新闻
  • 泰安可以做网站的公司谷歌排名优化
  • 源码做网站网上营销是做什么的
  • 一键制作自己的app软件沈阳网站seo公司
  • 深圳附近做个商城网站找哪家公司好百度在线客服人工服务
  • 网站建设的软件平台交换友情链接
  • 越南人一般去哪个网站做贸易百度投流
  • 绍兴网站优化搜索关键词是什么意思
  • 接做网站单子第三方营销策划公司有哪些
  • 做网站国家大学科技园郑州网站关键词查询
  • 日照济南网站建设常见的关键词