diff --git a/tools/southbound/docker-compose.yaml b/tools/southbound/docker-compose.yaml index d5d23a58e2ef24aa213c8be3ca686f00ca922ecd..a5159f564efe30e06eb0ddf9a27d0cdeb4000abc 100644 --- a/tools/southbound/docker-compose.yaml +++ b/tools/southbound/docker-compose.yaml @@ -7,7 +7,7 @@ services: # 服务名称 container_name: southbound-nginx # 指定上下文目录以及docker配置文件的相对路径 - build: ./southbound-view + build: ./southbound-view/DockerAppFile # 自动重启,如果服务启动不成功会一直尝试。 restart: always # 对外开放的端口。这里主机的端口映射到nginx容器端口,和expose的区别是,expose不会将端口暴露给主机。 diff --git a/tools/southbound/southbound-view/DockerAppFile b/tools/southbound/southbound-view/DockerAppFile new file mode 100644 index 0000000000000000000000000000000000000000..0e2901746be5dbdb179282abca0aed7607e3beaf --- /dev/null +++ b/tools/southbound/southbound-view/DockerAppFile @@ -0,0 +1,20 @@ +FROM node:14.17.3-alpine as Builder +RUN mkdir -p /app +WORKDIR /app +COPY . /app +RUN npm install -g cnpm -registry=https://registry.npm.taobao.org + +RUN cnpm install -g vue && \ + cnpm install && \ + cnpm run build + +FROM nginx:1.20.0 +RUN mkdir -p /app +WORKDIR /app +COPY --from=Builder /app/dist /app +RUN chmod -R 755 /app +COPY --from=Builder /app/nginx.conf /etc/nginx/conf.d/ +ENV RUN_USER nginx +ENV RUN_GROUP nginx +EXPOSE 80 +ENTRYPOINT ["nginx", "-g", "daemon off;"] diff --git a/tools/southbound/southbound-view/Dockerfile b/tools/southbound/southbound-view/Dockerfile index 0e2901746be5dbdb179282abca0aed7607e3beaf..f76e55c9b32e86851f1f7a37ae287993c50adc77 100644 --- a/tools/southbound/southbound-view/Dockerfile +++ b/tools/southbound/southbound-view/Dockerfile @@ -13,8 +13,9 @@ RUN mkdir -p /app WORKDIR /app COPY --from=Builder /app/dist /app RUN chmod -R 755 /app -COPY --from=Builder /app/nginx.conf /etc/nginx/conf.d/ -ENV RUN_USER nginx -ENV RUN_GROUP nginx +# 这里nginx配置复制过去 +ADD nginx.template /etc/nginx/conf.d EXPOSE 80 -ENTRYPOINT ["nginx", "-g", "daemon off;"] +EXPOSE 443 +WORKDIR /etc/nginx/conf.d +ENTRYPOINT envsubst '$URL' < nginx.template > default.conf && cat default.conf && nginx -g 'daemon off;' \ No newline at end of file diff --git a/tools/southbound/southbound-view/nginx.template b/tools/southbound/southbound-view/nginx.template new file mode 100644 index 0000000000000000000000000000000000000000..1298dea1c40e6f28d438deac0a2cbf36dde5d24a --- /dev/null +++ b/tools/southbound/southbound-view/nginx.template @@ -0,0 +1,23 @@ +server { + # nginx监听端口 + listen 80; + server_name localhost; + charset utf-8; + location / { + # 将nginx运行目录指定到容器/app目录下 + root /app; + index index.html index.htm; + } + # 代理后台服务 + location /southbound/ { + proxy_pass $URL; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-real-ip $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + error_page 404 /404.html; + location = /40x.html { + } + error_page 500 502 503 504 /50x.html; +} \ No newline at end of file