Configuring Website Deployment on DigitalOcean (Droplet/App Platform)
DigitalOcean offers two paths: Droplet (VPS with full control) and App Platform (PaaS with auto-deploy from Git). Popular with startups and small teams for simplicity and predictable pricing.
App Platform — Quick Start
# .do/app.yaml
name: myapp
region: fra
services:
- name: web
github:
repo: user/myapp
branch: main
deploy_on_push: true
build_command: npm run build
run_command: node server.js
environment_slug: node-js
instance_count: 2
instance_size_slug: basic-xxs
http_port: 3000
envs:
- key: DATABASE_URL
scope: RUN_TIME
type: SECRET
value: "${db.DATABASE_URL}"
- name: worker
github:
repo: user/myapp
branch: main
run_command: node worker.js
instance_count: 1
databases:
- name: db
engine: PG
version: "16"
size: db-s-1vcpu-1gb
# Deploy via CLI
doctl apps create --spec .do/app.yaml
doctl apps update APP_ID --spec .do/app.yaml
Droplet: Manual Setup
# Create droplet via CLI
doctl compute droplet create myapp \
--size s-2vcpu-4gb \
--image ubuntu-22-04-x64 \
--region fra1 \
--ssh-keys KEY_ID \
--user-data-file cloud-init.yaml
# cloud-init.yaml
#cloud-config
packages:
- nginx
- php8.3-fpm
- php8.3-pgsql
- composer
- certbot
- python3-certbot-nginx
runcmd:
- curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
- apt-get install -y nodejs
- systemctl enable nginx php8.3-fpm
Auto-deploy via GitHub Actions + Droplet
# .github/workflows/deploy.yml
jobs:
deploy:
steps:
- name: Deploy to Droplet
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.DROPLET_IP }}
username: deploy
key: ${{ secrets.SSH_KEY }}
script: |
cd /var/www/myapp
git fetch origin main && git reset --hard origin/main
composer install --no-dev
npm ci && npm run build
php artisan migrate --force
php artisan config:cache
sudo systemctl reload php8.3-fpm
Managed Kubernetes (DOKS)
# Create cluster
doctl kubernetes cluster create myapp-cluster \
--region fra1 \
--node-pool "name=worker-pool;size=s-2vcpu-4gb;count=3"
# Get kubeconfig
doctl kubernetes cluster kubeconfig save myapp-cluster
# Deploy via kubectl
kubectl apply -f k8s/
Spaces (S3-compatible Storage)
# Upload static files
s3cmd sync ./dist/ s3://myapp-assets/ \
--host=fra1.digitaloceanspaces.com \
--host-bucket=%(bucket)s.fra1.digitaloceanspaces.com \
--access_key=$SPACES_KEY \
--secret_key=$SPACES_SECRET \
--delete-removed \
--add-header="Cache-Control:public, max-age=31536000"
Load Balancer
doctl compute load-balancer create \
--name myapp-lb \
--region fra1 \
--forwarding-rules "entry_protocol:https,entry_port:443,target_protocol:http,target_port:80,certificate_id:CERT_ID" \
--droplet-ids "DROPLET_ID_1,DROPLET_ID_2" \
--health-check "protocol:http,port:80,path:/health,check_interval_seconds:10,response_timeout_seconds:5"
Implementation Timeline
- App Platform from Git: 4–8 hours
- Droplet + Nginx + deploy: 1–2 days
- DOKS (Kubernetes): 3–5 days







