@novu/shared tweaks

Guys, I noticed a problem with the getContextPath function in the @novu/shared library. Back in version 0.12 I just tweaked that file with the required changes and completed a docker build and everything worked. Happy days. However, I have jumped to Novu version 0.16 and the same fix no longer works. In fact it appears that the tweaks version is no getting included in the build at all! Before, with version 0.12, my tweaked code was getting included in the resulting build/static/js/main.xxx.js file (and map file). However now, the code that is included is the same code from the original Novu repo (not my tweaks code) which is no longer present in my local repo / env when I am building the docker image! One other item to note, is that I do not change the version number of the @novu/shared library in my local repo, I keep everything the same as before Is the @novu/shared library that is getting included in my docker build getting pulled from the internet and not getting build locally?
9 Replies
Pawan Jain
Pawan Jain2y ago
@dmulligan Are you using this documentation for deployment? https://docs.novu.co/overview/docker-deploy
dmulligan
dmulliganOP2y ago
I have read that document, and it is light on information regarding the issues at hand. We have our own customer GitHub Actions for building each of the different container images, and they are heavily based on Novu's own dev-deploy-* / prod-deploy-* GitHub actions. For instance, the building of the WEB image uses the following command which is based on https://github.com/novuhq/novu/blob/next/.github/workflows/prod-deploy-web.yml#L205-L219 with the exception that we are using docker buildx directly on not depot
- name: Build, tag, and push image to ECR
id: build-image
env:
REGISTRY: ${{ steps.aws-ecr-login.outputs.registry }}
REPOSITORY: novu
IMAGE_TAG: ${{ github.sha }}-web
DOCKER_BUILDKIT: 1
run: |
docker build \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from=$REGISTRY/$REPOSITORY:$IMAGE_TAG \
--tag $REGISTRY/$REPOSITORY:$IMAGE_TAG \
--label "build-date=$(date --iso-8601=second --utc)" \
--label "build-url=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
--label "git-commit-sha=${{ github.sha }}" \
--label "git-source-repo=${{ github.repository }}" \
--label "service-version=$IMAGE_TAG" \
-f apps/web/Dockerfile .
- name: Build, tag, and push image to ECR
id: build-image
env:
REGISTRY: ${{ steps.aws-ecr-login.outputs.registry }}
REPOSITORY: novu
IMAGE_TAG: ${{ github.sha }}-web
DOCKER_BUILDKIT: 1
run: |
docker build \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from=$REGISTRY/$REPOSITORY:$IMAGE_TAG \
--tag $REGISTRY/$REPOSITORY:$IMAGE_TAG \
--label "build-date=$(date --iso-8601=second --utc)" \
--label "build-url=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
--label "git-commit-sha=${{ github.sha }}" \
--label "git-source-repo=${{ github.repository }}" \
--label "service-version=$IMAGE_TAG" \
-f apps/web/Dockerfile .
The building of the docker container triggers the building of the Novu web application via apps/web/Dockerfile My guess is that something within the build system is not rebuilding the local version of @novu/shared and instead fetching the already built instance from a shared cached on the internet. However, I do not have much knowledge on NX Cloud which is called via "build:web": "nx build @novu/web"
Pawan Jain
Pawan Jain2y ago
@dimagrossman Can you please here?
Dima Grossman
Dima Grossman2y ago
@dmulligan can you please share the package.json contents of your web project?
dmulligan
dmulliganOP2y ago
Thanks for your message @dimagrossman the web package.json file is an exact match to https://github.com/novuhq/novu/blob/v0.16.1/apps/web/package.json
GitHub
novu/apps/web/package.json at v0.16.1 · novuhq/novu
The open-source notification infrastructure with fully functional embedded notification center - novuhq/novu
Dima Grossman
Dima Grossman2y ago
And in the @Novu/shared package, what version is specified there? it should be the exact same version as specified in the package json files of the other used packages, otherwise it will fetch from npm
dmulligan
dmulliganOP2y ago
GitHub
novu/libs/shared/package.json at v0.16.1 · novuhq/novu
The open-source notification infrastructure with fully functional embedded notification center - novuhq/novu
Dima Grossman
Dima Grossman2y ago
Can you try updating the @Novu/shared version to be exact match without the "^" to be 0.16.1? It might be fetching the latest 0.16.4 from npm
dmulligan
dmulliganOP2y ago
I added the following to apps/web/Dockerfile
COPY --from=builder /usr/src/app /builder/app
COPY --from=builder /usr/src/app /builder/app
And within the created web container, I ran the following commands. You can see that @novu/shared is getting built correctly, but a different copy of Novu shared is included within the web's copy of node_modules
/app # cd /builder/

/builder # head -3 app/apps/web/package.json
{
"name": "@novu/web",
"version": "0.16.1",

/builder # grep shared app/apps/web/package.json
"@novu/shared": "^0.16.1",

/builder # head -3 app/libs/shared/package.json
{
"name": "@novu/shared",
"version": "0.16.1",

/builder # ls -l app/apps/web/node_modules/@novu/
total 8
lrwxrwxrwx 1 root root 20 Mar 23 10:29 dal -> ../../../../libs/dal
lrwxrwxrwx 1 root root 129 Jul 17 17:01 notification-center -> ../../../../node_modules/.pnpm/@[email protected]_sype5lc4hh4jvxdmzxcsfqy6ba/node_modules/@novu/notification-center
lrwxrwxrwx 1 root root 76 Jul 17 17:01 shared -> ../../../../node_modules/.pnpm/@[email protected]/node_modules/@novu/shared
lrwxrwxrwx 1 root root 24 Mar 23 10:29 testing -> ../../../../libs/testing

/builder # head -3 app/apps/web/node_modules/@novu/shared/package.json
{
"name": "@novu/shared",
"version": "0.16.3",
/app # cd /builder/

/builder # head -3 app/apps/web/package.json
{
"name": "@novu/web",
"version": "0.16.1",

/builder # grep shared app/apps/web/package.json
"@novu/shared": "^0.16.1",

/builder # head -3 app/libs/shared/package.json
{
"name": "@novu/shared",
"version": "0.16.1",

/builder # ls -l app/apps/web/node_modules/@novu/
total 8
lrwxrwxrwx 1 root root 20 Mar 23 10:29 dal -> ../../../../libs/dal
lrwxrwxrwx 1 root root 129 Jul 17 17:01 notification-center -> ../../../../node_modules/.pnpm/@[email protected]_sype5lc4hh4jvxdmzxcsfqy6ba/node_modules/@novu/notification-center
lrwxrwxrwx 1 root root 76 Jul 17 17:01 shared -> ../../../../node_modules/.pnpm/@[email protected]/node_modules/@novu/shared
lrwxrwxrwx 1 root root 24 Mar 23 10:29 testing -> ../../../../libs/testing

/builder # head -3 app/apps/web/node_modules/@novu/shared/package.json
{
"name": "@novu/shared",
"version": "0.16.3",
I will try as you suggested next That worked, once the version is locked, it will use the local version of @novu/shared. A huge thank you for that information. FYI, I have shared the fix back as a PR https://github.com/novuhq/novu/pull/3814
Want results from more Discord servers?
Add your server