From ced31722bdcbc4c453868a1da8ed7ca3980a9417 Mon Sep 17 00:00:00 2001 From: Enrico Marconi Date: Tue, 28 Nov 2023 17:19:19 +0100 Subject: [PATCH] Dockerfile --- .dockerignore | 3 +++ Dockerfile | 20 ++++++++++++++++++++ bindings/grpc/Cargo.toml | 4 +++- bindings/grpc/src/main.rs | 8 +++++--- bindings/grpc/src/services/credential.rs | 1 + 5 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..115fe4a561 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +target/ +bindings/wasm/ +bindings/grpc/target/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..b7faca7c63 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM rust:bookworm as builder + +# install protobuf +RUN apt-get update && apt-get install -y protobuf-compiler libprotobuf-dev musl-tools + +COPY . /usr/src/app/ +WORKDIR /usr/src/app/bindings/grpc +RUN rustup target add x86_64-unknown-linux-musl +RUN cargo build --target x86_64-unknown-linux-musl --release --bin identity-grpc + +FROM gcr.io/distroless/static-debian11 as runner + +# get binary +COPY --from=builder /usr/src/app/bindings/grpc/target/x86_64-unknown-linux-musl/release/identity-grpc / + +# set run env +EXPOSE 50051 + +# run it +CMD ["/identity-grpc"] \ No newline at end of file diff --git a/bindings/grpc/Cargo.toml b/bindings/grpc/Cargo.toml index 23a4a88aa8..40bcd081b6 100644 --- a/bindings/grpc/Cargo.toml +++ b/bindings/grpc/Cargo.toml @@ -23,12 +23,14 @@ tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] } anyhow = "1.0.75" tokio-stream = { version = "0.1.14", features = ["net"] } identity_iota = { path = "../../identity_iota", features = ["resolver"] } -identity_storage = { path = "../../identity_storage", features = ["memstore"] } iota-sdk = { version = "1.1.2", features = ["stronghold"] } serde_json = { version = "1.0.108", features = ["alloc"] } thiserror = "1.0.50" rand = "0.8.5" serde = { version = "1.0.193", features = ["derive", "alloc"] } +[dev-dependencies] +identity_storage = { path = "../../identity_storage", features = ["memstore"] } + [build-dependencies] tonic-build = "0.10" diff --git a/bindings/grpc/src/main.rs b/bindings/grpc/src/main.rs index 37eeb353a6..76684a4e91 100644 --- a/bindings/grpc/src/main.rs +++ b/bindings/grpc/src/main.rs @@ -1,12 +1,14 @@ +use anyhow::Context; use identity_grpc::server::GRpcServer; use iota_sdk::client::Client; -const API_ENDPOINT: &str = "http://127.0.0.1:14265"; - #[tokio::main] async fn main() -> anyhow::Result<()> { + let api_endpoint = std::env::var("API_ENDPOINT") + .context("Missing environmental variable API_ENDPOINT")?; + let client: Client = Client::builder() - .with_primary_node(API_ENDPOINT, None)? + .with_primary_node(&api_endpoint, None)? .finish() .await?; diff --git a/bindings/grpc/src/services/credential.rs b/bindings/grpc/src/services/credential.rs index f41a05e475..3119e9f98e 100644 --- a/bindings/grpc/src/services/credential.rs +++ b/bindings/grpc/src/services/credential.rs @@ -50,6 +50,7 @@ mod credential_verification { #[derive(Debug, Error, Serialize, Deserialize)] #[serde(tag = "error_type", content = "reason")] +#[serde(rename_all = "snake_case")] pub enum RevocationCheckError { #[error("Unknown revocation type {0}")] UnknownRevocationType(String),