Skip to main content

Overview

Fly.io hosts and executes your Shopify extension deployments. Each generation triggers a Fly.io build that compiles your code and deploys it to Shopify.

Why Fly.io?

Zero Config

Automatic setup
  • Detects build tools
  • Configures environment
  • Manages dependencies
  • Handles secrets

Fast Builds

Quick deployments
  • Cached layers
  • Parallel builds
  • Instant rollback
  • Hot reloading

GitHub Integration

Seamless connection
  • Auto-detects pushes
  • Branch deployments
  • PR previews
  • Commit tracking

Shopify CLI

Built-in tools
  • Shopify CLI installed
  • Deploy commands
  • Extension bundling
  • Version management

Setup Process

1

Create Fly.io Account

Sign up for Fly.io:
  1. Go to fly.io
  2. Click “Start a New Project”
  3. Sign in with GitHub
  4. Authorize Fly.io app
2

Generate Fly.io Token

Create API token:
  1. Go to Account Settings → Tokens
  2. Click “Create New Token”
  3. Name it “Synapse Deployment”
  4. Copy the token
3

Add Token to Synapse

Configure in dashboard:
  1. Go to Settings → Integrations
  2. Find Fly.io section
  3. Paste API token
  4. Click “Connect Fly.io”
4

Project Created

Synapse automatically creates:
  • Fly.io project per user
  • Service per generation
  • Environment variables
  • GitHub integration

Fly.io paid planject Structure

Your Fly.io setup:
Fly.io paid planject: synapse-user-{userId}
├── Service: gen-abc123-delivery-estimate
│   ├── Source: GitHub (user-xxx/synapse-extensions:gen-abc123)
│   ├── Build: buildpacks
│   ├── Environment: Production
│   └── Variables: SHOPIFY_*, RAILWAY_*
├── Service: gen-def456-volume-discount
│   ├── Source: GitHub (user-xxx/synapse-extensions:gen-def456)
│   ├── Build: buildpacks
│   ├── Environment: Production
│   └── Variables: SHOPIFY_*, RAILWAY_*
└── Shared Variables
    ├── SHOPIFY_CLI_PARTNERS_TOKEN
    ├── SHOPIFY_CLIENT_ID
    ├── SHOPIFY_CLIENT_SECRET
    └── SHOPIFY_DEV_STORE_URL

How Fly.io Builds Work

1

GitHub Push

Code pushed to repository triggers Fly.io
2

Build Detection

Fly.io uses buildpacks to detect:
  • Language (Node.js, Rust, etc.)
  • Package manager (npm, pnpm, yarn)
  • Build commands
  • Start commands
3

Dependency Install

Installs packages:
# For UI extensions
npm install

# For Rust functions
cargo fetch

# Shopify CLI
npm install -g @shopify/cli
4

Extension Build

Compiles extension:
# UI extensions
npm run build

# Rust functions
cargo build --release
shopify app function build
5

Shopify Deploy

Deploys to Shopify:
shopify app deploy --force
shopify app release --version=latest --force
6

Completion

Extension live in your dev store

Environment Variables

Fly.io automatically configures:
VariableDescriptionSource
SHOPIFY_CLIENT_IDApp client IDSynapse config
SHOPIFY_CLIENT_SECRETApp client secretSynapse config
SHOPIFY_CLI_PARTNERS_TOKENPartners API tokenSynapse config
SHOPIFY_DEV_STORE_URLDevelopment storeUser profile
FLY_REGIONDeployment environmentFly.io
FLY_APP_NAMEService identifierFly.io
FLY_APP_IDProject identifierFly.io

Adding Custom Variables

Add your own environment variables:
  • Via Fly.io Dashboard
  • Via Fly.io CLI
  • Via fly.toml
  1. Open your Fly.io project
  2. Select service
  3. Go to Variables tab
  4. Click “New Variable”
  5. Enter name and value
  6. Click “Add”
  7. Redeploy service

buildpacks Build Configuration

Fly.io uses buildpacks for builds. Customize in fly.toml:
{
  "build": {
    "builder": "nixpacks",
    "buildCommand": "npm run build:custom",
    "watchPatterns": [
      "extensions/**/*.tsx",
      "extensions/**/*.rs"
    ]
  },
  "deploy": {
    "startCommand": "./deploy.sh",
    "restartPolicyType": "ON_FAILURE",
    "restartPolicyMaxRetries": 10,
    "numReplicas": 1,
    "healthcheckPath": "/health",
    "healthcheckTimeout": 300
  }
}

