gitpod-io / gitpod

The developer platform for on-demand cloud development environments to create software faster and more securely.
https://www.gitpod.io
GNU Affero General Public License v3.0
12.84k stars 1.23k forks source link

MongoDB and Node (Express) #2175

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hi Everyone, I would like to ask about how can I install mongodb and set it up in gitpod as I am trying to run npm install mongod but I get an issue with node-gyp not being able to get installed, I just want to install mongodb to follow along an online course on my repo. Can I get some pointers as to how to get mongodb to work in gitpod?

fullmetalrooster commented 3 years ago

Do you want to install the mongodb database server or only the nodejs driver?

akosyakov commented 3 years ago

Please also consult our ultimate guide: https://www.gitpod.io/blog/gitpodify/#mongodb composed by @jankeromnes 🙏

ghost commented 3 years ago

I know how to install it but the problem is how to set it up with mongo compass on my local machine. It just does not connect at all

akosyakov commented 3 years ago

I know how to install it but the problem is how to set it up with mongo compass on my local machine. It just does not connect at all

Is it accessible remotely somehow?

@csweichel wrote a blog post about how to use local services from Gitpod workspaces: https://www.gitpod.io/blog/local-services-in-gitpod/

meysholdt commented 3 years ago

I assume your're running MongoDB in your Gitpod Workspace and Mongo Compass on your desktop (because it's a GUI app).

You'll need to make sure that

This assumes Compass talks a HTTP-based protocol and this assumes Compass is fine with the fact that Gitpod does the HTTPS-termination.

I haven't tried it myself.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

wisammechano commented 2 years ago

I assume your're running MongoDB in your Gitpod Workspace and Mongo Compass on your desktop (because it's a GUI app).

You'll need to make sure that

  • You have Mongo's port exposed in Gitpod (Marked as "public")
  • obtain the URL via gp url <portno> in Gitpod's Terminal.
  • wrap the URL into Mongo Compass's connection string.

This assumes Compass talks a HTTP-based protocol and this assumes Compass is fine with the fact that Gitpod does the HTTPS-termination.

I haven't tried it myself.

Unfortunately, I've tried this and it doesn't work. The problem seems to be the internal port mapping for gitpod. Trying to connect through gp url <portno> output, but it timesout for all ports: 27017(public), 80, 443 because gitpod URLs are actually proxied through HTTP protocols.

It seems that the only way to connect to other non-http services is through the chisel workaround to enable ssh tunneling to workspaces.

Though I wonder why URLs are as such, wouldn't it be close to usual behavior if a workspace had a unique url and then ports can actually be appended to it instead of pretending it to the domain?

so instead of https://27017-red-lynx-4rm8h0jx.ws-eu18.gitpod.io/ it becomes wp-red-lynx-4rm8h0jx.ws-eu18.gitpod.io:27017 then handler can be appended by the user. Sort of like how it is on localhost.