This commit is contained in:
Ruidy 2022-11-15 22:46:35 +01:00
parent aed6c16d5a
commit f32cca0b34
6 changed files with 1243 additions and 0 deletions

1
rust/.dockerignore Normal file
View file

@ -0,0 +1 @@
/target

1
rust/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

1194
rust/Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

10
rust/Cargo.toml Normal file
View file

@ -0,0 +1,10 @@
[package]
name = "example"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
env_logger = "0.9.0"
actix-web = "4"

21
rust/Dockerfile Normal file
View file

@ -0,0 +1,21 @@
FROM rust:alpine as builder
WORKDIR /app
COPY . ./
RUN apk -U upgrade --no-cache && \
apk add --no-cache musl-dev
RUN cargo build --release
FROM alpine
RUN apk -U upgrade --no-cache
COPY --from=builder app/target/release/example .
EXPOSE 8080
CMD ./example

16
rust/src/main.rs Normal file
View file

@ -0,0 +1,16 @@
use actix_web::{get, middleware::Logger, App, HttpResponse, HttpServer, Responder};
use env_logger::Env;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
env_logger::init_from_env(Env::default().default_filter_or("info"));
HttpServer::new(|| App::new().wrap(Logger::default()).service(hello))
.bind(("127.0.0.1", 8080))?
.run()
.await
}
#[get("/")]
async fn hello() -> impl Responder {
HttpResponse::Ok().body("Hello, World!")
}