feat: nginx配置

This commit is contained in:
sudoooooo 2024-05-20 18:37:12 +08:00
parent 95917e22f0
commit 3629796786
3 changed files with 7 additions and 8 deletions

View File

@ -14,18 +14,15 @@ RUN apt-get update && \
RUN npm config set registry https://registry.npmjs.org/ RUN npm config set registry https://registry.npmjs.org/
# 安装项目依赖 # 安装项目依赖
RUN cd /xiaoju-survey/web && npm install && npm run build-only RUN cd /xiaoju-survey/web && npm install && npm run build
# 用了后端服务代理启动建议使用nginx启动
#RUN cd /xiaoju-survey && cp -af ./web/dist/* ./server/public/
# 覆盖nginx配置文件 # 覆盖nginx配置文件
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
RUN cd /xiaoju-survey/server && npm install && npm run build RUN cd /xiaoju-survey/server && npm install && npm run build
# 暴露端口 需要跟nginx的port一致 # 暴露端口 需要跟nginx的port一致
# EXPOSE 3000 EXPOSE 80
EXPOSE 8080
# docker入口文件,启动nginx和运行pm2启动,并保证监听不断 # docker入口文件,启动nginx和运行pm2启动,并保证监听不断
CMD ["sh","docker-run.sh"] CMD ["sh","docker-run.sh"]

View File

@ -1,7 +1,9 @@
#! /bin/bash #! /bin/bash
# 启动nginx # 启动nginx
echo 'nginx start'
nginx -g 'daemon on;' nginx -g 'daemon on;'
# 启动后端服务 # 启动后端服务
cd /xiaoju-survey/server cd /xiaoju-survey/server
npm run start:prod npm run start:prod

View File

@ -18,9 +18,9 @@ http {
sendfile on; sendfile on;
keepalive_timeout 65; keepalive_timeout 65;
server { server {
listen 8080; listen 80;
# IPv6端口 # IPv6端口
listen [::]:8080; listen [::]:80;
server_name localhost; server_name localhost;
# gzip config # gzip config
gzip on; gzip on;