Deploy to Fly.io
Goal: run the app on a Fly machine. Hamur has no fly preset and hamur deploy does not call flyctl; Fly builds a Dockerfile, and hamur build --docker writes one. So this recipe is the Docker output with Fly's config around it.
- Build with
--dockeronce, to get theDockerfileand.dockerignore, then let Fly describe the app.fly launch --no-deploywritesfly.toml:
hamur build --docker
fly launch --no-deploy
fly volumes create data --size 1
fly secrets set HAMUR_KEY="$(hamur create-key)"
fly deploy
- Check
fly.toml. The image listens onPORT=3000, sointernal_portis 3000. A volume mounted at/app/.datakeeps the default SQLite file of@hamur/dband the disk files of@hamur/blobacross deploys. A volume belongs to one machine, so an app that uses it runs on one machine; for more, use a hosted database and thes3blob driver.
app = "my-app"
primary_region = "ams"
[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = "stop"
auto_start_machines = true
min_machines_running = 0
[mounts]
source = "data"
destination = "/app/.data"
- Set
HAMUR_KEYas a secret before the first deploy: a built server without it does not start. The last line of the sample isfly deploy, which builds the image on Fly.
The .dockerignore keeps .env* out of the image, so every secret has to be a Fly secret or a variable in fly.toml.
See also: Docker, Node preset, Environment.