我在Docker中使用多级构建,我可以在本地完美地创建它。我正在使用Jenkins在我的CI过程中构建图像。我所有的单一阶段构建都有效,所以它必须与多阶段有关。当Jenkins开始构建图像时,我得到以下内容:
Step 1/11 : FROM node:8.1.4-alpine as builder
Error parsing reference: "node:8.1.4-alpine as builder" is not a valid repository/tag: invalid reference format
这是我的Dockerfile
### STAGE 1: Build ###
# We label our stage as ‘builder’
FROM node:8.1.4-alpine as builder
COPY package.json ./
## Storing node modules on a separate layer will prevent unnecessary npm installs at each build
RUN npm i && mkdir /ng-app && cp -R ./node_modules ./ng-app
WORKDIR /ng-app
COPY . .
## Build the angular app in production mode and store the artifacts in dist folder
RUN $(npm bin)/ng build --prod
### STAGE 2: Setup ###
FROM nginx:1.13.3-alpine
## 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 /ng-app/dist /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]
我正在使用以下jenkins版本:`jenkins / jenkins:2.95``
有人可能会向我暗示正确的方向。谢谢。
答案 0 :(得分:-1)
不是问题的100%解决方案,但我停止使用多阶段构建。基本上只是使用阶段2并预先手动构建生产版本。
### STAGE 2: Setup ###
FROM nginx:1.13.3-alpine
## 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 /ng-app/dist /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]