Docker NodeJS Deployment

Hi,

I am close to launching my new app and I am considering my options with DigitalOcean. I’ve used DO during development and I’ve set up a Production server through Wappler target and this all works fine. In order to have SSL on the production server I have a DO load balancer also. I want to have two web servers so I plan on adding a second droplet to the production load balancer to improve availability in case one server/droplet fails.

My question is how do I update both servers from Wappler when I want to push updates to the app?

Thanks
Allan

No expert here but you could try the new DO App platform.

You can set up a single deployment via git and easily manage as many containers as you like to achieve the reliability you seek.

Hi @mgaussie,

Thanks for your response. That is an option I have been considering along with the Managed Kubernetes that DO offers. The issue I see with deployment via git is that what Wappler pushes to git are the Wappler json files not the executable NodeJS files.

If there’s a way to export the generated NodeJS code locally, or even to push it directly to a git repository, that would open up those two options.

Thanks,
Allan

1 Like

I didn’t realise that. You’ll need one of the Wappler team to answer - that’s a bit beyond me! :slightly_smiling_face:

I don’t understand this part. What do you mean with nodejs code? NPM modules?

Hi @JonL,

The website code that Wappler deploys to a target. So if you’re doing a PHP site it will be html/js/css and php code. In my case my target is a NodeJS website so it will be the files and folders that Wappler generates to deploy to the NodeJS server.

To be honest I still don’t understand but I will try to explain as best as I can.

When you deploy a nodejs project you are basically deploying js, ejs and json files for your backend and html, js, css and other static assets for the frontend.

Wappler will deploy everything that is needed if you are following the docker route. The npm modules will not be deployed as those are downloaded on server at build time following what you have in the package.json file.

If you are going to go the GIT route and deploy to a PaaS like DO platform or Heroku you will also deploy all the files needed and available in your local repository except for the npm modules which will be handled by the PaaS when building your project.

You only need to make sure that DO platform or Heroku know you are deploying a nodejs based app. Normally this is handled automatically for you by the PaaS as they will check automatically if a package.json file is available and assume it’s a nodejs app you are deploying.

You actually don’t have to do much on your side to deploy.

If you are scaling out on a PaaS this topic is handled centrally by the PaaS itself. You just instruct how many resources you want to dedicate and the platform will handle the code sync from their own repository where you deployed remotely from your local one. That’s the beauty of PaaS. You can forget about infra and just focus on your code. Although it does come attached with a premium of course.

1 Like

Thanks for the detailed response.

Yes, I was talking about those files that are deployed. Currently I am creating the target droplet through Wappler and everything is handled. Subsequent deployments then create a new docker image and upload that to the droplet.

As I understand DO, for Kubernetes or App Platform I need to upload the docker image to a DO repository. As I’m not sure if that can be done from the target page in Wappler I was wondering if there was a way to save the output of the deployment process, the docker image, to a local folder and then manually upload that to wherever DO requires it for deployment to Kubernetes or App Platform.

Thanks
Allan

Are you referring then to deploying your app docker image to DO’s Container Registry to leverage rapid deployment to a Kubernetes cluster?

For DO App platform you can only deploy via GIT through github or gitlab. Internally it’s true they use k8s but all that is abstracted for you.

@JonL

Actually, I’m thinking that all I need to do is deploy as I do now to a droplet, then make a snapshot of that and that will be my docker image to be used in Kubernetes or App Platform.

Thanks
Allan

@JonL

Yes I want to go the Kubernetes route but couldn’t work out how to deploy from Wappler. But I think I may have a way as I said in my other post.

I just remember there is this nice FOSS project that will deploy for you on a DO k8s cluster and let you scale, manage and monitor from their app.

If you want I can get you in touch with one of the founders and I am pretty sure he will help you out to create a docker image of your full project and use their software.

They were looking just recently for people with apps close to release to work with closely to improve their platform.

Hey @JonL,

Thanks for the info, it looks interesting. I’m going to try out my idea with the snapshot as a feed into K8s and see how that goes on DO. I may take you up on your offer if I can’t get it to work.

Thanks
Allan

1 Like

Hey jonkinen, will follow your progress with this.

Do you know if Kubernetes with DO has persistent storage, or if you need to use DO Spaces, too?

Hi @mgaussie,

DO also has Block Storage Volumes that you can mount to a droplet, but in order to get the benefit of horizontal scaling I would prefer to use DO Spaces which is accessed via API calls and so is available to all of your replicated droplets.

Thanks
Allan

1 Like

Thanks @jonkinen - for speed I’ve just used the persistent storage that comes with the Docker Wappler integration. Only for basic assets like site logos etc. nothing big - but I do need to put some time aside and move to S3 or spaces, so as you say once I decide on the final landing place - either AWS or DO so I have a bit more flexibility. Thanks for the info.

Hi, I’m not using Docker yet, but I’m planning on it. I think this video could be very useful.

https://www.youtube.com/watch?v=gAkwW2tuIqE