RustのRocketアプリをrenderにデプロイする

2023/07/07

下記のような超シンプルな Rocket アプリを render にデプロイしてみます。

src/main.rs
#[macro_use]
extern crate rocket;

#[get("/")]
fn index() -> &'static str {
    "Hello, world!"
}

#[launch]
fn rocket() -> _ {
    rocket::build().mount("/", routes![index])
}

ここを参考に、下記の設定でデプロイをしましたが、タイムアウトで失敗しました。

  • Runtime: Rust
  • Build Command: cargo build --release
  • Start Command: cargo run --release

ここ に有料の場合、127.0.0.1ではなく、0.0.0.0にバインドさせる必要があると書いてありました。 そこで、ここ を参考に、Rocket.toml のaddress0.0.0.0にしたら、デプロイ成功しました!

Rocket.toml
[default]
address = "0.0.0.0"
Rust🦀, Network⚡, PostgreSQL🐘, Unity🎮

Tags

rust  (9)
rocket  (7)
svelte  (5)
c++  (4)
ethereum  (3)
solidity  (3)
vscode  (3)
sqlx  (3)
glfw  (2)
opengl  (2)
nestjs  (2)
graphql  (2)
render  (2)
wsl2  (2)
truffle  (1)
goerli  (1)
geth  (1)
hardhat  (1)
nft  (1)
gui  (1)
tetris  (1)
next.js  (1)
jwt  (1)
nextauth  (1)
node.js  (1)
prisma  (1)
passport  (1)
urql  (1)
codegen  (1)
mdsvex  (1)
markdown  (1)
tmux  (1)
nvim  (1)
axum  (1)
atcoder  (1)
vim  (1)
pacman  (1)
tracing  (1)
Cursor  (1)
VSCode  (1)
PHP  (1)
Laravel  (1)