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