App Platform is a Platform-as-a-Service (PaaS) offering that allows developers to publish code directly to DigitalOcean servers without worrying about the underlying infrastructure.
The usual app creation process will create a service by default; you only need to follow this process if you’re creating another resource for your app that needs an internet-accessible endpoint. If your resource only needs to be internally accessible, create a internal service instead. If you don’t need this resource to be internet-accessible, create a worker instead.
You can add a service to an app using the CLI’s app update command or the API’s app update endpoint. To add a service, update the app’s spec with the service’s specifications and submit the spec using the following command or endpoint.
Select the repository service to retrieve your source code from, either: GitHub, GitLab, DigitalOcean Container Registry, Docker Hub, or a sample app. If you are connecting to your repository from DigitalOcean for the first time, you will need to click the Manage Access button to provide DigitalOcean access to the repositories or containers, then refresh this page.
Select the repository from the Repository drop-down list. Next, select which branch of the source repo you’d like to use as the source. Optionally, for monorepos, specify the folder that contains the source in the Source Directory field. For containers, specify the image tag to use. Click Next.
App Platform will inspect the code, select an appropriate resource type and also detect any appropriate build and run commands.
To change to a different resource type, click the edit icon to open the Settings page of the resource. Click Edit next to Resource Type, choose another option from the Type drop-down list. Click Save to confirm your changes.
In the settings page, you can also change the resource’s name, view the resource’s buildpacks, edit its build and run commands, edit the HTTP port and the request route, and more. Click Save to confirm your changes.
Optionally, if you want to specify additional resources, click the Add Additional Resource From Source link, repeat the procedure and click Next.
If you need to use environment variables, click Edit to the right of the resource name and supply them. Click the Encrypt checkbox to ensure a variable’s value is obscured in all build, deploy, and application logs.
To specify an app-level environment variable, click Edit to the right of Global. Click Save and then click Next.
See How to Use Environment Variables in App Platform for more details.
Review the resources, environment variables and pricing, and click Create Resources.
0.0.0.0
, rather than on the localhost (localhost
) or loopback interface (127.0.0.1
).Full HTTP request path preservation for services is not available in the control panel. Instead, set the preserve_path_prefix
annotation in the App Spec to true
.
In the Apps section of the DigitalOcean Control Panel, select your app and click on the Settings tab. Click the Web Service you’d like to edit.
You can use the configuration settings you see here to change the Web Service’s scaling behavior, modify environment variables, edit commands, and more.
In the Apps section of the DigitalOcean Control Panel, select your app and click on the Settings tab. Click on the Web Service you’d like to destroy.
You can destroy the Web Service by clicking the Destroy Component button on the bottom of the page and entering its name to confirm your selection.
Internal services are accessible to other components in the app’s private network. They do not have ports or endpoints exposed to the public internet.
You can create an internal service by closing the ports on an existing service or by updating an app’s spec with the internal_ports
field.
To create an internal service from the control panel, click your app and then click the Settings tab. From the Settings tab, select the service you want to make internal, scroll down to the Ports section, and then click Edit.
In the Ports section, leave the Public HTTP Port field blank to close the public port. Then click the Add internal ports for private networking checkbox and add the internal port you want to open in the Internal Port field. You can add additional internal ports by clicking Add internal port and repeating this step.
Once you have specified the ports you want to add, click Save. This redeploys the app with the new internal ports.
To create an internal service using the app spec, remove any existing http_port
fields from the target service object and then add the internal_ports
field to the service:
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
The example service above is an internal service because it has no HTTP port or route, so it is inaccessible from the public internet, but exposes port 8080 internally, so workers and other services can reach it.
To add Functions, adjust your app spec like so:
name: go-random
region: nyc
functions:
- name: go-api
github:
repo: digitalocean/sample-functions-golang-random
branch: master
deploy_on_push: true
This process requires you to authorize to GitHub and specify the region you want to create the Function in. You can also delete the region
field to automatically create the Function in the datacenter closest to you.