Skip to content

Commit

Permalink
[#147] rupring_example README에 AWS Lambda 사용법 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
myyrakle committed Dec 10, 2024
1 parent 4f44793 commit 3573ad9
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ Cargo.lock

test.json

.vscode
.vscode

*.zip
7 changes: 6 additions & 1 deletion rupring_example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
name = "rupring_example"
version = "0.1.0"
edition = "2021"
default-run = "example"

[dependencies]
mockall = "0.13.1"
# rupring={ version = "0.11.0" }
rupring={ path="../rupring", features=["full"] }
serde = { version="1.0.193", features=["derive"] }

[[bin]]
name = "example"
path = "src/main.rs"

[[bin]]
name = "bootstrap"
path = "src/main.rs"
path = "src/lambda.rs"
21 changes: 20 additions & 1 deletion rupring_example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,31 @@ very easy
cargo run
```

## Docker
## Run with Docker

```bash
cd ./rupring_example
sudo docker build -t test .
sudo docker run -p 8080:8000 test
# ...

curl http://localhost:8080
```

## Deploy to AWS Lambda

1. Create an AWS Lambda. The runtime must be either Amazon Linux 2, Amazon Linux 2023.

2. Compile and create an executable file.

```bash
rustup target add x86_64-unknown-linux-musl
cargo build --release --target x86_64-unknown-linux-musl
```

3. Zip the executable file and upload it to the AWS console.

```bash
zip -j bootstrap.zip ./target/x86_64-unknown-linux-musl/release/bootstrap
# ...and upload it as a file to the AWS console
```
8 changes: 8 additions & 0 deletions rupring_example/src/lambda.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use domains::root::module::RootModule;

pub(crate) mod domains;
pub(crate) mod middlewares;

fn main() {
rupring::run_on_aws_lambda(RootModule {})
}
2 changes: 1 addition & 1 deletion rupring_example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ pub(crate) mod domains;
pub(crate) mod middlewares;

fn main() {
rupring::run_on_aws_lambda(RootModule {})
rupring::run(RootModule {})
}

0 comments on commit 3573ad9

Please sign in to comment.