os-js / OS.js

OS.js - JavaScript Web Desktop Platform
https://www.os-js.org/
Other
6.88k stars 819 forks source link

How to handle node_modules in production mode #824

Closed mahsashadi closed 1 year ago

mahsashadi commented 1 year ago

I want to run osjs in production mode, so I use ENV NODE_ENV=production in my Dockerfile. But since in production mode devDependencies are not installed, so my apps can not built (webpack is not available).

Here is my Dockerfile.

FROM node:14.15.0-alpine
WORKDIR /usr/src/osjs
ENV NODE_ENV=production

COPY . .
COPY files/packages ./src/packages

RUN rm -rf files

RUN npm install

RUN cd ./src/packages/osjs-splash \
    && npm install \
    && npm run build

WORKDIR /usr/src/osjs

EXPOSE 8000

CMD ./my-entrypoint.sh

If I only put the dist folder in packages directory, without node_modules, it cause a problem which maybe app server-side needs a module like axios. Is it recommended to add all node_modules needed in server-side of all applications in dependencies of osjs project?

So what is the right way for production mode?

andersevenrud commented 1 year ago
RUN cd ./src/packages/osjs-splash \
    && NODE_ENV=development npm install \
    && npm run build