Skip to content

Commit

Permalink
[fix] hyperledger-iroha#3451: Fix docker startup on M1
Browse files Browse the repository at this point in the history
Signed-off-by: Ilia Churin <churin.ilya@gmail.com>
  • Loading branch information
ilchu committed Jul 26, 2023
1 parent 8089ba2 commit 35777be
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ RUN rustup component add rust-src
# Install musl C++ toolchain to build wasm-opt
RUN wget -c http://musl.cc/x86_64-linux-musl-native.tgz -O - | tar -xz
RUN ln -s /x86_64-linux-musl-native/bin/x86_64-linux-musl-g++ /x86_64-linux-musl-native/bin/musl-g++
RUN ln -s /x86_64-linux-musl-native/bin/x86_64-linux-musl-gcc-ar /x86_64-linux-musl-native/bin/musl-ar
RUN ln -s /x86_64-linux-musl-native/bin/x86_64-linux-musl-gcc-ranlib /x86_64-linux-musl-native/bin/musl-ranlib
ENV PATH="$PATH:/x86_64-linux-musl-native/bin"
ENV RUSTFLAGS="-C link-arg=-static"
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=/x86_64-linux-musl-native/bin/x86_64-linux-musl-gcc
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.dev.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: '3.8'
services:
iroha0:
build: ./
platform: linux/amd64
environment:
IROHA_PUBLIC_KEY: ed01208BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB
IROHA_PRIVATE_KEY: '{"digest_function":"ed25519","payload":"8f4c15e5d664da3f13778801d23d4e89b76e94c1b94b389544168b6cb894f84f8ba62848cf767d72e7f7f4b9d2d7ba07fee33760f79abe5597a51520e292a0cb"}'
Expand All @@ -21,6 +22,7 @@ services:
command: iroha --submit-genesis
iroha1:
build: ./
platform: linux/amd64
environment:
IROHA_PUBLIC_KEY: ed0120815BBDC9775D28C3633269B25F22D048E2AA2E36017CBE5AD85F15220BEB6F6F
IROHA_PRIVATE_KEY: '{"digest_function":"ed25519","payload":"c02ffad5e455e7ec620d74de5769681e4d8385906bce5a437eb67452a9efbbc2815bbdc9775d28c3633269b25f22d048e2aa2e36017cbe5ad85f15220beb6f6f"}'
Expand All @@ -37,6 +39,7 @@ services:
init: true
iroha2:
build: ./
platform: linux/amd64
environment:
IROHA_PUBLIC_KEY: ed0120F417E0371E6ADB32FD66749477402B1AB67F84A8E9B082E997980CC91F327736
IROHA_PRIVATE_KEY: '{"digest_function":"ed25519","payload":"29c5ed1409cb10fd791bc4ff8a6cb5e22a5fae7e36f448ef3ea2988b1319a88bf417e0371e6adb32fd66749477402b1ab67f84a8e9b082e997980cc91f327736"}'
Expand All @@ -53,6 +56,7 @@ services:
init: true
iroha3:
build: ./
platform: linux/amd64
environment:
IROHA_PUBLIC_KEY: ed0120A66522370D60B9C09E79ADE2E9BB1EF2E78733A944B999B3A6AEE687CE476D61
IROHA_PRIVATE_KEY: '{"digest_function":"ed25519","payload":"5eed4855fad183c451aac39dfc50831607e4cf408c98e2b977f3ce4a2df42ce2a66522370d60b9c09e79ade2e9bb1ef2e78733a944b999b3a6aee687ce476d61"}'
Expand Down
1 change: 1 addition & 0 deletions docker-compose.dev.single.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: '3.8'
services:
iroha0:
build: ./
platform: linux/amd64
environment:
IROHA_PUBLIC_KEY: ed01208BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB
IROHA_PRIVATE_KEY: '{"digest_function":"ed25519","payload":"8f4c15e5d664da3f13778801d23d4e89b76e94c1b94b389544168b6cb894f84f8ba62848cf767d72e7f7f4b9d2d7ba07fee33760f79abe5597a51520e292a0cb"}'
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: '3.8'
services:
iroha0:
image: hyperledger/iroha2:dev
platform: linux/amd64
environment:
IROHA_PUBLIC_KEY: ed01208BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB
IROHA_PRIVATE_KEY: '{"digest_function":"ed25519","payload":"8f4c15e5d664da3f13778801d23d4e89b76e94c1b94b389544168b6cb894f84f8ba62848cf767d72e7f7f4b9d2d7ba07fee33760f79abe5597a51520e292a0cb"}'
Expand All @@ -21,6 +22,7 @@ services:
command: iroha --submit-genesis
iroha1:
image: hyperledger/iroha2:dev
platform: linux/amd64
environment:
IROHA_PUBLIC_KEY: ed0120815BBDC9775D28C3633269B25F22D048E2AA2E36017CBE5AD85F15220BEB6F6F
IROHA_PRIVATE_KEY: '{"digest_function":"ed25519","payload":"c02ffad5e455e7ec620d74de5769681e4d8385906bce5a437eb67452a9efbbc2815bbdc9775d28c3633269b25f22d048e2aa2e36017cbe5ad85f15220beb6f6f"}'
Expand All @@ -37,6 +39,7 @@ services:
init: true
iroha2:
image: hyperledger/iroha2:dev
platform: linux/amd64
environment:
IROHA_PUBLIC_KEY: ed0120F417E0371E6ADB32FD66749477402B1AB67F84A8E9B082E997980CC91F327736
IROHA_PRIVATE_KEY: '{"digest_function":"ed25519","payload":"29c5ed1409cb10fd791bc4ff8a6cb5e22a5fae7e36f448ef3ea2988b1319a88bf417e0371e6adb32fd66749477402b1ab67f84a8e9b082e997980cc91f327736"}'
Expand All @@ -53,6 +56,7 @@ services:
init: true
iroha3:
image: hyperledger/iroha2:dev
platform: linux/amd64
environment:
IROHA_PUBLIC_KEY: ed0120A66522370D60B9C09E79ADE2E9BB1EF2E78733A944B999B3A6AEE687CE476D61
IROHA_PRIVATE_KEY: '{"digest_function":"ed25519","payload":"5eed4855fad183c451aac39dfc50831607e4cf408c98e2b977f3ce4a2df42ce2a66522370d60b9c09e79ade2e9bb1ef2e78733a944b999b3a6aee687ce476d61"}'
Expand Down
18 changes: 17 additions & 1 deletion tools/kagami/src/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,7 @@ mod serialize_docker_compose {

const COMMAND_SUBMIT_GENESIS: &str = "iroha --submit-genesis";
const DOCKER_COMPOSE_VERSION: &str = "3.8";
const PLATFORM_ARCHITECTURE: &str = "linux/amd64";

#[derive(Serialize, Debug)]
pub struct DockerCompose {
Expand Down Expand Up @@ -935,10 +936,23 @@ mod serialize_docker_compose {
}
}

#[derive(Debug)]
struct PlatformArchitecture;

impl Serialize for PlatformArchitecture {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(PLATFORM_ARCHITECTURE)
}
}

