make docker images smaller by 150%

This commit is contained in:
anarch3 2022-11-24 03:35:27 -05:00
parent de9379603b
commit b04e0f4f42
2 changed files with 22 additions and 18 deletions

View file

@ -1,10 +1,22 @@
FROM node:16
FROM node:16-alpine AS BUILD_IMAGE
RUN apk add curl bash
# Install dependencies
COPY package*.json ./
RUN npm install
# Package app source
RUN npm prune --production
RUN curl -sf https://gobinaries.com/tj/node-prune | sh
FROM node:16-alpine
COPY --from=BUILD_IMAGE /node_modules ./node_modules
COPY . .
ENTRYPOINT ["./docker-entrypoint.sh"]
ENV NODE_ENV=production
RUN node db.js
CMD ["npm", "start"]

View file

@ -1,12 +1,4 @@
#!/bin/bash
# Exit build script on first failure.
set -e
# Exit on unset variable.
set -u
set -x
node db.js
npm start