Viewing Logs

Monitor deployments in real-time:
  • Fly.io Dashboard
  • Fly.io CLI
  1. Open Fly.io project
  2. Select service
  3. Click “Deployments” tab
  4. Click specific deployment
  5. View build and runtime logs
Log output:
Building...
[nixpacks] Detecting builder...
[nixpacks] Using Node.js builder
[nixpacks] Installing dependencies...
[nixpacks] Running build command...
Building extension: delivery-estimate
✓ Built in 12.3s
Deploying to Shopify...
✓ Deployed version 2024.10.30.1
✓ Released to dev store
Deployment complete!

Managing Services

See all deployed services:
# Via CLI
flyctl apps list

# Via dashboard
# Open project → View all services
Each generation gets its own service for isolation
Manually restart a service:
# Via CLI
flyctl apps restart

# Via dashboard
# Service → Settings → Restart Service
Useful for applying new environment variables
Remove unused services:
# Via CLI
flyctl apps destroy <service-id>

# Via dashboard
# Service → Settings → Delete Service
Frees up project resources
Monitor performance:
  • CPU usage
  • Memory consumption
  • Network traffic
  • Build duration
  • Deployment frequency
Available in Fly.io dashboard under Metrics tab

Deployment Strategies

  • Instant Deploy (Default)
  • Manual Deploy
  • PR Previews
Every push triggers immediate deployment:Pros:
  • Fast feedback
  • Always up-to-date
  • No manual steps
Cons:
  • May deploy broken code
  • No review process
Best for: Development, rapid iteration

Cost Management

Fly.io pricing and optimization:

Free Tier

  • $5 free credit per month
  • Pauses after 500 hours
  • Shared resources
  • Community support

Pro Plan ($20/month)

  • $20 credit included
  • Usage-based billing
  • Dedicated resources
  • Priority support

Optimization Tips

Remove Unused Services

Delete old generation services to save resources

Use Sleep Mode

Configure services to sleep when inactive

Optimize Builds

Cache dependencies, minimize build time

Monitor Usage

Track resource consumption in dashboard

Advanced Configuration

Use custom Docker build instead of buildpacks:
# Dockerfile
FROM node:20-alpine

# Install Shopify CLI
RUN npm install -g @shopify/cli

# Copy extension code
WORKDIR /app
COPY . .

# Install dependencies
RUN npm install

# Build extension
RUN npm run build

# Deploy to Shopify
CMD ["shopify", "app", "deploy", "--force"]
Fly.io automatically detects and uses Dockerfile
Optimize image size:
# Build stage
FROM node:20 AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

# Deploy stage
FROM node:20-alpine
RUN npm install -g @shopify/cli
WORKDIR /app
COPY --from=builder /app/extensions ./extensions
COPY shopify.app.toml .
CMD ["shopify", "app", "deploy", "--force"]
Trigger actions on deployment events:
  1. Service → Settings → Webhooks
  2. Add webhook URL
  3. Select events:
    • Deployment started
    • Deployment succeeded
    • Deployment failed
  4. Receive JSON payload
{
  "event": "deployment.succeeded",
  "project": "synapse-user-123",
  "service": "gen-abc123",
  "deployment": "dep-xyz789",
  "timestamp": "2025-10-30T12:00:00Z"
}

Troubleshooting

Error: Build fails during npm install or compilationCauses:
  • Missing dependencies
  • Node version mismatch
  • Memory limit exceeded
Solutions:
  • Check package.json
  • Specify Node version in package.json:
    {
      "engines": {
        "node": "20.x"
      }
    }
    
  • Review build logs for specific errors
  • Upgrade to Pro plan for more resources
Error: Deployment exceeds time limitCauses:
  • Large extension bundle
  • Slow Shopify API
  • Network issues
Solutions:
  • Optimize bundle size
  • Retry deployment
  • Increase timeout in fly.toml:
    {
      "deploy": {
        "healthcheckTimeout": 600
      }
    }
    
Error: SHOPIFY_CLIENT_ID not foundCauses:
  • Variables not configured
  • Service not linked to project
Solutions:
  • Verify variables in dashboard
  • Re-add via Fly.io CLI:
    flyctl secrets set SHOPIFY_CLIENT_ID=xxx
    
  • Redeploy service

Next Steps