【发布时间】:2021-11-05 22:10:50
【问题描述】:
我正在尝试使用 base-href 对我的 Angular 项目进行 dockerize,但是在它构建并复制到 Nginx 之后它无法正常工作。有人能给我一些关于我能做什么的提示吗?我可以设置 nginx.conf 的基本路径吗?
# base image
FROM node:14.15.4 as build
WORKDIR /app
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
# install and cache app dependencies
COPY package.json /app/package.json
RUN npm install
RUN npm install -g @angular/cli@10.0.4
# add app
COPY . .
# generate build
RUN ng build --build-optimizer --aot --base-href=/dev/
# base image
FROM nginx:1.18.0-alpine
# overwrite default nginx website
RUN rm -rf /usr/share/nginx/html/*
# copy artifact build from the 'build environment'
COPY --from=build /app/dist /usr/share/nginx/html
# expose port 80
EXPOSE 80
# run nginx
CMD ["nginx", "-g", "daemon off;"]
【问题讨论】:
标签: node.js angular docker nginx