Reduce Docker image size again.

This commit is contained in:
Koen Kanters
2022-04-02 21:50:12 +02:00
parent 51f8c1c487
commit 8fd8df75be
+15 -5
View File
@@ -3,15 +3,25 @@ FROM node:16-alpine3.15 as base
WORKDIR /app
RUN apk add --no-cache tzdata eudev tini
COPY package.json package-lock.json tsconfig.json index.js LICENSE index.js data/configuration.yaml ./
COPY lib ./lib
COPY dist ./dist
COPY package.json ./
# Dependencies and build
FROM base as dependencies_and_build
COPY package-lock.json tsconfig.json index.js ./
COPY lib ./lib
# Install dependencies
RUN apk add --no-cache --virtual .buildtools make gcc g++ python3 linux-headers git && \
npm ci --production --no-audit --no-optional --no-update-notifier && \
apk del .buildtools
# Release
FROM base as release
COPY --from=dependencies_and_build /app/node_modules ./node_modules
COPY dist ./dist
COPY LICENSE index.js data/configuration.yaml ./
COPY docker/docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
@@ -21,4 +31,4 @@ ARG COMMIT
RUN echo "$COMMIT" > dist/.hash
ENTRYPOINT ["docker-entrypoint.sh"]
CMD [ "/sbin/tini", "--", "node", "index.js"]
CMD [ "/sbin/tini", "--", "node", "index.js"]