File tree Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ .dockerignore
2
+ dist
3
+ node_modules
Original file line number Diff line number Diff line change
1
+ FROM node:16-alpine as DIST
2
+
3
+ WORKDIR /admim
4
+
5
+ COPY ./package.json .
6
+ COPY ./yarn.lock .
7
+ COPY ./.npmrc .
8
+ RUN yarn install
9
+
10
+ COPY . .
11
+ ARG NODE_ENV=""
12
+ RUN env ${NODE_ENV} yarn build:prod
13
+
14
+ # # -- stage: dist => nginx --
15
+ FROM nginx:alpine
16
+
17
+ ENV TZ=Asia/Shanghai
18
+
19
+ COPY ./nginx.conf /etc/nginx/conf.d/default.conf
20
+ COPY --from=DIST /admim/dist /usr/share/nginx/html
21
+
22
+ EXPOSE 80
Original file line number Diff line number Diff line change
1
+ server {
2
+ listen 80 default_server ;
3
+ server_name _; ## 重要!!!修改成你的外网 IP/域名
4
+
5
+ gzip on ;
6
+ gzip_min_length 1k ; # 设置允许压缩的页面最小字节数
7
+ gzip_buffers 4 16k ; # 用来存储 gzip 的压缩结果
8
+ gzip_http_version 1.1 ; # 识别 HTTP 协议版本
9
+ gzip_comp_level 2 ; # 设置 gzip 的压缩比 1-9。1 压缩比最小但最快,而 9 相反
10
+ gzip_types text/plain application/x-javascript text/css application/xml application/javascript; # 指定压缩类型
11
+ gzip_proxied any; # 无论后端服务器的 headers 头返回什么信息,都无条件启用压缩
12
+
13
+ location / { ## 前端项目
14
+ root /usr/share/nginx/html/;
15
+ index index.html index.htm;
16
+ try_files $uri $uri / /index.html;
17
+ }
18
+
19
+ location /prod-api/ { ## 后端项目 - 管理后台
20
+ proxy_pass http://yudao-server:48080/; ## 重要!!!proxy_pass 需要设置为后端项目所在服务器的 IP
21
+ proxy_set_header Host $http_host ;
22
+ proxy_set_header X-Real-IP $remote_addr ;
23
+ proxy_set_header REMOTE-HOST $remote_addr ;
24
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments