Skip to main content

Digital Ocean App Platform 🌊

App Platform is a service from Digital Ocean that helps you launch apps quickly while they manage the underlying infrastructure.

Prerequisites​

Before you get started, if you haven't already completed these steps, you'll have to:

  1. Create a free Digital Ocean account (or sign in with Google or GitHub).
caution

You can incur costs when running this quickstart! For more details, see App Platform Pricing and Container Registry Pricing.

  1. Install Docker on your machine and run it. You can verify it is set up correctly by running:
docker images

(If Docker is running, the command will print the images on your machine. If not, it will print something like Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?)

  1. Install the Digital Ocean CLI (doctl) on your machine.

  2. Create a Digital Ocean API Token for your account with read and write access, then use it to give doctl access to your account by running (it will prompt you for the access token):

doctl auth init --context [NAME]
  • [NAME]: A new name for the authentication context.
tip

You can switch authentication contexts in doctl buy running:

doctl auth switch --context [NAME]
  1. Give Docker permission to push images to Digital Ocean by running:
doctl registry login
  1. Create a Container Registry. This can be done in the Digital Ocean console, or by running:
doctl registry create [REGISTRY_NAME] --region [REGION]
  • [REGISTRY_NAME]: A name for the newly created registry.
  • [REGION]: The Digital Ocean region the registry should reside in (ex: sfo1)
note

Be creative - registry names must be unique across all Digital Ocean container registries.

Deploying​

  1. Build your API for production use by running:
dart_frog build

This will create a /build directory with all the files needed to deploy your API.

  1. Build your API using Docker by running:
docker build build \
--tag registry.digitalocean.com/[REGISTRY]/[IMAGE_NAME]
  • [REGISTRY]: The name of the registry you created eariler
  • [IMAGE_NAME]: A name given to this image to identify it in the registry

This command will build the Docker image on your machine and can take up to a few minutes.

caution

Since this step requires building an image on your own hardware make sure the image is compatible with the hardware used by Digital Ocean before proceeding.

For example, if you build on an M1 CPU, the generated image will not be able to run on an Intel CPU.

info

We recommend using an automated workflow via GitHub Actions to automate deployments and ensure a consistent environment when building your image.

  1. Push the image to Container Registry by running:
docker push registry.digitalocean.com/[REGISTRY]/[IMAGE_NAME]

You should now see your repository in the Container Registry page

  1. Create your App by following these instructions.

  2. Congratulations! You have successfully built and deployed your API to App Platform. You can now access your API via the URL at the top of the app’s overview page 🎉

Additional Resources​