Setting up dev environment
-
Startup app with baasil create
works fine. I can push it to my local docker and runs perfectly. -
Now I have setup the dev environment with typescript and jest
-
I am replacing express with KoaJS
The problem I am facing is; If I compile with tsc and put the files to \dist folder and then push to docker with baasil run .\dist, it pushes the stuff. But when I do a docker logs -f myappname, I see lot of restarts happening with worker.js because it fails to find module koa.
Is this because I now need to compose a docker image with relevant packages included?
Then, If I compile without copying to \dist\ folder and just do baasil run; it gets pushed to docker and docker logs -f myappname does not complain about missing module (koa). Instead it complains about another folder /api that I have my swagger api definitions(This is thrown by koa-router). Additionally it shows below details with the error:
[Busy] Launching SocketCluster !! The sc-hot-reboot plugin is watching for code changes in the /usr/src/app directory
Broker PID: 46 WorkerCluster PID: 52 Worker PID: 58 router boot error: { Error: ENOENT: no such file or directory, stat './api' at fs.statSync (fs.js:948:11) at /usr/src/app/node_modules/koa-oai-router/lib/spec.js:14:33
In here koa-oai-router fails to find ./api directory. It seems to me that if I add more tools to the dev environment and customize I will have to compose a docker image with all dependencies include additional directories etc.... ?
I think I got a bit far with this. According to https://nodejs.org/en/docs/guides/nodejs-docker-webapp/ I need to customize dockerfile to rebuild a new image. So now what I tried was edited dockerfile and included;
COPY package*.json /usr/src/ RUN npm install .
also included below to dockerignore file node_modules npm-debug.log
Then I ran baasil run .\dist\ In which case I assumed it'll copy all compiled files from .\dist\ to image, then copy the package.json and finally run npm install.
After doing this I checked the container logs it still says it can't find the module. Then I did a docker export and looked at the container file system. It does not have the latest npm packages included. So that's why it's not working. So i concluded that baasil run .\dist\ will not recreate a new image but it will just run what is in the docker cache?
How can I force baasil to re-create the docker image and publish?