Optimize docker NodeJS deployments

@patrick I optimized the Dockerfile for NodeJS deployments, check the end of this post

Until Wappler releases an update to fix this, yes

Here’s your optimized Dockerfile: (edit: fixed the issue on the following post)

FROM node:16-bullseye-slim

ARG NODE_ENV=production
ENV NODE_ENV $NODE_ENV

ARG PORT=3000
ENV PORT $PORT
EXPOSE $PORT

RUN mkdir /opt/node_app
ENV PATH /opt/node_app/node_modules/.bin:$PATH

WORKDIR /opt/node_app

COPY package.json ./
RUN npm install --no-optional --production --no-package-lock

COPY . .
CMD [ "nodemon", "./index.js" ]

After saving the file, switch the target to your local environment (if not already), and then switch it back to Live, only then you can attempt to deploy. The first deployment will still take an eternity, but subsequent deploys will skip the slow npm install step, and therefore deploy within a few seconds

Community Page
Last updated: