How do you run the docker for production build?
Closed this issue · 3 comments
Tasin5541 commented
It's always running in dev mode even if I make Dev: false in docker-compose file
przemek-nowicki commented
Good question @Tasin5541, you can do it by the following commands:
- For the sake of readability, build an image with custom name i.e. net.ts, so go to the root project (where the Dockerfile is) and run:
docker build -t net.ts .
- Execute the
docker run
command with all the required environment variables to create container based on net.ts image:
docker run --rm -it -e NODE_ENV='production' -e API_KEY_TOKEN='your-api-token' net.ts
You should see the following result, if so you just ran the app in production mode.
> net.ts@1.0.0 server:prod
> node dist/server.js
2022-06-27 15:03:00 info: Logger level is set to info
2022-06-27 15:03:00 info: Aapplication listens on PORT: 8080
btw. I will update README file about this part as it may be not clear for other folks.
Tasin5541 commented
Do we need to copy everything for the production build (the ts files)? Copying only the build folder and package*.json should suffice, right? This'll keep the image size low too
przemek-nowicki commented
That's a good point, I will create a new thread for this to not mix up these two topics.