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:
- Create a free Digital Ocean account (or sign in with Google or GitHub).
You can incur costs when running this quickstart! For more details, see App Platform Pricing and Container Registry Pricing.
- 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?
)
-
Install the Digital Ocean CLI (doctl) on your machine.
-
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.
You can switch authentication contexts in doctl
buy running:
doctl auth switch --context [NAME]
- Give Docker permission to push images to Digital Ocean by running:
doctl registry login
- 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)
Be creative - registry names must be unique across all Digital Ocean container registries.
Deploying
1. Build your API for production use
Simply run:
dart_frog build
This will create a /build
directory with all the files needed to deploy your API.
2. Build your API using Docker
In order to build a Docker image, you can run this command:
docker build build \
--tag registry.digitalocean.com/[REGISTRY]/[IMAGE_NAME]
[REGISTRY]
: The name of the registry you created earlier[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.
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.
We recommend using an automated workflow via GitHub Actions to automate deployments and ensure a consistent environment when building your image.
3. Push the image to Container Registry
docker push registry.digitalocean.com/[REGISTRY]/[IMAGE_NAME]
You should now see your repository in the Container Registry page
4. Create your App
Create an application on Digital Ocean by following these instructions.
5. Enjoy your API on Digital Ocean!
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 🎉