DEV Community

Cover image for How we deploy our website and API
lewisakura for PreMiD

Posted on

How we deploy our website and API

PreMiD is a decently large application. With just over 60 thousand users, it is a much larger feat to actually maintain the infrastructure that goes into running the website and application. This post is going to go through some of our strategies on how we deploy and keep all of our production servers in sync.

Let's discuss the website:

GitHub logo PreMiD / Website

πŸ“‚ All our website insides for free.


The website is a crucial part of PreMiD. It's the face of the application and contains all the information you'd want to know about PreMiD, and also includes the store. DePloY is our GitHub workflow that handles deploying both the website and the API. When we push to master or merge into stable, the website is automatically deployed on https://beta.premid.app and https://premid.app respectively. Here's the steps:
  • We SSH into the three servers that handle the website and API
  • We cd into the directory that has the guts of the website
  • Run a git reset
  • Pull
  • Install with yarn
  • Build the website with yarn build
  • Reload with pm2.

Lets talk about pm2 reload for a second. Reloading and restarting with pm2 is a very different operation. Reloading is a more graceful restart -- it takes down instances one by one and makes sure they start correctly before taking down the next one, and it keeps repeating this until your application is fully upgraded. This is a lifesaver when doing deployments, it means your application will remain running during an upgrade and even start serving new content whilst your old application is going down. The only time this may be an issue is if you have major changes between versions which may be incompatible and could lead to issues if both versions ran at the same time. If this is the case, we force a full restart on the deployment rather than a reload. However, this is such a rare occurrence that we never end up doing it.

The API is a very similar process. Identical, actually, except that instead of running nuxt we're just running a standard Node application.

And that's it! Really! Our deployment process is kept relatively simple.

This is part of a series of Behind the Scenes posts. Make sure to check them out as we post them!

Top comments (5)

Collapse
 
ben profile image
Ben Halpern

Great first post

Collapse
 
lewisakura profile image
lewisakura

Thank you!

Collapse
 
dmdboi profile image
Max Diamond

Great first post, can't wait to read more

Collapse
 
lewisakura profile image
lewisakura

Thank you! I'm hoping to post more about how we do things behind the scenes, so we definitely have posts in the making already.

Collapse
 
hannahwvp profile image
HannahWVP • Edited

Great! thank you very much to the author!