Skip to content

fly-apps/hello-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hello Rust!

This is an example app demonstrating how to deploy a Rust program on Fly.io

Structure

App

Warp-based "hello world" app, as simple as it can get.

Binding to all addresses

Noticed this line?

    warp::serve(routes)
        // ipv6 + ipv6 any addr
        .run(([0, 0, 0, 0, 0, 0, 0, 0], 8080))
        .await;

This listens to all addresses on both IPv4 and IPv6, on port 8080. It's important to do this because your app would otherwise need to know about the 172.19.0.0/16 IP it should bind to specifically. Binding to IPv6 is not required, but is likely a good idea going forward.

fly.toml

A fairly standard fly.toml configuration, except for the cmd override:

[experimental]
cmd = "./hello" # should be the name of the binary you want to run

Dockerfile

The most efficient way to create a Docker image for a Rust app is a simple Dockerfile.

Our Dockerfile is heavily commented, but here's a short rundown:

  • Copy Cargo.{toml,lock} and build dependencies
  • Copy whole project and cargo install it

.dockerignore

You definitely want to ignore /target since this can get pretty hefty, adding to the build context's size, and slow down builds significantly.

Deploy

fly launch

About

Rust example app on Fly.io

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published