Skip to content
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

Docker multi-stage builds vs vite-plugin-server-entry #1877

Closed
roschaefer opened this issue Sep 12, 2024 · 1 comment
Closed

Docker multi-stage builds vs vite-plugin-server-entry #1877

roschaefer opened this issue Sep 12, 2024 · 1 comment
Labels

Comments

@roschaefer
Copy link

Description

We were blocked to update vike from version 0.4.176 onwards because if we run our app from within a Docker image, it would display "An error occurred."

The logs in the docker container would show:

presenter-1  | Error: [@brillout/[email protected]][Wrong Usage] Cannot find server entry. (Re-)build your app and try again. If you still get this error, then you may need to manually import the server entry, see https://github.com/brillout/vite-plugin-server-entry#manual-import
presenter-1  |     at importServerEntry (/app/node_modules/@brillout/vite-plugin-server-entry/dist/runtime/importServerEntry.js:39:29)
presenter-1  |     at async loadImportBuild (/app/node_modules/vike/dist/cjs/node/runtime/globalContext/loadImportBuild.js:15:9)

We figured out that we have to manually copy a file from node_modules in a multi-stage docker build:

COPY --from=build ${DOCKER_WORKDIR}/node_modules/@brillout/vite-plugin-server-entry/dist/runtime/autoImporter.js ./node_modules/@brillout/vite-plugin-server-entry/dist/runtime/autoImporter.js

Here's our PR changing the relevant Dockerfile: dreammall-earth/dreammall.earth#2018

What is the suggested workflow with vike running inside a docker image?

@brillout
Copy link
Member

Indeed, that should work. You can also manually import dist/server/entry.js. I've improved the section https://github.com/brillout/vite-plugin-server-entry#manual-import — let me know if you still have questions.

Btw. in case your company is up for it, we're looking for sponsors (#1350).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants