4:49

Part 5 of 10

Set Up a Deployment Environment on DigitalOcean

0

Install VS Code and Elements, build a todos app by asking an AI agent, and deploy the app to DigitalOcean. Then tour the project environment, the elements command, the website and the business.

  1. 1. Introduction 0:18
  2. 2. Install VS Code 3:30
  3. 3. Install Elements 1:27
  4. 4. Create Your First App 5:26
  5. 5. Set Up a Deployment Environment on DigitalOcean 4:49
  6. 6. Deploy Your App 3:11
  7. 7. The Project Environment 2:32
  8. 8. The Elements Tooling 6:07
  9. 9. The Elements Website and Community 2:48
  10. 10. The Elements Business 1:27

In this video we draw what a deployment looks like, then create a DigitalOcean droplet to run the app and a managed Postgres cluster for its data, and copy the details the agent needs to deploy.

What a deployment is

You write and build the app on your laptop, and you control the deployment from there too.

The app runs on a virtual private server. We use DigitalOcean, where a server is called a droplet: a virtual machine running Ubuntu Linux. Amazon and other providers work too. Elements deploys to any Ubuntu server you reach over SSH.

  • A prototype needs your laptop and one droplet. Elements installs Postgres on that machine and creates the app's databases there.
  • A business app, or one that will add app servers, keeps its data in one database the servers share. That can be a Postgres machine you run yourself, or a managed provider such as DigitalOcean's Managed Postgres, which is what we use here.

DigitalOcean charges monthly for each droplet and for the database. See DigitalOcean's pricing (opens in a new tab) for the current rates.

Start with one app server. Add a second for redundancy, so one picks up the load if the other fails, and add more when you have many users. Elements balances the load across the app servers automatically: create a droplet, tell the agent about it, and the agent configures Elements.

If you have a domain name, give it to the agent too. Elements sets up the HTTPS certificates and keeps the app servers working together.

1. Create a droplet

Create a DigitalOcean (opens in a new tab) account if you don't have one. On your home page, click Create and choose Droplets.

  • Region: the default data center, or one you prefer.
  • Image: Ubuntu, the latest version.
  • Size: the default type. It defaults to 2 CPUs and 4 GB of memory; 1 CPU and 2 GB also work.
  • Storage: the default.
  • SSH key: click Add SSH Key and follow the instructions, or select a key you already have.
  • Networking: make sure the public IPv4 address is turned on. The app server faces the public internet.

Leave the rest and click Create Droplet.

2. Note the droplet's IP addresses

The droplet takes a minute or two, and its connection details a few seconds more. The panel shows a public IPv4 address and a private IP address. The agent needs both to set up the deployment.

3. Create a managed Postgres cluster

Click Create at the top again and choose the managed database.

  • Engine: PostgreSQL, the latest version.
  • Plan: Standard edition.
  • Storage: the default.

Leave the other defaults and click to create the database cluster. It takes longer than the droplet.

4. Copy the connection details

When the cluster is ready, scroll down to the Connection details panel and click its copy button. Paste them into the agent with the droplet's IP addresses, and the agent sets Elements up to use the new database cluster.

Add a comment