DaoCloud-Dockfile文件&NGINX文件

Dockfile文件

安装依赖,打包,配置NGINX代理,最后把打完的包复制到服务器相应的文件夹下,构建镜像成功。

# syntax = docker/dockerfile:experimental
FROM xx.xx.xx.xx/public/node:16.14.2 as builder

# LABEL maintainer="elementwin"

WORKDIR /app

COPY package.json .
COPY package-lock.json .

RUN npm config set proxy http://xx.xx.xx.xx:端口号 \
RUN npm config set registry http://registry.npm.taobao.org

RUN npm install

COPY . .

ARG BUILD_ENV="production"

RUN npm run build:${BUILD_ENV}

# Build app
FROM xx.xx.xx.xx/public/nginx:1.24.0-tools as app

ENV TZ="Asia/Shanghai"

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" >> /etc/timezone

WORKDIR /app
RUN mkdir -p /app/dist

ADD prod-nginx.conf /etc/nginx/conf.d/app.conf

COPY --from=builder /app/dist /app/dist

VOLUME ["/opt", "/app"]

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]

NGINX文件

# admin.cloud.elementwin.com
server {
      client_max_body_size 200m;
      client_body_buffer_size 128k;
      listen      80 default_server;
      server_name _;
      gzip on;
      gzip_buffers 4 16k;
      gzip_comp_level 6;
      gzip_vary on;
      gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

      location / {
          client_max_body_size 200m;
          client_body_buffer_size 128k;
          proxy_send_timeout 300;
          proxy_read_timeout 300;
          proxy_connect_timeout 600;
          proxy_buffering on;
          proxy_buffer_size 1M;
          proxy_buffers 8 1M;
          proxy_busy_buffers_size 1M;
          proxy_temp_file_write_size 1M;
          root /app/dist;
          index index.html index.htm;
          try_files $uri $uri/ /index.html;
      }
      location /api/ {
        proxy_pass  http://xx.xx.xx.xxx:端口号/;
      }
  }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值