Fly.io
Fly.io deploys containerized applications to edge servers worldwide. For static sites, use a multi-stage Dockerfile that builds your site, runs pageflare, and serves the optimized output with a lightweight web server.
How It Works
Section titled “How It Works”Add pageflare to the build stage of your Dockerfile. The optimized files are then copied to a minimal serving image (nginx or Caddy).
Step 1 — Create the Dockerfile
Section titled “Step 1 — Create the Dockerfile”# Build stageFROM node:22-slim AS buildWORKDIR /appCOPY package*.json ./RUN npm ciCOPY . .RUN npm run build && npx @pageflare/cli dist/ --in-place --no-progress
# Serve stageFROM nginx:alpineCOPY --from=build /app/dist /usr/share/nginx/htmlEXPOSE 8080CMD ["nginx", "-g", "daemon off;"]Step 2 — Configure fly.toml
Section titled “Step 2 — Configure fly.toml”app = "my-site"primary_region = "iad"
[build]
[http_service] internal_port = 8080 force_https = trueStep 3 — Pro License
Section titled “Step 3 — Pro License”Pass your license key as a build argument:
FROM node:22-slim AS buildARG PAGEFLARE_LICENSEENV PAGEFLARE_LICENSE=$PAGEFLARE_LICENSE# ... rest of buildSet the secret in Fly.io:
fly secrets set PAGEFLARE_LICENSE=your-license-keyAnd pass it during deploy:
fly deploy --build-arg PAGEFLARE_LICENSE=your-license-keyStep 4 — Verify
Section titled “Step 4 — Verify”Check the deploy logs for the pageflare summary:
Done 145.2 KB saved (38.1%) 1.2s Files 42 total, 38 optimized, 4 unchanged, 0 errorsFramework Output Directories
Section titled “Framework Output Directories”| Framework | Output directory |
|---|---|
| Astro | dist/ |
| Next.js static export | out/ |
| Hugo | public/ |
| Vite | dist/ |
| Eleventy | _site/ |
Update the COPY --from=build path and the pageflare input directory to match your framework.
Troubleshooting
Section titled “Troubleshooting”Build fails with “command not found”
Make sure @pageflare/cli is in your devDependencies, or install it globally in the Dockerfile with RUN npm install -g @pageflare/cli.
Large Docker image
The multi-stage build ensures only the optimized static files end up in the final image. Make sure you’re copying from the build stage, not including node_modules in the final image.