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

[V3] Error 500 when refreshing parsed content page in production using Docker #3027

Open
weimin96 opened this issue Jan 24, 2025 · 1 comment
Labels
question Further information is requested v3

Comments

@weimin96
Copy link

Environment

  • Operating System: Windows_NT
  • Node Version: v20.16.0
  • Nuxt Version: 3.15.2
  • CLI Version: 3.20.0
  • Nitro Version: 2.10.4
  • Package Manager: pnpm@9.14.2
  • Builder: -
  • User Config: compatibilityDate, devtools, modules, vite, typescript
  • Runtime Modules: @nuxt/content@3.0.0
  • Build Modules:

Reproduction

minimal reproduction

Describe the bug

I'm encountering an issue when deploying a Nuxt Content project in a production environment using Docker. Refreshing a page that displays parsed content (not navigating via routes) results in a 500 error. The error message is as follows:

[POST] "/api/content/docs/query?v=TognxvETDU": 500

After checking the server logs, I found this error:

Failed to execute SQL DROP TABLE IF EXISTS _content_docs;: Error loading shared library /home/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node: Exec format error...

Upon further investigation, I entered the Docker container and noticed that the contents.sqlite file is not generated in the server directory.

Strangely, navigating to the content page via route transitions works fine. The issue only occurs when refreshing a parsed content page directly.


error

Finally, this is my Dockerfile file

FROM node:20-alpine3.20

RUN mkdir -p /home
WORKDIR /home

ENV HOST 0.0.0.0

COPY ./.output /home

EXPOSE 3000/tcp

CMD ["node", "server/index.mjs"]

Could you please provide guidance on resolving this issue? Let me know if additional information is needed.

Thank you!

Additional context

No response

Logs

Listening on http://0.0.0.0:3000
Failed to execute SQL DROP TABLE IF EXISTS _content_docs;: Error loading shared library /home/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node: Exec format error
Failed to execute SQL CREATE TABLE IF NOT EXISTS _content_docs (id TEXT PRIMARY KEY, "title" VARCHAR, "body" TEXT, "date" VARCHAR, "description" VARCHAR, "extension" VARCHAR, "image" VARCHAR, "meta" TEXT, "navigation" TEXT DEFAULT true, "path" VARCHAR, "seo" TEXT DEFAULT '{}', "stem" VARCHAR, "tags" TEXT, "updated" VARCHAR);: Error loading shared library /home/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node: Exec format error
Failed to execute SQL INSERT INTO _content_docs VALUES ('docs/docs/1.index.md', 'demo1', '{"type":"minimal","value":[["h2",{"id":"title"},"title"],["p",{},"demo1"]],"toc":{"title":"","searchDepth":2,"depth":2,"links":[{"id":"title","depth":2,"text":"title"}]}}', '2025-01-14 16:00:00', '', 'md', NULL, '{}', 'true', '/docs', '{"title":"demo1","description":""}', 'docs/1.index', '["Spring","AI"]', NULL);: Error loading shared library /home/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node: Exec format error
Failed to execute SQL INSERT INTO _content_docs VALUES ('docs/docs/2.index2.md', 'demo2', '{"type":"minimal","value":[["h2",{"id":"title"},"title"],["p",{},"demo2"]],"toc":{"title":"","searchDepth":2,"depth":2,"links":[{"id":"title","depth":2,"text":"title"}]}}', '2025-01-14 16:00:00', '', 'md', NULL, '{}', 'true', '/docs/index2', '{"title":"demo2","description":""}', 'docs/2.index2', NULL, NULL);: Error loading shared library /home/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node: Exec format error
Failed to execute SQL CREATE TABLE IF NOT EXISTS _content_info (id TEXT PRIMARY KEY, "version" VARCHAR);: Error loading shared library /home/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node: Exec format error
Failed to execute SQL DELETE FROM _content_info WHERE id = 'checksum_docs';: Error loading shared library /home/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node: Exec format error
Failed to execute SQL INSERT INTO _content_info VALUES ('checksum_docs', 'TognxvETDU');: Error loading shared library /home/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node: Exec format error
@farnabaz
Copy link
Member

Since there is a native dependency in the project, you need to build your project inside your docker file. Building the project outside will install incompatible binary which cannot be execute in the alpine architecture.

Checkout this docker file https://github.com/Phu1237/nuxt-content-docker/blob/master/Dockerfile

@farnabaz farnabaz added question Further information is requested v3 labels Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested v3
Projects
None yet
Development

No branches or pull requests

2 participants