From 5421b8182887bed9d8ef6d4cf72e0ffcef2a1e8f Mon Sep 17 00:00:00 2001 From: carry <2641257231@qq.com> Date: Thu, 20 Feb 2025 02:51:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E5=89=8D=E5=90=8E=E7=AB=AF=E5=88=86?= =?UTF-8?q?=E7=A6=BB=E7=9A=84=E4=BB=A3=E7=90=86=E7=8B=AC=E7=AB=8B=E5=87=BA?= =?UTF-8?q?=E6=9D=A5=EF=BC=8C=E5=B9=B6=E8=A7=A3=E5=86=B3=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E7=B3=BB=E5=88=97nginx=E4=BB=A3=E7=90=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 4 +--- frontend/Dockerfile | 2 +- nginx/Dockerfile | 11 +++++++++++ nginx.conf => nginx/nginx.conf | 0 4 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 nginx/Dockerfile rename nginx.conf => nginx/nginx.conf (100%) diff --git a/docker-compose.yml b/docker-compose.yml index c9df627..c7f68e2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -25,11 +25,9 @@ services: - app-network nginx: - image: nginx:stable-alpine + build: ./nginx ports: - "80:80" - volumes: - - ./nginx.conf:/etc/nginx/nginx.conf depends_on: - frontend - backend diff --git a/frontend/Dockerfile b/frontend/Dockerfile index d5d255b..6107578 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -24,7 +24,7 @@ FROM nginx:stable-alpine as production-stage COPY --from=build-stage /app/dist /usr/share/nginx/html # 复制Nginx配置文件 -COPY nginx.conf /etc/nginx/conf.d/default.conf +COPY nginx.conf /etc/nginx/nginx.conf # 暴露80端口 EXPOSE 80 diff --git a/nginx/Dockerfile b/nginx/Dockerfile new file mode 100644 index 0000000..84ab4ab --- /dev/null +++ b/nginx/Dockerfile @@ -0,0 +1,11 @@ +# 使用Nginx作为基础镜像 +FROM nginx:stable-alpine + +# 复制Nginx配置文件 +COPY nginx.conf /etc/nginx/nginx.conf + +# 暴露80端口 +EXPOSE 80 + +# 启动Nginx +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/nginx.conf b/nginx/nginx.conf similarity index 100% rename from nginx.conf rename to nginx/nginx.conf