Deploying Realtime FeathersJS to DigitalOcean App Platform
Tags: webdev, javascript, digitalocean, feathers
Published: 2020-12-17 19:20:18

Recently, the [DigitalOcean App Hackathon](https://dev.to/devteam/announcing-the-digitalocean-app-platform-hackathon-on-dev-2i1k) was announced. If you've been following [my articles on FeathersJS](https://dev.to/rachel_cheuk/getting-started-with-realtime-events-and-streaming-data-in-js-4j6l), this is a great opportunity to try out Feathers. 

In this brief article, I'll show how to launch your own Feathers instance on Digital Ocean.

Similar to Heroku and other PaaS (Platform-as-a-Service) providers, with the DigitalOcean App service, it's quite easy and straightforward to deploy an application. Digital Ocean provides a full workflow to add in environment variables, add a managed database, build on code push, and to deploy your application. If you don't want to deal with the stress of CI/CD (continuous integration/continuous delivery) and DevOps for an application, this may be a good option. 

### Generate Application

To get started, I generated a basic Feathers application using the following settings:

`feathers generate app`

```bash
? Do you want to use JavaScript or TypeScript? ...JavaScript
? Project name ...do-feathers
? Description ...Digital Ocean Feathers App
? What folder should the source files live in? ...src
? Which package manager are you using (has to be installed globally)? ...Yarn
? What type of API are you making? ...Realtime via Socket.io
? Which testing framework do you prefer? ...Jest
? This app uses authentication ...Yes
? Which coding style do you want to use? ...ESLint
? What authentication strategies do you want to use? (See API docs for all 180+ supported oAuth providers) ...Username + Password (Local)
? What is the name of the user (entity) service? ...users
? What kind of service is it? ...NeDB
? What is the database connection string? (nedb://../data)
```

This scaffolded a barebones application.

I updated the `index.html` in `/public/index.html`.

Then I pushed this to [my github repo](https://github.com/meditatingdragon/do-feathers). 

### Digital Ocean App Platform

To create a new App, on the home screen, click the Create App button. 

![Alt Click Create App Button](https://dev-to-uploads.s3.amazonaws.com/i/ahz978dznto4j852i0ou.png)

This will walk you through creating an app.

#### Connect Github to Digital Ocean

The first step will be to connect your Github to Digital Ocean. 

![Alt Connect Github to Digital Ocean](https://dev-to-uploads.s3.amazonaws.com/i/h0qpz5yps68w9g7ped8a.png)

Follow the prompts to authorize your account, and either allow access to all repositories or only select repositories. 

Select the repository with your feathers app.

#### Name Your App and Select Deploy Branch

You'll be asked to name your application, select a region, and select a branch to deploy your application from. 

![Alt Name Application and select deploy branch](https://dev-to-uploads.s3.amazonaws.com/i/3k6ur9n4ctegyqkg01t3.png)

You can also decide if you want Digital Ocean to automatically rebuild your application and deploy it for you once you push a new commit.

#### Configure Application

Digital Ocean will attempt to detect the type of application you are trying to run. It should detect that you have a Node.js based application and offer some default options.

![Alt Configure Application Screen](https://dev-to-uploads.s3.amazonaws.com/i/mcurigf9dsie59o2a4de.png)

Update the settings as needed.

Depending on your application, you may need to update the Environment Variables, Build Commands, Run Command, and Port.

Environment variables should be used to store 3rd-party API credentials and database settings. 

For the default Feathers application, at a minimum, you'll need to update the port to 3030, which is the default setting for a Feathers Application (though you can change it if you choose). 

![Alt Update port to 3030](https://dev-to-uploads.s3.amazonaws.com/i/rk2etop9th7z1vyl6xnx.png)

#### Finalize and Launch

Finally, you'll be asked to select a plan. Choose one that meets your needs. If you're participating in the hackathon, you'll be given $50 credit for 60 days to use.

Once you're ready, hit the magic button: Launch Basic App.

### Sample Deployment

Take a look at my deployment:

![Alt Digital Ocean Deployment](https://dev-to-uploads.s3.amazonaws.com/i/tkopx4dtxjacnjbqjf33.png)

It's available here: 

[https://do-feathers-tc4py.ondigitalocean.app/](https://do-feathers-tc4py.ondigitalocean.app/)

Here's the repo used:

{% github https://github.com/meditatingdragon/do-feathers %}

I don't plan to keep it up long though, as I hope to deploy another app for the hackathon, so don't be surprised if it's no longer available by the time you read this!

#### Your Turn

Let me know if you run into any issues. Happy Hacking!