Node.js on Docker Question

I finally managed to set up a Docker project!

If I make a PHP project I can connect to a database no problem. If I make a Node.js project it doesn’t see a database. Which server am I using in a Node.js project? The Docker or the Node.js one that doesn’t have a database?

Perfect @brad :+1:

NodeJs server model like php , net etc … (short explantation nodejs is server side javascript )

you can use all database models and remote and local . it doesnt matter

1 Like

But the node JS server doesn’t have a local database. So this will be confusing for new users?

no no just choose database and connect like php server model …

But you have to have a database first. So new users would already have to have a remote database or install something like MAMP to connect to it.

Docker with PHP has a sample database at least.

Anyways, I look forward to your tutorials. Thank you.

1 Like

You are right, a template nodejs docker can be prepared for this.
ready to use templates

1 Like

@brad,

edit I thought you would just add the database, it is not included by default. I created a new test project to demonstrate.

  1. Here we see in the terminal that only the web service is started.
    https://prnt.sc/t8tzml

  2. We click on the Project Settings icon (the gear icon) to open up the project settings.
    https://prnt.sc/t8u035

  3. We click on Targets and see that the Database is currently set to None.
    https://prnt.sc/t8u0cp

  4. We change the Database from None to our preferred database type. I select mysql.
    https://prnt.sc/t8u0tw

  5. The default mysql settings should be fine, but can be adjusted as need be. I chose to leave the sample data. I also chose to enable the sql log (because I like logs :slight_smile: ).
    https://prnt.sc/t8u1p2

  6. We click on save so that our settings are saved and look for the green notifications in the bottom right hand corner.
    https://prnt.sc/t8u1yc

  7. At this point, the database will not be showing in Wappler, so you click on deploy to activate the new mysql container.
    https://prnt.sc/t8u50c

hmm, at this point, I started hitting errors in Docker, where both the web and db containers constantly restarted with errors. https://prnt.sc/t8um3v

@brad is that what you are running into?

Hi@scott,

I think I didn’t do step seven. And database wouldn’t connect. Which makes sense now. I will try in the morning again.

Thanks!

I must be one of the luckiest Wappler users on the planet :joy:. The only difference between what @scott has done and what I have done for my test is that I used the Sample Data with the following result

1 Like

Following up on my previous reply, I did find a little bug in the process. I had to create a Server Action before the Database Manager recognised the database connection.

Not sure why, but I switched from Development to Local, went through the automatic install of node packages and then switched back to Development and the database was there and no further issues with Docker. :slight_smile:

I think that is what happened to me. But I never thought to create a server connect action. I will test and confirm both your guys theories in the morning.

Thanks guys

1 Like

Ok, I tried both @scott and @ben ideas.

I went through all seven steps of Scott’s post and still couldn’t connect to database.

Created a server connection as Ben suggested and then I was able to connect to database. Seems Ben stumbled across a bug.