DEV Community

Discussion on: How to Dockerize your NestJS App for production

Collapse
 
seand52 profile image
seand52

Nice post!

Just a small comment - I'm fairly certain that it's not necessary to do it in two steps by using first the full node image and then node-alpine. I got it working with just 1 step using node-alpine for everything:

FROM node:10-alpine
WORKDIR /app
COPY ${PWD}/package.json ./
RUN yarn
COPY . .
RUN yarn build
EXPOSE 5000
CMD ["sh", "-c", "yarn typeorm migration:run && yarn start:prod"]

Collapse
 
abbasogaji profile image
Abbas Ogaji • Edited

Very true, although they might be scenarios where your dependencies rely on native builds, and that might require you to install build tools like node-gpy (which is written in python [meaning also need to install python] ), make, gcc, g++ which might not exists on alpine version,

Although you can still get away with it by installing build tools via apk in Dockerfile