Skip to content
Snippets Groups Projects
Commit bfb85c07 authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

add Dockerfile (!31)

* working dockerfile

* wip dockerfile

TODO make duniter-polkadot-sdk repo lighter to avoid long download time in docker build

(cherry picked from commit 5f4b716f)

* update subxt and polkadot sdk
parent 76024d27
No related branches found
No related tags found
1 merge request!31add Dockerfile
target/
This diff is collapsed.
......@@ -13,37 +13,37 @@ version = "0.2.10"
[dependencies]
# subxt is main dependency
subxt = { git = 'https://github.com/duniter/subxt', branch = 'subxt-v0.34.0-duniter-substrate-v1.6.0', default-features = false, features = [
subxt = { git = 'https://github.com/duniter/subxt', branch = 'subxt-v0.35.3-duniter-substrate-v1.11.0', default-features = false, features = [
"substrate-compat",
"native",
"jsonrpsee",
] }
# substrate primitives dependencies
sp-core = { git = "https://github.com/duniter/duniter-polkadot-sdk.git", branch = "duniter-substrate-v1.6.0" }
sp-runtime = { git = "https://github.com/duniter/duniter-polkadot-sdk.git", branch = "duniter-substrate-v1.6.0" }
sp-core = { git = "https://github.com/duniter/duniter-polkadot-sdk.git", branch = "duniter-substrate-v1.11.0" }
sp-runtime = { git = "https://github.com/duniter/duniter-polkadot-sdk.git", branch = "duniter-substrate-v1.11.0" }
# crates.io dependencies
anyhow = "^1.0"
clap = { version = "^4.5.0", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "^3.6.9" }
clap = { version = "^4.5.4", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "^3.6.12" }
env_logger = "^0.10"
futures = "^0.3.30"
graphql_client = { version = "^0.13.0", features = ["reqwest-rustls"] }
hex = "^0.4.3"
log = "^0.4.20"
reqwest = { version = "^0.11.24", default-features = false, features = [
log = "^0.4.21"
reqwest = { version = "^0.11.27", default-features = false, features = [
"rustls-tls",
] }
rpassword = "^7.3.1"
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0.113"
tokio = { version = "^1.36.0", features = ["macros"] }
serde_json = "^1.0.117"
tokio = { version = "^1.37.0", features = ["macros"] }
confy = "^0.5.1"
bs58 = "^0.5.0"
bs58 = "^0.5.1"
inquire = "^0.6.2"
directories = "^5.0.1"
comfy-table = "^7.1.0"
comfy-table = "^7.1.1"
# crypto
scrypt = { version = "^0.11", default-features = false } # for old-style key generation
......
# FROM rustlang/rust:nightly-slim as build
# nightly needed for -Zgit=shallow-deps build but ahash problem with stdsimd
FROM rust:latest as build
# # Use musl Rust image
# FROM clux/muslrust:1.75.0-stable as build
WORKDIR /app
# Copy the Cargo.toml and Cargo.lock files to leverage Docker's caching mechanism
COPY Cargo.toml Cargo.lock ./
# Build the dependencies of the application separately
RUN --mount=type=cache,target=/app/target \
--mount=type=cache,target=/root/.cargo/registry \
mkdir src \
&& echo "fn main() {}" > src/main.rs \
&& cargo build --release \
&& rm -r src
# Copy the rest of the source code
COPY ./res ./res
COPY ./src ./src
# Build the application
RUN cargo build --release
# Start release stage
FROM debian as release
# Set the working directory to the location of the built application
WORKDIR /app
# Copy the built application from the previous stage
COPY --from=build /app/target/release/gcli .
# Specify the entrypoint for the container
ENTRYPOINT ["/app/gcli"]
\ No newline at end of file
# Docker
Docker image for gcli is useful for people with docker-based infrastructure or old system with old glibc or libssl.
## Build
```sh
./docker/build.sh
```
## Use
To use gcli, run it with docker:
```sh
docker run --rm gcli
```
Ğcli uses folders to store config and vault. You can bind local folders to these locations:
```sh
# create folders
mkdir -p $HOME/.config/gcli/
mkdir -p $HOME/.local/share/gcli/
# run gcli in docker with there folders
docker run --rm \
--mount type=bind,src=$HOME/.config/gcli/,dst=/root/.config/gcli \
--mount type=bind,src=$HOME/.local/share/gcli/,dst=/root/.local/share/gcli \
gcli
```
An alias can be useful:
```sh
# define alias
alias docker_gcli="docker run --rm \
--mount type=bind,src=$HOME/.config/gcli/,dst=/root/.config/gcli \
--mount type=bind,src=$HOME/.local/share/gcli/,dst=/root/.local/share/gcli \
gcli"
# then simply call
docker_gcli --help
```
#!/bin/bash
# Also generated by chatGPT
# Name of your Docker image
IMAGE_NAME="gcli"
# Version of your Docker image
IMAGE_VERSION="latest"
# Build and tag the Docker image using Docker Buildx
docker buildx build -t "$IMAGE_NAME:$IMAGE_VERSION" .
# Optionally, you can push the image to a Docker registry
# docker push "$IMAGE_NAME:$IMAGE_VERSION"
......@@ -29,7 +29,7 @@ pub async fn handle_command(_data: Data, command: Subcommand) -> Result<(), Gcli
.unwrap()
};
println!("Pubkey (hex): 0x{}", hex::encode(raw_pubkey));
let address: AccountId = sp_core::ed25519::Public(raw_pubkey).into();
let address: AccountId = sp_core::ed25519::Public::from_raw(raw_pubkey).into();
println!("Address (SS58): {}", address);
}
Subcommand::Prompt => {
......@@ -73,7 +73,7 @@ where
}
fn sign(&self, payload: &[u8]) -> T::Signature {
sp_core::ed25519::Signature(
sp_core::ed25519::Signature::from_raw(
nacl::sign::signature(payload, &self.keypair.skey)
.unwrap()
.try_into()
......
......@@ -107,9 +107,9 @@ pub async fn technical_committee_proposals(client: &Client) -> anyhow::Result<()
.at(parent_hash)
.iter(runtime::storage().technical_committee().proposal_of_iter())
.await?;
while let Some(Ok((proposal_hash, proposal))) = proposals_iter.next().await {
println!("{}", hex::encode(&proposal_hash[32..64]));
println!("{proposal:#?}");
while let Some(Ok(item)) = proposals_iter.next().await {
println!("{}", hex::encode(&item.key_bytes[32..64]));
println!("{:#?}", item.value);
println!();
}
......
......@@ -35,10 +35,10 @@ pub async fn monitor_expirations(data: &Data, blocks: u32, _sessions: u32) -> an
.iter(runtime::storage().certification().certs_removable_on_iter())
.await?;
let mut basic_certs = BTreeMap::new();
while let Some(Ok((k, v))) = basic_certs_iter.next().await {
let block_number = BlockNumber::from_le_bytes(k[40..44].try_into().unwrap());
while let Some(Ok(item)) = basic_certs_iter.next().await {
let block_number = BlockNumber::from_le_bytes(item.key_bytes[40..44].try_into().unwrap());
if block_number < end_block {
basic_certs.insert(block_number - current_block, v);
basic_certs.insert(block_number - current_block, item.value);
}
}
......@@ -72,13 +72,13 @@ pub async fn monitor_expirations(data: &Data, blocks: u32, _sessions: u32) -> an
.iter(runtime::storage().membership().memberships_expire_on_iter())
.await?;
let mut basic_memberships = BTreeMap::new();
while let Some(Ok((k, v))) = basic_membership_iter.next().await {
let block_number = BlockNumber::from_le_bytes(k[40..44].try_into().unwrap());
while let Some(Ok(item)) = basic_membership_iter.next().await {
let block_number = BlockNumber::from_le_bytes(item.key_bytes[40..44].try_into().unwrap());
if block_number < end_block {
if block_number < current_block {
dbg!((block_number, current_block));
}
basic_memberships.insert(block_number - current_block, v);
basic_memberships.insert(block_number - current_block, item.value);
}
}
......
......@@ -212,14 +212,14 @@ impl std::fmt::Display for IdtyView {
writeln!(
f,
"Certifications: received {}, issued {}",
self.cert_received_count, self.cert_issued_count
self.cert_received_count, self.cert_issued_count
)?;
if let Some(smith) = &self.smith {
writeln!(f, "Smith status: {:?}", smith.status)?;
writeln!(
f,
"Smith certs: received {}, issued {}",
smith.cert_received_count, smith.cert_issued_count
smith.cert_received_count, smith.cert_issued_count
)?;
}
let a = self.linked_account.len();
......
......@@ -65,13 +65,12 @@ pub async fn spam_roll(data: &Data, actual_repart: usize) -> anyhow::Result<()>
let dest: AccountId = pairs[i + 1].1.clone();
let watcher = client
.tx()
.create_signed_with_nonce(
.create_signed_offline(
&runtime::tx()
.balances()
.transfer_allow_death(MultiAddress::Id(dest).into(), 1),
&pairs[i].0,
nonce,
DefaultExtrinsicParamsBuilder::new().build(),
DefaultExtrinsicParamsBuilder::new().nonce(nonce).build(),
)?
.submit_and_watch()
.await?;
......
......@@ -58,18 +58,16 @@ pub async fn submit_call<Payload: TxPayload>(
// sign and submit
match data.keypair() {
// sr25519 key pair
KeyPair::Sr25519(keypair) => data.client().tx().create_signed_with_nonce(
KeyPair::Sr25519(keypair) => data.client().tx().create_signed_offline(
payload,
&PairSigner::<Runtime, sp_core::sr25519::Pair>::new(keypair),
nonce,
Default::default(),
DefaultExtrinsicParamsBuilder::new().nonce(nonce).build(),
),
// nacl key pair
KeyPair::Nacl(keypair) => data.client().tx().create_signed_with_nonce(
KeyPair::Nacl(keypair) => data.client().tx().create_signed_offline(
payload,
&commands::cesium::CesiumSigner::new(keypair),
nonce,
Default::default(),
DefaultExtrinsicParamsBuilder::new().nonce(nonce).build(),
),
}?
.submit_and_watch()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment