Skip to content

Commit

Permalink
save it
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbhmr committed Dec 29, 2023
1 parent a11c7d0 commit b231208
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/spin-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: spin deploy
on:
push:
branches: "main"
paths-ignore:
- .gitignore
- LICENSE
- README.md
- .github/**
- "!.github/workflows/wasmer-deploy.yml"
workflow_dispatch:
concurrency: ${{ github.workflow }}
jobs:
wasmer-deploy:
environment:
name: fermyon-cloud
url: https://hello-world-rust-spin-app-vjy7e5ib.fermyon.app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup target add wasm32-wasi
- uses: fermyon/actions/spin/setup@v1
- uses: fermyon/actions/spin/deploy@v1
with:
fermyon_token: ${{ secrets.FERMYON_CLOUD_TOKEN }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# https://developer.fermyon.com/cloud/develop
target/
.spin/

#region https://github.com/github/gitignore/blob/main/Rust.gitignore
# Generated by Cargo
# will have compiled files and executables
debug/
Expand All @@ -12,3 +17,4 @@ Cargo.lock

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
#endregion
13 changes: 13 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "hello-world-rust-spin-app"
version = "0.0.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
anyhow = "1"
spin-sdk = { git = "https://github.com/fermyon/spin", tag = "v2.1.0" }

[workspace]
16 changes: 16 additions & 0 deletions spin.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
spin_manifest_version = 2

[application]
name = "hello-world-rust-spin-app"
version = "0.0.0"

[[trigger.http]]
route = "/..."
component = "hello-world-rust-spin-app"

[component.hello-world-rust-spin-app]
source = "target/wasm32-wasi/release/hello_world_rust_spin_app.wasm"
allowed_outbound_hosts = []
[component.hello-world-rust-spin-app.build]
command = "cargo build --target wasm32-wasi --release"
watch = ["src/**/*.rs", "Cargo.toml"]
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use spin_sdk::http::{IntoResponse, Request, Response};
use spin_sdk::http_component;

/// A simple Spin HTTP component.
#[http_component]
fn handle_hello_world_rust_spin_app(req: Request) -> anyhow::Result<impl IntoResponse> {
let url = req
.header("spin-full-url")
.map_or("", |v| v.as_str().unwrap_or_default());
println!("Handling request to {:?}", url);
Ok(Response::builder()
.status(200)
.header("content-type", "text/plain")
.body("Hello, Fermyon")
.build())
}

0 comments on commit b231208

Please sign in to comment.