This repository contains a development environment setup for Fly.io machines with overlayfs and SSH support.
- Overlay filesystem for persistent changes
- SSH access over IPv6
- s6-overlay for service management
- 50GB volume for data storage
- 8GB RAM and 8 shared CPUs
Dockerfile- Container image definitionoverlayfs-init- Script for setting up overlay filesystemfly.toml- Fly.io app configurationmachines- CLI script for building and deployingcli/- Deno-based deployment toolingmachine-config-template.json- Template for machine configuration
reference/- API documentation and examples.dockerignore- Excludes non-build files from image
-
Clone this repository:
git clone <repository-url> cd fly-dev-env
-
Deploy to Fly.io:
# Build the image ./machines build --app fly-dev-env # Create a volume (if not exists) fly volumes create data --size 50 # Deploy a new machine ./machines deploy --app fly-dev-env
-
Get your machine's IPv6 address:
fly machine list
-
Create an SSH key pair if you don't have one:
ssh-keygen -t ed25519 -f ~/.ssh/fly_dev_env -
Create the .ssh directory and set permissions:
# Using the machines API exec endpoint curl -X POST \ -H "Authorization: Bearer $(fly auth token)" \ -H "Content-Type: application/json" \ https://api.machines.dev/v1/apps/fly-dev-env/machines/MACHINE_ID/exec \ -d '{"cmd": "mkdir -p /home/dev/.ssh && chmod 700 /home/dev/.ssh && chown dev:dev /home/dev/.ssh"}'
-
Install your SSH public key:
# Replace MACHINE_ID with your machine's ID and adjust the path to your public key curl -X POST \ -H "Authorization: Bearer $(fly auth token)" \ -H "Content-Type: application/json" \ https://api.machines.dev/v1/apps/fly-dev-env/machines/MACHINE_ID/exec \ -d "{\"cmd\": \"echo '$(cat ~/.ssh/fly_dev_env.pub)' > /home/dev/.ssh/authorized_keys && chmod 600 /home/dev/.ssh/authorized_keys && chown dev:dev /home/dev/.ssh/authorized_keys\"}"
-
Add to your SSH config (~/.ssh/config):
Host fly-dev HostName MACHINE_IPV6_ADDRESS User dev IdentityFile ~/.ssh/fly_dev_env -
Connect to your machine:
ssh fly-dev
The /data directory is mounted from a persistent volume and is available in both the base system and the overlay filesystem. Any data you want to persist should be stored here.
-
Check machine status:
fly machine status MACHINE_ID
-
View logs:
fly logs
-
If SSH connection fails:
- Verify the machine is running:
fly machine list - Check SSH service logs:
fly logs | grep sshd - Verify IPv6 connectivity:
ping6 MACHINE_IPV6_ADDRESS - Ensure key permissions:
chmod 600 ~/.ssh/fly_dev_env
- Verify the machine is running: