SRE团队优化后的dockerfile
dockerfile1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| FROM artifactory.momenta.works/docker/node:lts-alpine as builder
ENV EVA_ENTRYPOINT=/api
WORKDIR /
ADD package.json /
RUN npm install --registry=https://registry.npm.taobao.org
ADD . /
RUN npm run build
FROM nginx:alpine
LABEL maintainer="An <aa@163.ai>"
COPY /nginx/ /etc/nginx/
COPY --from=builder /dist/ /usr/share/nginx/html/
EXPOSE 80
|
是否可以继续优化目前的镜像,因为打出的包还是300+M。因此需要继续深研。
dockerfile2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| FROM artifactory.momenta.works/docker/node:lts-alpine AS build
WORKDIR /
COPY package.json ./
RUN yarn config set registry https://artifactory.momenta.works/artifactory/api/npm/npm/ \
&& yarn install
COPY . /
RUN yarn build
LABEL maintainer=" An <aa@163.ai>"
LABEL app=tropoBackend
ENTRYPOINT ["node", "/build/app.js"]
EXPOSE 8000
|
本docker继续优化的点在哪?有计划了再更新文章
dockerfile1为前端服务
dockerfile2为后端服务
Happy Hacking~