DEV Community

Cover image for Deploying Realtime FeathersJS to DigitalOcean App Platform
Rachel
Rachel

Posted on

Deploying Realtime FeathersJS to DigitalOcean App Platform

Recently, the DigitalOcean App Hackathon was announced. If you've been following my articles on FeathersJS, 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

? 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)
Enter fullscreen mode Exit fullscreen mode

This scaffolded a barebones application.

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

Then I pushed this to my github repo.

Digital Ocean App Platform

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

Alt Click Create App Button

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

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

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

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

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

It's available here:

https://do-feathers-tc4py.ondigitalocean.app/

Here's the repo used:

do-feathers

About

This project uses Feathers. An open source web framework for building modern real-time applications.

Getting Started

Getting up and running is as easy as 1, 2, 3.

  1. Make sure you have NodeJS and npm installed.

  2. Install your dependencies

    cd path/to/do-feathers
    npm install
    
  3. Start your app

    npm start
    

Testing

Simply run npm test and all your tests in the test/ directory will be run.

Scaffolding

Feathers has a powerful command line interface. Here are a few things it can do:

$ npm install -g @feathersjs/cli          # Install Feathers CLI

$ feathers generate service               # Generate a new Service
$ feathers generate hook                  # Generate a new Hook
$ feathers help                           # Show all commands

Help

For more information on all the things you can do with Feathers visit docs.feathersjs.com.

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!

Top comments (0)