1 of 28

2 of 28

3 of 28

Automating Your App Platform Deployments with doctl

4 of 28

Mason Egger

Developer Advocate

@masonegger�

https://mason.dev

mason@do.co

4

5 of 28

Quick Outline

  • Learn about doctl�
  • Learn what the App Platform Spec is and how to use it�
  • Deploy an App to App Platform using doctl

  • By the end we’ll have deployed our entire App with a single command

6 of 28

Our App

  • Sammy Reader!

7 of 28

Resources

7

8 of 28

8

doctl

DigitalOcean’s Command Line Tool�(or DigitalOcean Control)

9 of 28

doctl

  • doctl is the command line tool for managing your DigitalOcean resources
  • Handles all products, from Droplets to App Platform
  • doctl provides you with a way to automate deployments from the command line
  • Other automation tools for DigitalOcean include our Terraform provider, so be on the lookout for App Platform support there

9

10 of 28

doctl apps -h

Usage:

doctl apps [command]

Aliases:

apps, app, a

Available Commands:

create Create an app

create-deployment Create a deployment

delete Deletes an app

get Get an app

get-deployment Get a deployment

list List all apps

list-deployments List all deployments

logs Get logs

update Update an app

11 of 28

App Platform Spec

12 of 28

App Spec Parts

  • Top Level
    • name of your app, domain
  • static_sites - Deploy a static site
  • databases - Deploy a development database
  • services - Deploy a public facing service
  • workers - Deploy a private service inaccessible on the public internet

App Spec Reference - https://www.digitalocean.com/docs/app-platform/resources/app-specification-reference/

13 of 28

Top Level

name: sammy-reader

domains:

- domain: sammy.shark.codes

14 of 28

static_sites

static_sites:

- name: rss-reader-frontend

github:

repo: do-community/rss-reader-frontend

branch: master

deploy_on_push: true

routes:

- path: "/"

envs:

- key: REACT_APP_API_URL

scope: RUN_AND_BUILD_TIME

value: sammy.shark.codes/api

type: GENERAL

15 of 28

databases

databases:

- name: rss

engine: PG

version: '12'

16 of 28

services

services:

- name: rss-reader-api

instance_count: 1

instance_size_slug: professional-xs

routes:

- path: "/api"

github:

repo: do-community/rss-reader-api

branch: main

deploy_on_push: true

run_command: gunicorn --worker-tmp-dir /dev/shm rss_reader.wsgi

envs:

17 of 28

services

17

- key: DB_USER

scope: RUN_AND_BUILD_TIME

value: "${rss.USERNAME}"

type: GENERAL

- key: DB_PASSWORD

scope: RUN_AND_BUILD_TIME

value: "${rss.PASSWORD}"

type: GENERAL

- key: DB_HOST

scope: RUN_AND_BUILD_TIME

value: "${rss.HOSTNAME}"

type: GENERAL

- key: DB_NAME

scope: RUN_AND_BUILD_TIME

value: "${rss.DATABASE}"

type: GENERAL

- key: DB_PORT

scope: RUN_AND_BUILD_TIME

value: "${rss.PORT}"

type: GENERAL

- key: DEBUG

scope: RUN_AND_BUILD_TIME

value: 'True'

type: GENERAL

- key: DJANGO_ALLOWED_HOSTS

scope: RUN_AND_BUILD_TIME

value: sammy.shark.codes

type: GENERAL

- key: APP_PLAT_ROUTE

scope: RUN_AND_BUILD_TIME

value: api

type: GENERAL

18 of 28

Let’s Get Deploying

19 of 28

Thanks for attending!

20 of 28

21 of 28

22 of 28

23 of 28

24 of 28

25 of 28

26 of 28

27 of 28

28 of 28