【发布时间】:2019-09-16 17:51:29
【问题描述】:
我在运行来自npm run 的ng build 命令时遇到问题。我有以下几种情况:
当我在本地环境中构建项目时,我运行
ng build --configuration=development,一切正常。另一方面,当我构建我的 Docker 映像时,我使用
npm rum ng build --configuration=$VAR运行命令,但没有传递参数,结果也不是预期的。
虽然我觉得没必要,但是我的Dockerfile在下面
# STAGE 1: Build
##############################################################################
# Image
FROM node:10-alpine as builder
MAINTAINER joseantonio@gogroup.es
# BUILD ARGS
ARG ENVIROMENT
# Installing GIT & Bash
RUN apk add --no-cache git
## Storing node modules on a separate layer will prevent unnecessary npm installs at each build
COPY package.json package-lock.json ./
RUN npm ci
RUN mkdir /pancho-ui
RUN mv ./node_modules ./pancho-ui
WORKDIR /pancho-ui
COPY . .
## Build the angular app in production mode and store the artifacts in dist folder
RUN npm run ng build --output-path=dist --configuration=$ENVIROMENT --verbose
# STAGE 2: Setup
##############################################################################
# Image
FROM nginx:1.14.1-alpine
MAINTAINER joseantonio@gogroup.es
## Copy our default nginx config
COPY nginx/default.conf /etc/nginx/conf.d/
## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
## From ‘builder’ stage copy over the artifacts in dist folder to default nginx public folder
COPY --from=builder /pancho-ui/dist /usr/share/nginx/html
RUN mv /usr/share/nginx/html/pancho-ui/* /usr/share/nginx/html/
# Run nginx
CMD ["nginx", "-g", "daemon off;"]
【问题讨论】:
标签: angular docker npm dockerfile angular-cli