From d1a12b551d62456b1375beaae43796ddbd6f3b0c Mon Sep 17 00:00:00 2001 From: dastansam Date: Fri, 22 Mar 2024 17:46:58 +0100 Subject: [PATCH] Final changes --- .dockerignore | 4 +--- Dockerfile | 16 ++++++---------- README.md | 21 ++++++++++++++------- node/src/chain_spec.rs | 2 +- pallets/iso-8583/src/lib.rs | 13 +++++++++++++ 5 files changed, 35 insertions(+), 21 deletions(-) diff --git a/.dockerignore b/.dockerignore index ee0ad2c..63107a3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,2 @@ -target **/target -target/* -target \ No newline at end of file +!./target/release/iso8583-chain \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 007ba68..510c478 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,21 +8,17 @@ WORKDIR /app COPY . . # Build the substrate node -RUN --mount=type=cache,target=/usr/local/cargo/registry \ - cargo build --release --locked --features docker +RUN cargo build --release --locked --features docker # Use a smaller base image for the final image FROM debian:bullseye-slim # Install necessary dependencies -RUN apt-get update && apt-get install -y \ - libssl-dev \ - && rm -rf /var/lib/apt/lists/* - -RUN apt-get update && apt-get install -y \ - libssl1.1 \ - ca-certificates \ - curl +RUN apt-get update && \ + apt-get install -y libssl-dev libssl1.1 ca-certificates && \ + update-ca-certificates --fresh && \ + rm -rf /var/lib/apt/lists/* + # Copy the built substrate node binary from the builder stage COPY --from=builder /app/target/release/iso8583-chain /usr/local/bin/ diff --git a/README.md b/README.md index b2e7c7f..c1884b3 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,19 @@ cargo build --release ./target/release/iso8583-chain --dev --tmp -loffchain-worker ``` +Docker: + +```bash +# Ready to use docker image +docker run -it -p 9944:9944 kingleard/iso8583-chain --dev --tmp --unsafe-rpc-external --rpc-cors=all --rpc-methods=unsafe -loffchain-worker + +# Build docker image +docker build -t iso8583-chain . + +# Run docker image +docker run -it -p 9944:9944 iso8583-chain --dev --tmp --unsafe-rpc-external --rpc-cors=all --rpc-methods=unsafe -loffchain-worker +``` + ### Offchain Worker First and foremost, insert the offchain worker key by running this command: @@ -55,10 +68,4 @@ cargo tarpaulin --workspace --all-features This is the high-level overview of components and how they interact: -![iso-8583-overview](https://github.com/subclone/payment-processor/assets/88332432/01c97bed-2ec8-4041-9702-cf079477e9be) - -```rs -cargo build -r - -./target/release/iso8583-chain --dev --tmp -``` +![iso-8583-overview](https://github.com/subclone/payment-processor/assets/88332432/939a8e5c-0b2e-4735-b0f4-003726008248) diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index b02daa7..2f72aab 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -169,7 +169,7 @@ fn testnet_genesis( .expect("valid account; qed"), ], #[cfg(feature = "docker")] - payment_processor_url: b"http://host.docker.internal:3001".to_vec(), + payment_processor_url: b"http://server:3001".to_vec(), #[cfg(not(feature = "docker"))] payment_processor_url: b"http://localhost:3001".to_vec(), }, diff --git a/pallets/iso-8583/src/lib.rs b/pallets/iso-8583/src/lib.rs index beacbd0..810cdc6 100644 --- a/pallets/iso-8583/src/lib.rs +++ b/pallets/iso-8583/src/lib.rs @@ -466,6 +466,19 @@ pub mod pallet { Ok(()) } + + /// Set payment processor url + /// + /// This function is used to set the payment processor url. + #[pallet::weight(T::DbWeight::get().writes(1))] + #[pallet::call_index(9)] + pub fn set_payment_processor_url(origin: OriginFor, url: StorageKey) -> DispatchResult { + ensure_root(origin)?; + + PaymentProcessorUrl::::put(url); + + Ok(()) + } } #[pallet::hooks]