I have a Node.js application that consists of different microservices. Each microservice is a Node.js or NestJS app with .js
and .ts
files. Every such app has its own Dockerfile in the app's folder. These files usually contain similar lines for the build step:
dockerfile
WORKDIR /app
RUN npm run build && npm prune --production --force && rm -rf src
For example, this code belongs to the 'gateway-server' service. If I launch a terminal shell inside the running container, I can see compiled files (only .js and .js.map files) inside the 'app' folder. This is the case for other services as well.
However, our app has a microservice labeled 'sps'. The Dockerfile for the 'sps' app does not contain any 'build' instructions. When I run a shell inside its container, the 'app' folder consists of the original source files - .ts
and .js
files (raw source code).
I have a few questions:
How is it possible that the Node.js app container does not contain compiled files? I tried searching for them using catalog search and the find
command but found nothing.
Could the compiled files be located in some external volume, or were they built in RAM? If so, how can I find their location - can Docker inspect <containerID>
help me?
Why might someone use such a setup without compiled files?
If there is something like ts-node, you won't see any compiled files 'cause it compiles + runs them on the fly without emitting to disk. Check out the package.json to see how the app is started.