Create a Server with DigitalOcean

DigitalOcean is one of the most popular cloud VPS providers in the development community. Many tools and services are built to support it.

Create an account

The first step is to create an account with DigitalOcean. You can do this by going to their website and clicking the "Sign Up" button. With the link below, they offer $200 in credits. This is an affiliate link, meaning we get a small kickback if you sign up, but this doesn't affect our recommendations.

Sign Up with DigitalOcean →

Create an API token

To create an API token, you'll need to sign in to the DigitalOcean Console. On the left sidebar, click on the "API" section.

Go to DigitalOcean API

On the API page, click the "Generate New Token" button.

Generate DigitalOcean API Token

You can set a number of settings for the token:

  • Name: Set this to something descriptive.
  • Expiration: Set how long the token should be valid for. The shorter the value, the more secure, but the more often you'll need to generate a new token.
  • Scopes: Select "Custom Scopes" for the most secure option.

DigitalOcean API Token Scopes

If you choose "Custom Scopes", you can select the following permissions:

Access LevelScopesDetails
Fully Scoped Access10 scopes- firewall (4): create, read, update, delete
- regions (1): read
- sizes (1): read
- ssh_key (4): create, read, update, delete
Create Access4 scopesproject / tag / image / droplet
Read Access5 scopessnapshot / project / tag / image / droplet
Update Access3 scopesproject / image / droplet
Total Custom Scopes22 scopes

Place the token in your .spin.yml file

In your .spin.yml file, you'll find a providers section where you can add your DigitalOcean API token.

.spin.yml configure providers

##############################################################
# 👇 Providers - You must set at least one provider
##############################################################

providers:
  - name: digitalocean
    api_token: abc123def456ghi789jkl012mno345pqr678stu901vwx234yz

Set as DO_API_TOKEN environment variable

If you prefer to set the token as an environment variable, you can also set the DO_API_TOKEN variable in your .env file, secrets manager, or wherever you store your environment variables.

Configure users

Make sure you configure your system users in your .spin.yml file.

Learn more about users →

Example users configuration in .spin.yml

##############################################################
# 👇 Users - You must set at least one user
##############################################################

users:
  - username: alice
    name: Alice Smith
    groups: ['sudo']
    authorized_keys:
      - public_key: "ssh-ed25519 AAAAC3NzaC1lmyfakeublickeyMVIzwQXBzxxD9b8Erd1FKVvu alice"

Configuring a DigitalOcean hardware profile

By default we set you up with a very cost-effective hardware profile to get up and running quickly.

.spin.yml default Hardware Profiles

##############################################################
# 🤖 Hardware Profiles
##############################################################

hardware_profiles:
  # DigitalOcean
  - name: digitalocean_1c_1gb_ubuntu2404
    provider: digitalocean
    profile_config:
      region: nyc3
      size: s-1vcpu-1gb
      image: ubuntu-24-04-x64
      backups: true

You can uncomment the defaults we give you or create/modify your own hardware profile.

Profile ConfigDescriptionAPI Reference
regionThe data center and location you want to deploy your server to (pick the closest one to your customers).See below for common examples.
sizeThe type of server.See below for common examples.
imageThe image to use for the server.DigitalOcean Images
backupsWhether to enable snapshot backups for the server (may add 20% to the monthly price).Learn more about DigitalOcean snapshot backups.

Common Region Values

The region value is the slug of the region. You can find the full list of regions here.

LocationCountryValue
New York 1USAnyc1
New York 3USAnyc3
San Francisco 3USAsfo3
Amsterdam 3Netherlandsams3
Singapore 1Singaporesgp1
London 1UKlon1
Frankfurt 1Germanyfra1
Toronto 1Canadator1
Bangalore 1Indiablr1
Sydney 1Australiasyd1

Common Size Values

You can find the full list of server types here.

Server TypevCPUsRAMStorageTrafficMonthly Price (USD)Description
Basic Droplets
s-1vcpu-1gb11GB25GB1TB$6.00Basic
s-1vcpu-1gb-amd11GB25GB1TB$7.00Basic AMD
s-1vcpu-1gb-intel11GB25GB1TB$7.00Basic Intel
s-1vcpu-2gb12GB50GB2TB$12.00Basic
s-2vcpu-2gb22GB60GB3TB$18.00Basic
s-2vcpu-4gb24GB80GB4TB$24.00Basic
s-2vcpu-4gb-amd24GB80GB4TB$28.00Basic AMD
s-2vcpu-4gb-intel24GB80GB4TB$28.00Basic Intel
CPU-Optimized Droplets
c-224GB25GB4TB$42.00CPU-Optimized
c-448GB50GB5TB$84.00CPU-Optimized
c-8816GB100GB6TB$168.00CPU-Optimized
c-161632GB200GB7TB$336.00CPU-Optimized

Configure your server

By default, we give you defaults to get up and running quickly, but you might want to make some changes.

Learn more about server configuration →

Example server configuration in .spin.yml

##############################################################
# 👇 Servers - You must set at least one server
##############################################################

servers:
  - server_name: ubuntu-1gb-nyc-1
    environment: production
    hardware_profile: digitalocean_1c_1gb_ubuntu2404

Provision your server

Once you have everything ready, you can provision your server(s) by running this simple command:

Provision your server(s)

spin provision

This command will create your server(s) with DigitalOcean and configure your server(s) to be ready for deployment. There are many more options available when provisioning your server(s). To learn more see the guide below:

Learn more about "spin provision" →

Getting ready for deployment

Now that you have a server ready, you'll want to learn how to get ready for deployment. Next steps are to choose a deployment strategy.

Learn which deployment strategy is right for you →