docs icon indicating copy to clipboard operation
docs copied to clipboard

following your Docker setup by the letter ends in error

Open mpstaton opened this issue 1 year ago • 1 comments

📚 Subject area/topic

Docker setup

📋 Page(s) affected (or suggested, for new content)

https://docs.astro.build/en/recipes/docker/

📋 Description of content that is out-of-date or incorrect

I don't know, it just throws an error. Line 12 throws an error. CMD node ./dist/server/entry.mjs

But from the look of it, it doesn't even make it to the full node_modules install.

🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)

node:internal/modules/cjs/loader:1147 2024-02-24 15:29:40 throw err; 2024-02-24 15:29:40 ^ 2024-02-24 15:29:40 2024-02-24 15:29:40 Error: Cannot find module '/app/dist/server/entry.mjs' 2024-02-24 15:29:40 at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15) 2024-02-24 15:29:40 at Module._load (node:internal/modules/cjs/loader:985:27) 2024-02-24 15:29:40 at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) 2024-02-24 15:29:40 at node:internal/main/run_main_module:28:49 { 2024-02-24 15:29:40 code: 'MODULE_NOT_FOUND', 2024-02-24 15:29:40 requireStack: [] 2024-02-24 15:29:40 } 2024-02-24 15:29:40 2024-02-24 15:29:40 Node.js v20.11.1

Here's from the Inspect file in DockerDesktop. ], "State": { "Status": "exited", "Running": false, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 0, "ExitCode": 1, "Error": "", "StartedAt": "2024-02-24T21:29:40.61032129Z", "FinishedAt": "2024-02-24T21:29:40.636170537Z" },

mpstaton avatar Feb 24 '24 21:02 mpstaton

Hi @mpstaton, thanks for the report!

I followed the guide, using the two given files (Dockerfile and .dockerignore) verbatim and everything worked fine.

By the error you see, I assume you are using the section about SSR on Docker. As it mentions in the docs:

This Dockerfile will build your site and serve it using Node.js on port 4321 and therefore requires the Node adapter installed in your Astro project.

You have to start from a project with the Node adapter, which in turn requires the output to be either "server" or "hybrid". If that config is missing or set to static, or if you are not using the Node adapter, you'll see the error you posted.

Can you check that?

Fryuni avatar Feb 25 '24 03:02 Fryuni