I'm currently in the process of dockerizing our microfrontend application, which consists of both React and Angular frameworks using a shared library for communication that we developed ourselves and installed locally via npm.
'- angular-project
'- react-projects
'- shared-libs
'- communication-lib
For local development, we install the communication-lib module with:
npm install ..\shared-libs\communication-lib
Everything runs smoothly locally, but when transitioning to Docker, I encountered several issues for which I am unable to find a suitable solution. Here are the initial lines from the Dockerfile of the Angular project:
FROM node:16-alpine As development
WORKDIR /usr/src/app/frontend
COPY ./angular/package.json ./angular/package-lock.json ./
RUN npm i
...
# trouble starts here
The Docker build fails at this point because the lib is not recognized by the image. I tried sharing the code of the shared lib with the image through a volume, but then faced the issue of missing pre-built node modules.
I would greatly appreciate any helpful tips on resolving this dilemma.
My thoughts:
Is there a way to create separate Docker containers for the libs and use them within my Angular projects container?
Could I possibly copy/build and link the lib inside the container?