зеркало из https://github.com/mozilla/fxa.git
feat(event-broker): optimize docker build
Because: * We prefer using slim docker images instead of alpine in production. * Prior docker builds were including Typescript build data instead of just the built Javascript. This commit: * Reduces the compressed size of the Docker build from 139MB to 86 MB. * Uses a separate build step to avoid including the Typescript sources.
This commit is contained in:
Родитель
94de104588
Коммит
e94d0ceec1
|
@ -1,27 +1,16 @@
|
|||
FROM node:10-alpine
|
||||
|
||||
# To handle 'not get uid/gid'
|
||||
RUN npm config set unsafe-perm true
|
||||
|
||||
RUN npm install -g npm@6 && rm -rf ~app/.npm /tmp/*
|
||||
|
||||
RUN apk add --no-cache git make gcc g++
|
||||
|
||||
RUN addgroup -g 10001 app && \
|
||||
adduser -D -G app -h /app -u 10001 app
|
||||
# Build image
|
||||
FROM node:12 as builder
|
||||
WORKDIR /app
|
||||
|
||||
USER app
|
||||
|
||||
COPY package.json package.json
|
||||
COPY package-lock.json package-lock.json
|
||||
|
||||
RUN npm ci && rm -rf ~app/.npm /tmp/*
|
||||
|
||||
COPY . /app
|
||||
RUN npm run build
|
||||
RUN npm ci
|
||||
RUN npm run build
|
||||
RUN npm ci --production
|
||||
|
||||
USER root
|
||||
RUN chown app:app /app/config
|
||||
|
||||
USER app
|
||||
# Production image
|
||||
FROM node:12-slim
|
||||
WORKDIR /app
|
||||
USER node
|
||||
COPY --from=builder --chown=node /app/dist ./dist/
|
||||
COPY --from=builder --chown=node /app/node_modules ./node_modules/
|
||||
COPY --chown=node config/*.json ./config/
|
||||
COPY --chown=node package* ./
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
FROM fxa-event-broker:build
|
||||
|
||||
USER root
|
||||
RUN rm -rf /app/node_modules
|
||||
RUN chown -R app /app
|
||||
|
||||
USER app
|
||||
RUN npm ci
|
||||
WORKDIR /app
|
Загрузка…
Ссылка в новой задаче