DEV Community

Cover image for Hosting old Node Projects 👴🏼
Lukas Mauser Subscriber for Wimadev

Posted on • Updated on • Originally published at sliplane.io

Hosting old Node Projects 👴🏼

A while ago, a friend of mine asked me to help him extend an old NodeJS project. But when we finished with all the changes, we could not deploy it anymore! The Node version was simply too old.

Google App Engine (GAE), where it was hosted before, refused to take care of our oldtimer. Yeah, they had a point. Hosting old stuff is generally not recommended for security reasons. And as a company, you don't want to maintain 20 different Node versions forever.

So we were left with the choice:

Spend a day, trying to upgrade Node and all dependencies, or find a different way to host our project.

It's the age old question:

To upgrade or not to upgrade?

Upgrading or not upgrading is essentially risk management. It's about estimating:

  • How big is the impact of a security breach?
  • How likely is it to happen?
  • How confident are you in your estimate?

I will make a wild guess here: If you really plan to host a 5 years old Node project, it's either so much enterprise that none of us programmers can fully comprehend the logic behind that decision, or it's a tiny project.

Our project is not mission critical. It does not store any personalized data and if it's down for a day, probably 2 people will notice.

We did not upgrade.

So, finding a different hosting solution it is!

Docker to the rescue 🐳

Luckily there is a neat little tool called Docker. It opens the doors to hosting pretty much anything you wish. Be it a frontend, backend, database or 5 year old NodeJs application.

For those of you, who are not already familiar with Docker, here is my two sentence intro:

Docker creates a container around your code, that houses all the dependencies necessary to run it. You define all of what you need in a Dockerfile, that can look something like this:

FROM node:12.3.1-alpine AS builder

WORKDIR /my-app

COPY package.json package-lock.json ./

RUN npm ci

COPY . .

RUN npm run build

FROM node:12.3.1-alpine AS runner

WORKDIR /my-app

COPY --from=builder /my-app/.output ./.output

EXPOSE 9000

CMD ["node", "./.output/server/index.mjs"]
Enter fullscreen mode Exit fullscreen mode

This Dockerfile contains instructions to build a Docker image with Node 12 installed, then copy our code into it, build it and run it. I won't go into all of the details in this post, but I do recommend you check out some other tutorials on Docker if you have not heard about it before.

And now instead of having to ask yourself: "Which provider still accepts Node 12?"

You ask: "Where can I host my container?"

Hosting Options

1. Self Hosting

If you know a thing or two about self hosting, you are probably able to fairly quickly spin up a VPS and throw your container on there.

But if you know a thing or two about self hosting, you also know, that taking care of the server can cause a lot of headaches and even if you manage to spin it up quickly, there is a bunch of overhead in solving secrets management, deploys, security updates etc.

If you want to dig into it anyways, Dokku is an interesting mention. They provide an Open Source PaaS that you can install on your server to simplify self hosting containers.

For our project though, we don't want to deal with server management, we just need a solution for hosting our old little Node project.

2. Major Cloud Providers

Amazon, Google and Microsoft offer a multitude of products (ECS, Cloud Run, Azure Container Instances, ...) in the container hosting space. They equip you with the tools to withstand an army of millions of users, firing requests at your container from all over the globe.

Great! No more worries about scaling! 🥳

But wait, we didn't worry about scaling in the first place. These solutions are highly capable but also highly complex. In the time we'd spend figuring out which product is the right one for our needs, we could have done a complete rewrite of our app.

And if we ever have to deal with an army of millions of users, it's probably time to upgrade...

We need a simple solution.

3. Simple Container Hosting

There are a bunch of other cloud services, that try to make simplicity a priority. These include Digital Ocean, Render or Railway for example. While they generally offer a great service, their entry plans often come with significant restrictions.

A fair compromise, but we were not fully happy with it.
If you read the book: "The third door", you know that there is often times an option, that is not obvious at first...

What Hoster did we choose?

We went for option Nr. 4 and instead of upgrading our app in a day, we fell into the rabbit hole and spent over a year of building a container hosting platform ourselves. 🤠

With a strong focus on simplicity, Sliplane enables you to deploy unlimited containers at a fixed rate for the fraction of the price of other popular hosting options. If you want to give it a shot, you can try it for free.

Recap

  1. Only host old stuff, that can't create serious damage
  2. Use Docker to containerize your app
  3. Choose from: self hosting, major cloud providers or simple container hosting solutions

Or try Sliplane, which I co-founded.

Top comments (6)

Collapse
 
code42cate profile image
Jonas Scholz

Love to see a properly pinned base image version 🫡

FROM node:12.3.1-alpine AS builder
Enter fullscreen mode Exit fullscreen mode
Collapse
 
wimadev profile image
Lukas Mauser

🫡

Collapse
 
thecodingthesi profile image
Thesi

and, how confident are you in your own estimate? 👀

Collapse
 
wimadev profile image
Lukas Mauser

Works 60% of the time, all the time 🤓

Collapse
 
userof profile image
Matthias Wiebe

Hugh - How long did it take u though hosting it with sliplane?

Collapse
 
wimadev profile image
Lukas Mauser

I just blinked and zap its there 😜