Skip to content

bugfix/issue-217-web-push-in-docker-image #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

brunobeeee
Copy link

In Issue #217 I noticed that web-push is not present in the docker image which prevented me from using push notifications. I guess due to shrinking the image size the multi-stage docker build installs all packages in the base stage and then copies only necessary files to the release stage.

See Dockerfile:

COPY --from=base  /app/prisma/schema.prisma ./prisma/schema.prisma
COPY --from=base  /app/prisma/migrations ./prisma/migrations
COPY --from=base  /app/node_modules/prisma ./node_modules/prisma
COPY --from=base  /app/node_modules/@prisma ./node_modules/@prisma
COPY --from=base  /app/node_modules/sharp ./node_modules/sharp

But this results in web-push not being available inside the release stage, so I added these lines that copy web-push and the pnpm dependencies of it.:

COPY --from=base  /app/node_modules/web-push ./node_modules/web-push
COPY --from=base  /app/node_modules/.pnpm/web-push@3.6.7 ./node_modules/.pnpm/web-push@3.6.7

For web-push to be runnable you also have to symlink the binary to node_modules similar to how the prisma binary was linked:

# Symlink the web-push binary
RUN ln -s /app/node_modules/web-push/src/cli.js ./node_modules/.bin/web-push

I would think that it now works but when running npx web-push inside the container, you get an error that the required dependency minimist is not present. So I copied it too:

# Required dependency for web-push
COPY --from=base  /app/node_modules/.pnpm/minimist@1.2.8 ./node_modules/.pnpm/minimist@1.2.8

I also added a short comment to .env.example on how to generate web-push keys when using docker.
I hope you like my solution, thank you for developing splitpro!

@brunobeeee
Copy link
Author

I assumed that web-push was missing inside the image bc I couldn't generate the keypair inside the container. But apparently you're supposed to generate the keypair somwhere else and the container runs w/o web-push binary, so this PR is obsolete.

@brunobeeee brunobeeee closed this May 11, 2025
@brunobeeee brunobeeee deleted the bugfix/issue-217-web-push-in-docker-image branch May 11, 2025 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant