Angular是否需要任何特定的nginx配置?我无法显示我的页面;只显示nginx页面。
我为我的React前端容器设置了这个确切的设置,它们显示得很好,所以我不确定我做错了什么。
Dockerfile:
# Stage 1: create build
FROM node:16-alpine AS build
WORKDIR /app
COPY ./member-dashboard/package*.json .
COPY ./member-dashboard .
RUN npm i --legacy-peer-deps
RUN npm run build --prod
# Stage 2: host using nginx
FROM nginx:alpine
ARG PORT
ENV PORT=${PORT}
COPY --from=build /app/nginx/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE ${PORT} 80
ENTRYPOINT ["nginx", "-g", "daemon off;"]
nginx.conf:
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
1条答案
按热度按时间u4vypkhs1#
结果我所需要做的就是重新排序我的第一阶段的构建命令并刷新页面,索引看起来很好。不过,问题很奇怪。