#[derive(Serialize, Debug)]
pub struct DockerComposeService {
#[serde(flatten)]
source: ServiceSource,
platform: PlatformArchitecture,
environment: FullPeerEnv,
ports: Vec<PairColon<u16, u16>>,
volumes: Vec<PairColon<String, String>>,
Expand Down Expand Up @@ -978,6 +992,7 @@ mod serialize_docker_compose {

Self {
source,
platform: PlatformArchitecture,
command,
init: AlwaysTrue,
volumes: volumes.into_iter().map(|(a, b)| PairColon(a, b)).collect(),
Expand Down Expand Up @@ -1138,7 +1153,7 @@ mod serialize_docker_compose {

use super::{
CompactPeerEnv, DockerCompose, DockerComposeService, DockerComposeVersion, FullPeerEnv,
PairColon, ServiceSource,
PairColon, PlatformArchitecture, ServiceSource,
};
use crate::swarm::serialize_docker_compose::{AlwaysTrue, ServiceCommand};

Expand Down Expand Up @@ -1241,6 +1256,7 @@ mod serialize_docker_compose {
map.insert(
"iroha0".to_owned(),
DockerComposeService {
platform: PlatformArchitecture,
source: ServiceSource::Build(PathBuf::from(".")),
environment: CompactPeerEnv {
key_pair: key_pair.clone(),
Expand Down

0 comments on commit 35777be

Please sign in to comment.