event-catalog / eventcatalog

An open source documentation tool to bring discoverability to your event-driven architectures
https://eventcatalog.dev
MIT License
1.69k stars 143 forks source link

Docker build not working #729

Closed wurst44 closed 1 week ago

wurst44 commented 1 month ago

Hello, I guess I am supposed to copy the examples/default/Dockerfile to the root folder? When building I am getting the following error:

╰❯ $ docker build -t ec:1.0.0 .
[+] Building 37.9s (11/12)                                                                                                                                                                                                                 docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                 0.0s
 => => transferring dockerfile: 320B                                                                                                                                                                                                                 0.0s
 => [internal] load metadata for docker.io/library/node:lts                                                                                                                                                                                          0.4s
 => [internal] load metadata for docker.io/library/httpd:2.4                                                                                                                                                                                         0.7s
 => [internal] load .dockerignore                                                                                                                                                                                                                    0.0s
 => => transferring context: 2B                                                                                                                                                                                                                      0.0s
 => [build 1/5] FROM docker.io/library/node:lts@sha256:d3c8ababe9566f9f3495d0d365a5c4b393f607924647dd52e75bf4f8a54effd3                                                                                                                              0.0s
 => [internal] load build context                                                                                                                                                                                                                    0.0s
 => => transferring context: 29.18kB                                                                                                                                                                                                                 0.0s
 => CACHED [runtime 1/2] FROM docker.io/library/httpd:2.4@sha256:3f71777bcfac3df3aff5888a2d78c4104501516300b2e7ecb91ce8de2e3debc7                                                                                                                    0.0s
 => CACHED [build 2/5] WORKDIR /app                                                                                                                                                                                                                  0.0s
 => [build 3/5] COPY . .                                                                                                                                                                                                                             0.9s
 => [build 4/5] RUN npm i                                                                                                                                                                                                                           33.0s
 => ERROR [build 5/5] RUN npm run build                                                                                                                                                                                                              1.5s 
------                                                                                                                                                                                                                                                    
 > [build 5/5] RUN npm run build:                                                                                                                                                                                                                         
1.326                                                                                                                                                                                                                                                     
1.326 > @eventcatalog/core@2.5.0 build                                                                                                                                                                                                                    
1.326 > npm run scripts:hydrate-content && astro check --minimumSeverity error && astro build                                                                                                                                                             
1.326                                                                                                                                                                                                                                                     
1.408 
1.408 > @eventcatalog/core@2.5.0 scripts:hydrate-content
1.408 > node scripts/catalog-to-astro-content-directory.js
1.408 
1.457 node:path:1175
1.457       validateString(arg, 'path');
1.457       ^
1.457 
1.457 TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
1.457     at Module.join (node:path:1175:7)
1.457     at file:///app/scripts/catalog-to-astro-content-directory.js:271:32
1.457     at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
1.457     at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
1.457     at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5) {
1.457   code: 'ERR_INVALID_ARG_TYPE'
1.457 }
1.457 
1.457 Node.js v20.16.0
------
Dockerfile:7
--------------------
   5 |     ENV NODE_OPTIONS=--max_old_space_size=2048
   6 |     RUN npm i
   7 | >>> RUN npm run build
   8 |     
   9 |     FROM httpd:2.4 AS runtime
--------------------
ERROR: failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1

Any ideas? Thx

boyney123 commented 1 month ago

Thanks for raising an issue.

There is an open PR at the moment, does this work for you? https://github.com/event-catalog/create-eventcatalog/pull/24

carlosallexandre commented 1 month ago

@wurst44, Could you create a small repo that reproduces this error for us? :pray:

wurst44 commented 1 month ago

I am not sure what you mean @carlosallexandre, I just ran docker build -t ec . after copying the Dockerfile to the root folder (Where is this procedure documeted?). With the PR I am getting other dependency errors. That was reminiscent of the Node versioning fun I had years ago.

carlosallexandre commented 1 month ago

@wurst44 Are you creating a catalog from npx @eventcatalog/create-eventcatalog@latest mycatalog?

dreglad commented 1 month ago

@wurst44 It seems your initial assumption about copying the Dockerfile to the root folder is not correct. That Dockerfile is likely a leftover from the scaffold files for the create-eventcatalog tool. As pointed out by @carlosallexandre, you should run the create-eventcatalog tool and build your container image using the Dockerfile generated by the tool.

This is just due to the ongoing development of the project, but there's definitely a source of confusion in the Dockerfile that could be addressed: I'd either consider the Dockerfile as unnecessary in this context and remove it, or I'd consider the example as being incomplete and ensure it includes the missing scaffold files (specifically, package.json and package-lock.json) required by the Dockerfile to function properly.

carlosallexandre commented 1 month ago

@dreglad Awesome point :smile:

Until now, the examples dir works for development purposes only. Running the npm run start:catalog we have an User EC to test hydration/watcher and other stuffs. Indeed, the Dockerfile here seems useless.

But, I think we should go a step further. Recently, @boyney123 added custom components to EC. These custom components doesn't appear in the files generated by create-eventcatalog bin. In other words, the create-eventcatalog files aren't up to date with the current examples. Perhaps, to solve this we could use examples from here like templates, such as astro templates. Following the same way astro does, create-eventcatalog could become cleaner (without the template there) and with giget download some template from examples here.

And to finish, #713 :laughing:

wurst44 commented 4 weeks ago

Thank you but I don't get it. I need to install the tooling to generate a Dockerfile? 😄

you should run the create-eventcatalog tool and build your container image using the Dockerfile generated by the tool.

Isn't the whole point of using Docker that you do not have to care about installing or generating any tooling and build & run it anywhere? Also reading your replies makes it more confusing. Where is all of this documented?

carlosallexandre commented 4 weeks ago

@wurst44 Detail for us, step by step what you did so everyone understand and reproduce the error.

For example:

  1. Clone this repository - specify which repository
  2. Copy Dockerfile from examples/default to root
  3. Run docker build -t ec .

Or:

  1. Create my catalog from npx @eventcatalog/create-eventcatalog mycatalog
  2. Run the docker build -t ec .

Detail as much as possible :pray:

boyney123 commented 1 week ago

Going to close for now if you still have the issues let us know , and reopen