astefanutti / kubebox

⎈❏ Terminal and Web console for Kubernetes
http://astefanutti.github.io/kubebox
MIT License
2.14k stars 142 forks source link

Docker build not working #153

Closed fpaparoni closed 2 weeks ago

fpaparoni commented 2 weeks ago

I'm trying to make some changes to the sourcecode but if I build the Docker image using the following standard command

docker build -t kubebox-custom . 

I receive this error

 "/kubebox/bundle.js": not found

in response to this command from the Dockefile

 [stage-1 5/7] COPY --from=builder /kubebox/bundle.js /kubebox/client.js:

I tried to enter in the builder container and I can see there isn't a bundle.js file

image

Is there something I'm doing wrong or isn't the builder container working properly?

fpaparoni commented 2 weeks ago

The problem seems related to some changes in Node 17 due to obsolete version of SSL.

I tried to locally set nvm to use node 16 and "npm run bundle" works but anyway it produces bundle.js in a different path, dist/js/bundle.js with the webpack configuration so I suppose there is something wrong with the Dockerfile

astefanutti commented 2 weeks ago

Thanks for the analysis. The Dockerfile relies on Node 12 which is indeed rather old. If you have an updated Dockerfile that works with a more recent version of Node, feel free to create a PR, I'd be happy to merge it!

fpaparoni commented 2 weeks ago

No sorry I'm trying to understand, but it seems like the actual Dockerfile (apart from this problem related to Node 17) has some problems related to paths.

I see problems this row in the Dockerfile

COPY --from=builder /kubebox/bundle.js /kubebox/client.js

because bundle.js is generated in a different path from webpack and client.js is inside another directory (lib). Is it an old version of Dockerfile of this project?

astefanutti commented 2 weeks ago

Ah got you. That's the Dockerfile for the project, so it's supposed to work. If it doesn't that's possible it's been broken, probably with some Webpack update.

fpaparoni commented 2 weeks ago

I changed this row

COPY --from=builder /kubebox/dist/js/bundle.js /kubebox/client.js

and the build works, but if I try to run it I have the execution of the node command directly in my console. I need to start it as I have done with the image published on dockerhub, to use it with the browser.

I saw there are two Dockerfile, one at root level and another inside docs. Which is the one used for the image kubebox which I installed in a remote cluster and (I know it should be simply docker run -t IMAGENAME) which is the command to run it?

astefanutti commented 2 weeks ago

The Dockerfile in docs is the one that's used to serve the Web interface in-cluster, from a Pod: https://github.com/astefanutti/kubebox/blob/0448a18e9e6acabba004d44fd1d0625027ba48ed/kubernetes.yaml#L58C16-L58C42

The Dockerfile at the root directory, is to run the CLI in container, either with kubectl e.g.:

$ kubectl run kubebox -it --rm --env="TERM=xterm" --image=astefanutti/kubebox --restart=Never

Or directly with Docker:

$ docker run -it --rm -v ~/.kube/:/home/node/.kube/:ro astefanutti/kubebox

So to use it in the browser, you need the former with the Web interface.

fpaparoni commented 2 weeks ago

ok great, it is like I supposed. But if I change something on the "main" folder, is there the need to copy something on the docs folder? Because I saw in docs folder there is only a kubebox.js without a relationship with the "main" folder. Is there some script/target to run to update also docs folder from the main folder?

astefanutti commented 2 weeks ago

Right, you need to run npm run browserify to update the content of the docs directory.

fpaparoni commented 2 weeks ago

I just added a pull request for this issue, thank you for your explanations