6

Deploying Realtime FeathersJS to DigitalOcean App Platform

 2 years ago
source link: https://blog.feathersjs.com/deploying-realtime-feathersjs-to-digitalocean-app-platform-64272487d00d
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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)

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.

0*BXMSLukAksGrs3oL.png?q=20
deploying-realtime-feathersjs-to-digitalocean-app-platform-64272487d00d

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.

0*E_Q9E2KqYSuvWiNt.png?q=20
deploying-realtime-feathersjs-to-digitalocean-app-platform-64272487d00d

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.

0*aaZurqWzq1CKW0oE.png?q=20
deploying-realtime-feathersjs-to-digitalocean-app-platform-64272487d00d

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.

0*iC-Ktg5RfkDCJlG0.png?q=20
deploying-realtime-feathersjs-to-digitalocean-app-platform-64272487d00d

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).

0*WN3UwiGp0ygId5sN.png?q=20
deploying-realtime-feathersjs-to-digitalocean-app-platform-64272487d00d

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:

0*moIOGMF8zTVS-_Bm.png?q=20
deploying-realtime-feathersjs-to-digitalocean-app-platform-64272487d00d

It’s available here:

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

The repo used:

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!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK