From b28ba5ca557b06b438130cb343df3687766369bb Mon Sep 17 00:00:00 2001 From: Kendall Weihe Date: Fri, 5 Jul 2024 16:18:55 -0400 Subject: [PATCH] Add linux support in SystemArchitecture.set(), add Dockerfile's in example --- .../tbdex/sdk/rust/SystemArchitecture.kt | 4 +-- examples/hosted-wallet-kt/DockerfileAlpine | 28 +++++++++++++++++++ examples/hosted-wallet-kt/DockerfileUbuntu | 21 ++++++++++++++ examples/hosted-wallet-kt/docker-alpine | 13 +++++++++ examples/hosted-wallet-kt/docker-ubuntu | 13 +++++++++ 5 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 examples/hosted-wallet-kt/DockerfileAlpine create mode 100644 examples/hosted-wallet-kt/DockerfileUbuntu create mode 100644 examples/hosted-wallet-kt/docker-alpine create mode 100644 examples/hosted-wallet-kt/docker-ubuntu diff --git a/bound/kt/src/main/kotlin/tbdex/sdk/rust/SystemArchitecture.kt b/bound/kt/src/main/kotlin/tbdex/sdk/rust/SystemArchitecture.kt index f8880b4e..53a275a3 100644 --- a/bound/kt/src/main/kotlin/tbdex/sdk/rust/SystemArchitecture.kt +++ b/bound/kt/src/main/kotlin/tbdex/sdk/rust/SystemArchitecture.kt @@ -26,10 +26,10 @@ object SystemArchitecture { val osReleaseContent = osRelease.readText().lowercase() when { osReleaseContent.contains("ubuntu") -> - throw Exception("Ubuntu amd64 not yet supported") + System.setProperty("uniffi.component.tbdex.libraryOverride", "tbdex_uniffi_x86_64_unknown_linux_gnu") osReleaseContent.contains("alpine") -> - throw Exception("Alpine amd64 not yet supported") + System.setProperty("uniffi.component.tbdex.libraryOverride", "tbdex_uniffi_x86_64_unknown_linux_musl") else -> throw Exception("Unsupported OS arch $osReleaseContent") } diff --git a/examples/hosted-wallet-kt/DockerfileAlpine b/examples/hosted-wallet-kt/DockerfileAlpine new file mode 100644 index 00000000..922a45ce --- /dev/null +++ b/examples/hosted-wallet-kt/DockerfileAlpine @@ -0,0 +1,28 @@ +FROM --platform=linux/amd64 alpine:latest + +# Install dependencies +RUN apk update && apk add --no-cache \ + openjdk17 \ + gradle \ + maven \ + git \ + bash + +# Copy application code +COPY bound/kt /app/bound/kt +COPY examples/hosted-wallet-kt /app/examples/hosted-wallet-kt + +# Build the bound/kt project +WORKDIR /app/bound/kt +RUN mvn install + +# Build the hosted-wallet-kt project +WORKDIR /app/examples/hosted-wallet-kt +RUN ./gradlew build + +# Expose ports +EXPOSE 8081 +EXPOSE 8082 + +# Set the default command +CMD ["bash"] diff --git a/examples/hosted-wallet-kt/DockerfileUbuntu b/examples/hosted-wallet-kt/DockerfileUbuntu new file mode 100644 index 00000000..e8885071 --- /dev/null +++ b/examples/hosted-wallet-kt/DockerfileUbuntu @@ -0,0 +1,21 @@ +FROM --platform=linux/amd64 ubuntu:22.04 + +RUN apt-get update && apt-get install -y \ + openjdk-17-jdk \ + gradle \ + maven \ + git + +COPY bound/kt /app/bound/kt +COPY examples/hosted-wallet-kt /app/examples/hosted-wallet-kt + +WORKDIR /app/bound/kt +RUN mvn install + +WORKDIR /app/examples/hosted-wallet-kt +RUN ./gradlew build + +EXPOSE 8081 +EXPOSE 8082 + +CMD ["bash"] \ No newline at end of file diff --git a/examples/hosted-wallet-kt/docker-alpine b/examples/hosted-wallet-kt/docker-alpine new file mode 100644 index 00000000..814aa368 --- /dev/null +++ b/examples/hosted-wallet-kt/docker-alpine @@ -0,0 +1,13 @@ +#!/bin/bash + +# Create the network +docker network create hosted-wallet-kt-alpine-network + +# Build the image +docker build -f DockerfileAlpine -t hosted-wallet-kt-alpine ../../ + +# Run the pfi application +docker run -d --name pfi-app-alpine --network hosted-wallet-kt-alpine-network -p 8082:8082 hosted-wallet-kt-alpine ./gradlew :pfi:run + +# Run the wallet application +docker run -d --name wallet-app-alpine --network hosted-wallet-kt-alpine-network -p 8081:8081 hosted-wallet-kt-alpine ./gradlew :wallet:run \ No newline at end of file diff --git a/examples/hosted-wallet-kt/docker-ubuntu b/examples/hosted-wallet-kt/docker-ubuntu new file mode 100644 index 00000000..5ea988ab --- /dev/null +++ b/examples/hosted-wallet-kt/docker-ubuntu @@ -0,0 +1,13 @@ +#!/bin/bash + +# Create the network +docker network create hosted-wallet-kt-ubuntu-network + +# Build the image +docker build -f DockerfileUbuntu -t hosted-wallet-kt-ubuntu ../../ + +# Run the pfi application +docker run -d --name pfi-app-ubuntu --network hosted-wallet-kt-ubuntu-network -p 8082:8082 hosted-wallet-kt-ubuntu ./gradlew :pfi:run + +# Run the wallet application +docker run -d --name wallet-app-ubuntu --network hosted-wallet-kt-ubuntu-network -p 8081:8081 hosted-wallet-kt-ubuntu ./gradlew :wallet:run \ No newline at end of file