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.
Create an API token
This API token is very powerful and should be treated as a secret. Do not share this token and treat it like you would a password.
To create an API token, you'll need to sign in to the DigitalOcean Console. On the left sidebar, click on the "API" section.
On the API page, click the "Generate New Token" button.
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.
If you choose "Custom Scopes", you can select the following permissions:
The "Full Access" scope is the easiest option, but it gives the token access to everything. Choose what makes the most sense for your use case. Use the custom scopes below for the most secure option.
Access Level | Scopes | Details |
---|---|---|
Fully Scoped Access | 10 scopes | - firewall (4): create, read, update, delete - regions (1): read - sizes (1): read - ssh_key (4): create, read, update, delete |
Create Access | 4 scopes | project / tag / image / droplet |
Read Access | 5 scopes | snapshot / project / tag / image / droplet |
Update Access | 3 scopes | project / image / droplet |
Total Custom Scopes | 22 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.
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 Config | Description | API Reference |
---|---|---|
region | The data center and location you want to deploy your server to (pick the closest one to your customers). | See below for common examples. |
size | The type of server. | See below for common examples. |
image | The image to use for the server. | DigitalOcean Images |
backups | Whether 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.
Location | Country | Value |
---|---|---|
New York 1 | USA | nyc1 |
New York 3 | USA | nyc3 |
San Francisco 3 | USA | sfo3 |
Amsterdam 3 | Netherlands | ams3 |
Singapore 1 | Singapore | sgp1 |
London 1 | UK | lon1 |
Frankfurt 1 | Germany | fra1 |
Toronto 1 | Canada | tor1 |
Bangalore 1 | India | blr1 |
Sydney 1 | Australia | syd1 |
Common Size Values
Make sure your server type is supported in the region you choose. Also, some of the pricing may change so be sure to check the latest pricing on the DigitalOcean Droplet Pricing Page.
You can find the full list of server types here.
Server Type | vCPUs | RAM | Storage | Traffic | Monthly Price (USD) | Description |
---|---|---|---|---|---|---|
Basic Droplets | ||||||
s-1vcpu-1gb | 1 | 1GB | 25GB | 1TB | $6.00 | Basic |
s-1vcpu-1gb-amd | 1 | 1GB | 25GB | 1TB | $7.00 | Basic AMD |
s-1vcpu-1gb-intel | 1 | 1GB | 25GB | 1TB | $7.00 | Basic Intel |
s-1vcpu-2gb | 1 | 2GB | 50GB | 2TB | $12.00 | Basic |
s-2vcpu-2gb | 2 | 2GB | 60GB | 3TB | $18.00 | Basic |
s-2vcpu-4gb | 2 | 4GB | 80GB | 4TB | $24.00 | Basic |
s-2vcpu-4gb-amd | 2 | 4GB | 80GB | 4TB | $28.00 | Basic AMD |
s-2vcpu-4gb-intel | 2 | 4GB | 80GB | 4TB | $28.00 | Basic Intel |
CPU-Optimized Droplets | ||||||
c-2 | 2 | 4GB | 25GB | 4TB | $42.00 | CPU-Optimized |
c-4 | 4 | 8GB | 50GB | 5TB | $84.00 | CPU-Optimized |
c-8 | 8 | 16GB | 100GB | 6TB | $168.00 | CPU-Optimized |
c-16 | 16 | 32GB | 200GB | 7TB | $336.00 | CPU-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.