Hosting old Node Projects 👴🏼
Tags: docker, node, webdev, devops
Published: 2024-04-25 15:54:09

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?

<img src="https://media.giphy.com/media/l4JyX3V0yydvPHNBe/giphy.gif?cid=790b7611q6oy3vyawxz1ddd2dgrh7i024qb7b02hewk2lu9q&ep=v1_gifs_search&rid=giphy.gif&ct=g"/>

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: 

```Dockerfile
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"]
```

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

<img src="https://media2.giphy.com/media/v1.Y2lkPTc5MGI3NjExaDgzaG05b3Vqa3NsMWVubWh5MGpwZnZwcW55bGlwbnFmcnV3eHc5MCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/YWbTFXAVxWOn2HEadR/giphy.gif"/>

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](https://dokku.com) 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. 

<img src="https://media4.giphy.com/media/v1.Y2lkPTc5MGI3NjExNmdheG5kendoMWQ0anVxMmdiaXhuaTRqOG1pam1nc3dzejVxc3VvbCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/dZCa79nBsVDU1sWwbm/giphy.gif" width="100%" />

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](https://sliplane.io?utm_source=old-node-projects) 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.

<img src="https://media.giphy.com/media/cdGQHR4Qzefx6/giphy.gif?cid=790b7611y3h7mzew25mrz8v2f4u2wyl712s3lu1fp9ylnz1f&ep=v1_gifs_search&rid=giphy.gif&ct=g" style="width: 500px"/>

## 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](https://sliplane.io?utm_source=old-node-projects), which I co-founded.

<img src="https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExamkyMGNxOG5mNXE3dHFkdjN2dWg4MTJtcWNkdGRpbDV4dzlmNWwxYSZlcD12MV9naWZzX3NlYXJjaCZjdD1n/xT9IgG50Fb7Mi0prBC/giphy.gif"/>