How to Manage Services in App Platform

The usual app creation process will create a service by default; you only need to follow this process if you’re creating another component for your app that needs an internet-accessible endpoint. If your component only needs to be internally accessible, create a internal service instead. If you don’t need this component to be internet-accessible, create a worker instead.

Create a Service

  1. Go to https://cloud.digitalocean.com/apps, click on your app, and click on the Components tab. Add a Service component by clicking the Create Component button and choosing the Service option.
Component screen
  1. Select the source code for the Service on GitHub. If connecting for the first time, you will see an empty repository list and will need to click the link labeled Configure your GitHub permissions, then refresh this page.

  2. Next, give the Service a name and select which branch of the source repo you’d like to use as the source of the Service. Click Next.

  3. App Platform will inspect the code and select an appropriate runtime environment (such as Node, Ruby, etc). If you need to override this, you can see if there is a better options in the drop-down labeled Type as well. If nothing suitable appears there, upload a Dockerfile to your branch and restart the app creation process.

  4. App Platform will also display any appropriate build and run commands that it detected, which you can now customize as needed.

  5. If the use of environment variables is required, click Edit and supply them. Click the Encrypt checkbox to ensure a variable’s value is obscured in all build, deploy, and application logs.

  6. Select a plan, and click Launch Service.

Edit a Service

Go to https://cloud.digitalocean.com/apps, click on your app, and click on the Components tab. Click the Service you’d like to edit.

You can use the configuration settings you see here to change the Service’s scaling behavior, modify environment variables, edit commands, and more.

Destroy a Service

Go to https://cloud.digitalocean.com/apps, click on your app, and click on the Components tab. Click on the Service you’d like to destroy.

You can destroy the Service by clicking the Destroy Component button on the bottom of the page and entering its name to confirm your selection.

Create an Internal Service

Internal services are not available for creation via the UI, they need to be created within the App spec. Documentation to deploy via doctl.

Adding another service to your app spec, like so:

services:
- environment_slug: go
  github:
    branch: master
    deploy_on_push: true
    repo: digitalocean/sample-golang
  instance_count: 1
  instance_size_slug: basic-xxs
  internal_ports:
  - 8080
  name: internal-service
  run_command: bin/sample-golang

This service has no HTTP port and route, making it inaccessible from the outside world. However, port 8080 is exposed internally making it an internal service. This service can be reached by workers and other services using the component name and the port, which in this example would be http://internal-service:8080. Keep in mind, services that are publicly accessible can function as an internal service as well by defining internal ports.

The build and run commands are the command-line statements that compile your app component at build time and launch your app component after it has been built, respectively.
A component in App Platform is any deployable, billable, run-time software element in your app. A component can be a database, a service, a worker, or a static site.
A container is a single running instance of a service, worker, or static site component shipped on App Platform.
The HTTP route for a service is the publicly-accessible directory path that maps to the root of your service.
In App Platform, a service is a type of component that is both accessible and running server-side code written in a supported programming language, such as Python, Ruby, Go, Node.js, or PHP.