diff --git a/.github/workflows/release_docker.yml b/.github/workflows/release_docker.yml index ba9cb957cad..0cdf3645e19 100644 --- a/.github/workflows/release_docker.yml +++ b/.github/workflows/release_docker.yml @@ -35,6 +35,15 @@ jobs: - name: Checkout code uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - name: Read Rust toolchain version from TOML + id: read_toolchain + run: | + TOOLCHAIN_VERSION=$(grep -oE 'channel = "[^"]+' ./rust-toolchain.toml | sed 's/channel = "//') + echo "TOOLCHAIN_VERSION=${TOOLCHAIN_VERSION}" >> $GITHUB_ENV + + - name: Log Rust toolchain version + run: echo "Rust toolchain version is ${{ env.TOOLCHAIN_VERSION }}" + - name: Set up QEMU uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 @@ -78,6 +87,8 @@ jobs: with: context: . file: docker/iota-node/Dockerfile + build-args: | + RUST_IMAGE_VERSION=${{ env.TOOLCHAIN_VERSION }}-bookworm platforms: linux/amd64 tags: ${{ steps.meta-node.outputs.tags }} push: true @@ -94,6 +105,15 @@ jobs: - name: Checkout code uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - name: Read Rust toolchain version from TOML + id: read_toolchain + run: | + TOOLCHAIN_VERSION=$(grep -oE 'channel = "[^"]+' ./rust-toolchain.toml | sed 's/channel = "//') + echo "TOOLCHAIN_VERSION=${TOOLCHAIN_VERSION}" >> $GITHUB_ENV + + - name: Log Rust toolchain version + run: echo "Rust toolchain version is ${{ env.TOOLCHAIN_VERSION }}" + - name: Set up QEMU uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 @@ -137,6 +157,8 @@ jobs: with: context: . file: docker/iota-indexer/Dockerfile + build-args: | + RUST_IMAGE_VERSION=${{ env.TOOLCHAIN_VERSION }}-bookworm platforms: linux/amd64 tags: ${{ steps.meta-indexer.outputs.tags }} push: true @@ -153,6 +175,15 @@ jobs: - name: Checkout code uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - name: Read Rust toolchain version from TOML + id: read_toolchain + run: | + TOOLCHAIN_VERSION=$(grep -oE 'channel = "[^"]+' ./rust-toolchain.toml | sed 's/channel = "//') + echo "TOOLCHAIN_VERSION=${TOOLCHAIN_VERSION}" >> $GITHUB_ENV + + - name: Log Rust toolchain version + run: echo "Rust toolchain version is ${{ env.TOOLCHAIN_VERSION }}" + - name: Set up QEMU uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 @@ -196,6 +227,8 @@ jobs: with: context: . file: docker/iota-tools/Dockerfile + build-args: | + RUST_IMAGE_VERSION=${{ env.TOOLCHAIN_VERSION }}-bookworm platforms: linux/amd64 tags: ${{ steps.meta-tools.outputs.tags }} push: true @@ -212,6 +245,15 @@ jobs: - name: Checkout code uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - name: Read Rust toolchain version from TOML + id: read_toolchain + run: | + TOOLCHAIN_VERSION=$(grep -oE 'channel = "[^"]+' ./rust-toolchain.toml | sed 's/channel = "//') + echo "TOOLCHAIN_VERSION=${TOOLCHAIN_VERSION}" >> $GITHUB_ENV + + - name: Log Rust toolchain version + run: echo "Rust toolchain version is ${{ env.TOOLCHAIN_VERSION }}" + - name: Set up QEMU uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 @@ -255,6 +297,8 @@ jobs: with: context: . file: docker/iota-graphql-rpc/Dockerfile + build-args: | + RUST_IMAGE_VERSION=${{ env.TOOLCHAIN_VERSION }}-bookworm platforms: linux/amd64 tags: ${{ steps.meta-tools.outputs.tags }} push: true diff --git a/apps/core/src/hooks/stake/index.ts b/apps/core/src/hooks/stake/index.ts index 2477e671351..2bfe4d462e8 100644 --- a/apps/core/src/hooks/stake/index.ts +++ b/apps/core/src/hooks/stake/index.ts @@ -6,3 +6,4 @@ export * from './useTotalDelegatedRewards'; export * from './useTotalDelegatedStake'; export * from './useValidatorInfo'; export * from './useStakeTxnInfo'; +export * from './useStakingGasBudgetEstimation'; diff --git a/apps/core/src/hooks/stake/useStakingGasBudgetEstimation.ts b/apps/core/src/hooks/stake/useStakingGasBudgetEstimation.ts new file mode 100644 index 00000000000..9c2cdf825e8 --- /dev/null +++ b/apps/core/src/hooks/stake/useStakingGasBudgetEstimation.ts @@ -0,0 +1,46 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import { useMemo } from 'react'; +import { useIotaClient } from '@iota/dapp-kit'; +import { useQuery } from '@tanstack/react-query'; +import { createStakeTransaction } from '../../utils'; + +interface UseStakingGasBudgetEstimationOptions { + senderAddress: string | null; + validatorAddress: string; + amount: bigint; +} + +export function useStakingGasBudgetEstimation({ + senderAddress, + validatorAddress, + amount, +}: UseStakingGasBudgetEstimationOptions) { + const client = useIotaClient(); + + const transaction = useMemo(() => { + return createStakeTransaction(amount, validatorAddress); + }, [amount, validatorAddress]); + + return useQuery({ + // eslint-disable-next-line @tanstack/query/exhaustive-deps + queryKey: [ + 'staking-tx-gas-budget-estimate', + senderAddress, + validatorAddress, + transaction.getData(), + ], + queryFn: async () => { + if (!senderAddress || !transaction) { + return null; + } + + transaction.setSender(senderAddress); + + await transaction.build({ client }); + + return transaction.getData().gasData.budget; + }, + }); +} diff --git a/apps/explorer/README.md b/apps/explorer/README.md index db68127e02e..bf0a1f7d657 100644 --- a/apps/explorer/README.md +++ b/apps/explorer/README.md @@ -4,7 +4,7 @@ # Set Up -**Requirements**: Node 18.0.0 or later. +**Requirements**: Node 20.0.0 or later. Dependencies are managed using [`pnpm`](https://pnpm.io/). You can start by installing dependencies in the root of the iota repository: diff --git a/apps/wallet-dashboard/README.md b/apps/wallet-dashboard/README.md index 570655b24cf..dcbab76f343 100644 --- a/apps/wallet-dashboard/README.md +++ b/apps/wallet-dashboard/README.md @@ -2,7 +2,7 @@ # Set Up -**Requirements**: Node 18.17.0 or later. +**Requirements**: Node 20.0.0 or later. Dependencies are managed using [`pnpm`](https://pnpm.io/). You can start by installing dependencies in the root of the repository: diff --git a/apps/wallet-dashboard/package.json b/apps/wallet-dashboard/package.json index 44066a00ef1..3cf781bca2f 100644 --- a/apps/wallet-dashboard/package.json +++ b/apps/wallet-dashboard/package.json @@ -12,7 +12,7 @@ "test": "jest" }, "engines": { - "node": ">= v18.17.0" + "node": ">= 20" }, "dependencies": { "@growthbook/growthbook": "^1.0.0", diff --git a/apps/wallet/README.md b/apps/wallet/README.md index 83b8ce4ed3a..2bdfd81afdc 100644 --- a/apps/wallet/README.md +++ b/apps/wallet/README.md @@ -4,7 +4,7 @@ A Chrome extension wallet for [IOTA](https://iota.org). # Set Up -**Requirements**: 18.0.0 or later. +**Requirements**: 20.0.0 or later. Dependencies are managed using [`pnpm`](https://pnpm.io/). You can start by installing dependencies in the root of the iota repository: diff --git a/apps/wallet/src/ui/app/WalletSigner.ts b/apps/wallet/src/ui/app/WalletSigner.ts index 2be83cb253e..6ed5b0a9f71 100644 --- a/apps/wallet/src/ui/app/WalletSigner.ts +++ b/apps/wallet/src/ui/app/WalletSigner.ts @@ -52,7 +52,10 @@ export abstract class WalletSigner { if (isTransaction(transaction)) { // If the sender has not yet been set on the transaction, then set it. // NOTE: This allows for signing transactions with mismatched senders, which is important for sponsored transactions. - transaction.setSenderIfNotSet(await this.getAddress()); + if (!transaction.getData().sender) { + transaction.setSender(await this.getAddress()); + } + return await transaction.build({ client: this.client, }); @@ -84,13 +87,12 @@ export abstract class WalletSigner { transactionBlock: Uint8Array | Transaction; options?: IotaTransactionBlockResponseOptions; }): Promise { - const bytes = await this.prepareTransaction(input.transactionBlock); const signed = await this.signTransaction({ - transaction: bytes, + transaction: input.transactionBlock, }); return this.client.executeTransactionBlock({ - transactionBlock: bytes, + transactionBlock: signed.bytes, signature: signed.signature, options: input.options, }); diff --git a/apps/wallet/src/ui/app/staking/stake/StakeForm.tsx b/apps/wallet/src/ui/app/staking/stake/StakeForm.tsx index 19e6617977e..83a70ef19a8 100644 --- a/apps/wallet/src/ui/app/staking/stake/StakeForm.tsx +++ b/apps/wallet/src/ui/app/staking/stake/StakeForm.tsx @@ -9,6 +9,7 @@ import { parseAmount, useCoinMetadata, useFormatCoin, + useStakingGasBudgetEstimation, } from '@iota/core'; import { Field, type FieldProps, Form, useFormikContext } from 'formik'; import { memo, useEffect, useMemo } from 'react'; @@ -36,7 +37,12 @@ function StakeForm({ validatorAddress, coinBalance, coinType, epoch }: StakeFrom if (!values.amount || !decimals) return null; if (Number(values.amount) < 0) return null; const amountWithoutDecimals = parseAmount(values.amount, decimals); - return createStakeTransaction(amountWithoutDecimals, validatorAddress); + const transaction = createStakeTransaction(amountWithoutDecimals, validatorAddress); + if (activeAddress) { + transaction.setSender(activeAddress); + } + + return transaction; }, [values.amount, validatorAddress, decimals]); const { data: txDryRunResponse } = useTransactionDryRun( @@ -46,18 +52,15 @@ function StakeForm({ validatorAddress, coinBalance, coinType, epoch }: StakeFrom const gasSummary = txDryRunResponse ? getGasSummary(txDryRunResponse) : undefined; - const stakeAllTransaction = useMemo(() => { - return createStakeTransaction(coinBalance, validatorAddress); - }, [coinBalance, validatorAddress]); - - const { data: stakeAllTransactionDryRun } = useTransactionDryRun( - activeAddress ?? undefined, - stakeAllTransaction, - ); + const { data: stakeAllGasBudget } = useStakingGasBudgetEstimation({ + senderAddress: activeAddress, + amount: coinBalance, + validatorAddress, + }); - const gasBudget = BigInt(stakeAllTransactionDryRun?.input.gasData.budget ?? 0); + const gasBudget = BigInt(stakeAllGasBudget ?? 0); - // do not remove: gasBudget field is used in the validation schema apps/wallet/src/ui/app/staking/stake/utils/validation.ts + // do not remove: gasBudget field is used in the validation schema apps/core/src/utils/stake/createValidationSchema.ts useEffect(() => { setFieldValue('gasBudget', gasBudget); }, [gasBudget]); diff --git a/bridge/evm/README.md b/bridge/evm/README.md index c295d1473f4..12ac65b3337 100644 --- a/bridge/evm/README.md +++ b/bridge/evm/README.md @@ -7,7 +7,7 @@ This project leverages [Foundry](https://github.com/foundry-rs/foundry) to manag Duplicate rename the `.env.example` file to `.env`. You'll need accounts and api keys for **Infura** and **Etherscan** as well as the necessary RPC URLs. Be sure to add the required values in your newly created `.env` file. > **Note** -> The OZ foundry upgrades library uses node to verify upgrade safety. Make sure you have node version 18.17 or higher as well as npm version 10.4 or higher installed. +> The OZ foundry upgrades library uses node to verify upgrade safety. Make sure you have node version 20.0.0 or higher as well as npm version 10.4 or higher installed. #### Dependencies diff --git a/crates/iota-rosetta/README.md b/crates/iota-rosetta/README.md index 06d8d16afd8..ae79306cb62 100644 --- a/crates/iota-rosetta/README.md +++ b/crates/iota-rosetta/README.md @@ -45,7 +45,7 @@ This will generate the `rosetta-cli.json` and `iota.ros` file to be used by the #### 1. CD into the Dockerfile directory ```shell -cd /crate/iota-rosetta/docker/iota-rosetta-local +cd /docker/iota-rosetta-local ``` #### 2. Build the image diff --git a/crates/iota-rosetta/docker/iota-rosetta-devnet/Dockerfile b/crates/iota-rosetta/docker/iota-rosetta-devnet/Dockerfile deleted file mode 100644 index 9f5c85f10ab..00000000000 --- a/crates/iota-rosetta/docker/iota-rosetta-devnet/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -FROM ubuntu:latest AS chef -WORKDIR iota -ARG GIT_REVISION -ENV GIT_REVISION=$GIT_REVISION -RUN apt-get update && apt-get install -y build-essential libssl-dev pkg-config curl cmake clang git ca-certificates -RUN curl https://sh.rustup.rs -sSf | bash -s -- -y -ENV PATH="/root/.cargo/bin:${PATH}" - -FROM chef AS builder - -RUN git clone https://github.com/iotaledger/iota . -RUN git checkout devnet - -RUN curl -sSfL https://raw.githubusercontent.com/coinbase/rosetta-cli/master/scripts/install.sh | sh -s -RUN curl -fLJO https://github.com/iotaledger/iota-genesis/raw/main/devnet/genesis.blob - -RUN cargo build --release --bin iota --bin iota-rosetta --bin iota-node - -# Production Image -FROM ubuntu:latest AS runtime -WORKDIR iota -RUN apt-get update && apt-get install -y ca-certificates -COPY --from=builder /iota/target/release/iota /usr/local/bin -COPY --from=builder /iota/target/release/iota-node /usr/local/bin -COPY --from=builder /iota/target/release/iota-rosetta /usr/local/bin -COPY --from=builder /iota/bin/rosetta-cli /usr/local/bin -COPY --from=builder /iota/crates/iota-config/data/fullnode-template.yaml /iota/devnet/fullnode.yaml -COPY --from=builder /iota/genesis.blob /iota/devnet/genesis.blob -RUN /usr/local/bin/iota genesis - -ARG BUILD_DATE -LABEL build-date=$BUILD_DATE -LABEL git-revision=$GIT_REVISION diff --git a/crates/iota-rosetta/docker/iota-rosetta-devnet/build.sh b/crates/iota-rosetta/docker/iota-rosetta-devnet/build.sh deleted file mode 100755 index 5c618a0b863..00000000000 --- a/crates/iota-rosetta/docker/iota-rosetta-devnet/build.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# Copyright (c) Mysten Labs, Inc. -# Modifications Copyright (c) 2024 IOTA Stiftung -# SPDX-License-Identifier: Apache-2.0 - -# fast fail. -set -e - -DIR="$( cd "$( dirname "$0" )" && pwd )" -REPO_ROOT="$(git rev-parse --show-toplevel)" -DOCKERFILE="$DIR/Dockerfile" -GIT_REVISION="$(git describe --always --abbrev=12 --dirty --exclude '*')" -BUILD_DATE="$(date -u +'%Y-%m-%d')" - -echo -echo "Building iota-rosetta docker image" -echo "Dockerfile: \t$DOCKERFILE" -echo "docker context: $REPO_ROOT" -echo "build date: \t$BUILD_DATE" -echo "git revision: \t$GIT_REVISION" -echo - -docker build -f "$DOCKERFILE" "$REPO_ROOT" \ - -t iotaledger/iota-rosetta-devnet \ - --build-arg GIT_REVISION="$GIT_REVISION" \ - --build-arg BUILD_DATE="$BUILD_DATE" \ - "$@" diff --git a/crates/iota-rosetta/docker/iota-rosetta-local/Dockerfile b/crates/iota-rosetta/docker/iota-rosetta-local/Dockerfile deleted file mode 100644 index 9a30acfef66..00000000000 --- a/crates/iota-rosetta/docker/iota-rosetta-local/Dockerfile +++ /dev/null @@ -1,35 +0,0 @@ -FROM ubuntu:latest AS chef -WORKDIR iota -ARG GIT_REVISION -ENV GIT_REVISION=$GIT_REVISION -RUN apt-get update && apt-get install -y build-essential libssl-dev pkg-config curl cmake clang ca-certificates -RUN curl https://sh.rustup.rs -sSf | bash -s -- -y -ENV PATH="/root/.cargo/bin:${PATH}" - -# Build application -FROM chef AS builder - -RUN curl -sSfL https://raw.githubusercontent.com/coinbase/rosetta-cli/master/scripts/install.sh | sh -s - -COPY Cargo.toml Cargo.lock ./ -COPY consensus consensus -COPY crates crates -COPY iota-execution iota-execution -COPY external-crates external-crates -COPY docs docs - -RUN cargo build --release --bin iota --bin iota-rosetta - -# Production Image -FROM ubuntu:latest AS runtime -WORKDIR iota -RUN apt-get update && apt-get install -y ca-certificates -COPY --from=builder /iota/target/release/iota /usr/local/bin -COPY --from=builder /iota/target/release/iota-rosetta /usr/local/bin -COPY --from=builder /iota/bin/rosetta-cli /usr/local/bin -COPY --from=builder /iota/crates/iota-config/data/fullnode-template.yaml /iota/devnet/fullnode.yaml -RUN /usr/local/bin/iota genesis - -ARG BUILD_DATE -LABEL build-date=$BUILD_DATE -LABEL git-revision=$GIT_REVISION diff --git a/crates/iota-rosetta/docker/iota-rosetta-local/build.sh b/crates/iota-rosetta/docker/iota-rosetta-local/build.sh deleted file mode 100755 index 5fd6e8c8645..00000000000 --- a/crates/iota-rosetta/docker/iota-rosetta-local/build.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# Copyright (c) Mysten Labs, Inc. -# Modifications Copyright (c) 2024 IOTA Stiftung -# SPDX-License-Identifier: Apache-2.0 - -# fast fail. -set -e - -DIR="$( cd "$( dirname "$0" )" && pwd )" -REPO_ROOT="$(git rev-parse --show-toplevel)" -DOCKERFILE="$DIR/Dockerfile" -GIT_REVISION="$(git describe --always --abbrev=12 --dirty --exclude '*')" -BUILD_DATE="$(date -u +'%Y-%m-%d')" - -echo -echo "Building iota-rosetta docker image" -echo "Dockerfile: \t$DOCKERFILE" -echo "docker context: $REPO_ROOT" -echo "build date: \t$BUILD_DATE" -echo "git revision: \t$GIT_REVISION" -echo - -docker build -f "$DOCKERFILE" "$REPO_ROOT" \ - -t iotaledger/iota-rosetta-local \ - --build-arg GIT_REVISION="$GIT_REVISION" \ - --build-arg BUILD_DATE="$BUILD_DATE" \ - "$@" diff --git a/dapps/kiosk-cli/index.js b/dapps/kiosk-cli/index.js index aff1f965b12..b86a4d698b1 100644 --- a/dapps/kiosk-cli/index.js +++ b/dapps/kiosk-cli/index.js @@ -35,7 +35,7 @@ import { import { bcs } from '@iota/iota-sdk/bcs'; import { program } from 'commander'; import { KIOSK_LISTING, KioskClient, KioskTransaction } from '@iota/kiosk'; -import { IotaClient, getFullnodeUrl } from '@iota/iota-sdk/client'; +import { IotaClient, getFullnodeUrl, Network } from '@iota/iota-sdk/client'; import { Ed25519Keypair } from '@iota/iota-sdk/keypairs/ed25519'; import { Transaction } from '@iota/iota-sdk/transactions'; @@ -45,11 +45,11 @@ import { Transaction } from '@iota/iota-sdk/transactions'; const KNOWN_TYPES = {}; /** JsonRpcProvider for the Testnet */ -const client = new IotaClient({ url: getFullnodeUrl('testnet') }); +const client = new IotaClient({ url: getFullnodeUrl(Network.Testnet) }); const kioskClient = new KioskClient({ client, - network: 'testnet', + network: Network.Testnet, }); /** diff --git a/docker/iota-bridge-indexer/Dockerfile b/docker/iota-bridge-indexer/Dockerfile index 6c74d925bee..9dd2957ed93 100644 --- a/docker/iota-bridge-indexer/Dockerfile +++ b/docker/iota-bridge-indexer/Dockerfile @@ -1,40 +1,61 @@ -# Build application -# -# Copy in all crates, Cargo.toml and Cargo.lock unmodified, -# and build the application. -FROM rust:bullseye AS builder +# Build image (the specific rust version can also be passed, e.g. "1.82-bookworm") +ARG RUST_IMAGE_VERSION=bookworm +FROM rust:${RUST_IMAGE_VERSION} AS builder + ARG PROFILE=release +ARG CARGO_BUILD_FEATURES +# The GIT_REVISION environment variable is used during build time inside the rust crates ARG GIT_REVISION ENV GIT_REVISION=$GIT_REVISION -WORKDIR "$WORKDIR/iota" -RUN apt-get update && apt-get install -y cmake clang +WORKDIR "/iota" -# bridge-indexer needs postgres libpq5 and ca-certificates -RUN apt update && apt install -y libpq5 ca-certificates libpq-dev postgresql +# Install build dependencies, including clang and lld for faster linking +RUN apt update && apt install -y cmake clang lld -COPY Cargo.toml Cargo.lock ./ +# Configure Rust to use clang and lld as the linker +RUN mkdir -p ~/.cargo && \ + echo -e "[target.x86_64-unknown-linux-gnu]\nlinker = \"clang\"\nrustflags = [\"-C\", \"link-arg=-fuse-ld=lld\"]" > ~/.cargo/config.toml + +# Install additional dependencies +RUN apt install -y libpq5 libpq-dev ca-certificates + +# Copy in all crates, Cargo.toml, and Cargo.lock COPY consensus consensus COPY crates crates -COPY iota-execution iota-execution -COPY external-crates external-crates COPY docs docs +COPY external-crates external-crates +COPY iota-execution iota-execution +COPY Cargo.toml Cargo.lock ./ + +RUN cargo build --profile ${PROFILE} --bin bridge-indexer --features ${CARGO_BUILD_FEATURES:=default} + +# Copy the built binary to the working directory depending on the output folder of the profile, +# so we can copy it to the runtime image +RUN if [ -d target/release ]; then \ + TARGET_DIR="target/release"; \ +elif [ -d target/debug ]; then \ + TARGET_DIR="target/debug"; \ +else \ + echo "Error: No build directory found"; \ + exit 1; \ +fi && \ +mv $TARGET_DIR/bridge-indexer ./; -RUN cargo build --profile ${PROFILE} --bin bridge-indexer +# Production image +FROM debian:bookworm-slim AS runtime -# Copy the built binary to the working directory depending on the profile, so we can copy it to the runtime image -RUN mv target/$(if [ $PROFILE = "dev" ]; then echo "debug"; else echo "release";fi)/bridge-indexer ./ +ARG WORKDIR="/iota" +WORKDIR "$WORKDIR" -# Production Image -FROM debian:bullseye-slim AS runtime +# Install runtime dependencies and tools +RUN apt update && apt install -y libpq5 ca-certificates curl -# Use jemalloc as memory allocator -RUN apt-get update && apt-get install -y libjemalloc-dev ca-certificates curl +# Install jemalloc as the default allocator +RUN apt install -y libjemalloc-dev ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libjemalloc.so -WORKDIR "$WORKDIR/iota" COPY --from=builder /iota/bridge-indexer /usr/local/bin -RUN apt update && apt install -y libpq5 ca-certificates libpq-dev postgresql ARG BUILD_DATE ARG GIT_REVISION diff --git a/docker/iota-bridge-indexer/build.sh b/docker/iota-bridge-indexer/build.sh index 182f6351352..4d30b49572e 100755 --- a/docker/iota-bridge-indexer/build.sh +++ b/docker/iota-bridge-indexer/build.sh @@ -1,26 +1,5 @@ -#!/bin/sh +#!/bin/bash # Copyright (c) Mysten Labs, Inc. # Modifications Copyright (c) 2024 IOTA Stiftung # SPDX-License-Identifier: Apache-2.0 - -# fast fail. -set -e - -DIR="$( cd "$( dirname "$0" )" && pwd )" -REPO_ROOT="$(git rev-parse --show-toplevel)" -DOCKERFILE="$DIR/Dockerfile" -GIT_REVISION="$(git describe --always --abbrev=12 --dirty --exclude '*')" -BUILD_DATE="$(date -u +'%Y-%m-%d')" - -echo -echo "Building bridge-indexer docker image" -echo "Dockerfile: \t$DOCKERFILE" -echo "docker context: $REPO_ROOT" -echo "build date: \t$BUILD_DATE" -echo "git revision: \t$GIT_REVISION" -echo - -docker build -f "$DOCKERFILE" "$REPO_ROOT" \ - --build-arg GIT_REVISION="$GIT_REVISION" \ - --build-arg BUILD_DATE="$BUILD_DATE" \ - "$@" +./../utils/build-script.sh --container-name "iotaledger/bridge-indexer" diff --git a/docker/iota-graphql-rpc/Dockerfile b/docker/iota-graphql-rpc/Dockerfile index 35328801595..b23d4215768 100644 --- a/docker/iota-graphql-rpc/Dockerfile +++ b/docker/iota-graphql-rpc/Dockerfile @@ -1,34 +1,57 @@ -# Build application -# -# Copy in all crates, Cargo.toml and Cargo.lock unmodified, -# and build the application. -FROM rust:bullseye AS builder +# Build image (the specific rust version can also be passed, e.g. "1.82-bookworm") +ARG RUST_IMAGE_VERSION=bookworm +FROM rust:${RUST_IMAGE_VERSION} AS builder + ARG PROFILE=release -ENV PROFILE=$PROFILE +ARG CARGO_BUILD_FEATURES +# The GIT_REVISION environment variable is used during build time inside the rust crates ARG GIT_REVISION ENV GIT_REVISION=$GIT_REVISION -WORKDIR "$WORKDIR/iota" -RUN apt-get update && apt-get install -y cmake clang libpq-dev -COPY Cargo.toml Cargo.lock ./ +WORKDIR "/iota" + +# Install build dependencies, including clang and lld for faster linking +RUN apt update && apt install -y cmake clang lld + +# Configure Rust to use clang and lld as the linker +RUN mkdir -p ~/.cargo && \ + echo -e "[target.x86_64-unknown-linux-gnu]\nlinker = \"clang\"\nrustflags = [\"-C\", \"link-arg=-fuse-ld=lld\"]" > ~/.cargo/config.toml + +# Install additional dependencies +RUN apt install -y libpq5 libpq-dev ca-certificates + +# Copy in all crates, Cargo.toml, and Cargo.lock COPY consensus consensus COPY crates crates -COPY iota-execution iota-execution -COPY external-crates external-crates COPY docs docs +COPY external-crates external-crates +COPY iota-execution iota-execution +COPY Cargo.toml Cargo.lock ./ + +RUN cargo build --profile ${PROFILE} --bin iota-graphql-rpc --features ${CARGO_BUILD_FEATURES:=default} + +# Copy the built binary to the working directory depending on the output folder of the profile, +# so we can copy it to the runtime image +RUN if [ -d target/release ]; then \ + TARGET_DIR="target/release"; \ +elif [ -d target/debug ]; then \ + TARGET_DIR="target/debug"; \ +else \ + echo "Error: No build directory found"; \ + exit 1; \ +fi && \ +mv $TARGET_DIR/iota-graphql-rpc ./; + +# Production image +FROM debian:bookworm-slim AS runtime -RUN cargo build --profile ${PROFILE} --bin iota-graphql-rpc +ARG WORKDIR="/iota" +WORKDIR "$WORKDIR" -# Copy the built binary to the working directory depending on the profile, so we can copy it to the runtime image -RUN mv target/$(if [ $PROFILE = "dev" ]; then echo "debug"; else echo "release";fi)/iota-graphql-rpc ./ +# Install runtime dependencies and tools +RUN apt update && apt install -y libpq5 ca-certificates curl -# Production Image -FROM debian:bullseye-slim AS runtime -WORKDIR "$WORKDIR/iota" -# Both bench and release profiles copy from release dir -RUN mkdir -p /opt/iota/bin -COPY --from=builder /iota/iota-graphql-rpc /opt/iota/bin -RUN apt-get update && apt-get install -y libpq5 ca-certificates libpq-dev postgresql +COPY --from=builder /iota/iota-graphql-rpc /usr/local/bin ARG BUILD_DATE ARG GIT_REVISION diff --git a/docker/iota-graphql-rpc/build.sh b/docker/iota-graphql-rpc/build.sh index 8c87780e6ae..77f244d55a6 100755 --- a/docker/iota-graphql-rpc/build.sh +++ b/docker/iota-graphql-rpc/build.sh @@ -1,36 +1,5 @@ -#!/bin/sh +#!/bin/bash # Copyright (c) Mysten Labs, Inc. # Modifications Copyright (c) 2024 IOTA Stiftung # SPDX-License-Identifier: Apache-2.0 - -# fast fail. -set -e - -DIR="$( cd "$( dirname "$0" )" && pwd )" -REPO_ROOT="$(git rev-parse --show-toplevel)" -DOCKERFILE="$DIR/Dockerfile" -GIT_REVISION="$(git describe --always --abbrev=12 --dirty --exclude '*')" -BUILD_DATE="$(date -u +'%Y-%m-%d')" - -# option to build using debug symbols -if [ "$1" = "--debug-symbols" ]; then - PROFILE="bench" - echo "Building with full debug info enabled ... WARNING: binary size might significantly increase" - shift -else - PROFILE="release" -fi - -echo -echo "Building iota-graphql-rpc docker image" -echo "Dockerfile: \t$DOCKERFILE" -echo "docker context: $REPO_ROOT" -echo "build date: \t$BUILD_DATE" -echo "git revision: \t$GIT_REVISION" -echo - -docker build -f "$DOCKERFILE" "$REPO_ROOT" \ - --build-arg GIT_REVISION="$GIT_REVISION" \ - --build-arg BUILD_DATE="$BUILD_DATE" \ - --build-arg PROFILE="$PROFILE" \ - "$@" +./../utils/build-script.sh --container-name "iotaledger/iota-graphql-rpc" diff --git a/docker/iota-indexer-tidb/Dockerfile b/docker/iota-indexer-tidb/Dockerfile index 8816caee5ac..269f4a439f8 100644 --- a/docker/iota-indexer-tidb/Dockerfile +++ b/docker/iota-indexer-tidb/Dockerfile @@ -1,40 +1,61 @@ -# Build application -# -# Copy in all crates, Cargo.toml and Cargo.lock unmodified, -# and build the application. -FROM rust:bullseye AS builder +# Build image (the specific rust version can also be passed, e.g. "1.82-bookworm") +ARG RUST_IMAGE_VERSION=bookworm +FROM rust:${RUST_IMAGE_VERSION} AS builder + ARG PROFILE=release +ARG CARGO_BUILD_FEATURES +# The GIT_REVISION environment variable is used during build time inside the rust crates ARG GIT_REVISION ENV GIT_REVISION=$GIT_REVISION -WORKDIR "$WORKDIR/iota" -RUN apt-get update && apt-get install -y cmake clang +WORKDIR "/iota" -# iota-indexer needs postgres libpq5 and ca-certificates -RUN apt update && apt install -y libpq5 ca-certificates libpq-dev postgresql +# Install build dependencies, including clang and lld for faster linking +RUN apt update && apt install -y cmake clang lld -COPY Cargo.toml Cargo.lock ./ +# Configure Rust to use clang and lld as the linker +RUN mkdir -p ~/.cargo && \ + echo -e "[target.x86_64-unknown-linux-gnu]\nlinker = \"clang\"\nrustflags = [\"-C\", \"link-arg=-fuse-ld=lld\"]" > ~/.cargo/config.toml + +# Install additional dependencies +RUN apt install -y libpq5 libpq-dev ca-certificates + +# Copy in all crates, Cargo.toml, and Cargo.lock COPY consensus consensus COPY crates crates -COPY iota-execution iota-execution -COPY external-crates external-crates COPY docs docs +COPY external-crates external-crates +COPY iota-execution iota-execution +COPY Cargo.toml Cargo.lock ./ RUN cargo build --profile ${PROFILE} --bin iota-indexer --features mysql-feature --no-default-features -# Copy the built binary to the working directory depending on the profile, so we can copy it to the runtime image -RUN mv target/$(if [ $PROFILE = "dev" ]; then echo "debug"; else echo "release";fi)/iota-indexer ./ - -# Production Image -FROM debian:bullseye-slim AS runtime - -# Use jemalloc as memory allocator -RUN apt-get update && apt-get install -y libjemalloc-dev ca-certificates curl +# Copy the built binary to the working directory depending on the output folder of the profile, +# so we can copy it to the runtime image +RUN if [ -d target/release ]; then \ + TARGET_DIR="target/release"; \ +elif [ -d target/debug ]; then \ + TARGET_DIR="target/debug"; \ +else \ + echo "Error: No build directory found"; \ + exit 1; \ +fi && \ +mv $TARGET_DIR/iota-indexer ./; + +# Production image +FROM debian:bookworm-slim AS runtime + +ARG WORKDIR="/iota" +WORKDIR "$WORKDIR" + +# Install runtime dependencies and tools +RUN apt update && apt install -y libpq5 ca-certificates curl + +# Install jemalloc as the default allocator +RUN apt install -y libjemalloc-dev ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libjemalloc.so -WORKDIR "$WORKDIR/iota" COPY --from=builder /iota/iota-indexer /usr/local/bin -RUN apt update && apt install -y libpq5 ca-certificates libpq-dev postgresql ARG BUILD_DATE ARG GIT_REVISION diff --git a/docker/iota-indexer-tidb/build.sh b/docker/iota-indexer-tidb/build.sh index fc599bfe6bf..6181a041b52 100755 --- a/docker/iota-indexer-tidb/build.sh +++ b/docker/iota-indexer-tidb/build.sh @@ -1,26 +1,5 @@ -#!/bin/sh +#!/bin/bash # Copyright (c) Mysten Labs, Inc. # Modifications Copyright (c) 2024 IOTA Stiftung # SPDX-License-Identifier: Apache-2.0 - -# fast fail. -set -e - -DIR="$( cd "$( dirname "$0" )" && pwd )" -REPO_ROOT="$(git rev-parse --show-toplevel)" -DOCKERFILE="$DIR/Dockerfile" -GIT_REVISION="$(git describe --always --abbrev=12 --dirty --exclude '*')" -BUILD_DATE="$(date -u +'%Y-%m-%d')" - -echo -echo "Building iota-indexer-tidb docker image" -echo "Dockerfile: \t$DOCKERFILE" -echo "docker context: $REPO_ROOT" -echo "build date: \t$BUILD_DATE" -echo "git revision: \t$GIT_REVISION" -echo - -docker build -f "$DOCKERFILE" "$REPO_ROOT" \ - --build-arg GIT_REVISION="$GIT_REVISION" \ - --build-arg BUILD_DATE="$BUILD_DATE" \ - "$@" +./../utils/build-script.sh --container-name "iotaledger/iota-indexer-tidb" diff --git a/docker/iota-indexer/Dockerfile b/docker/iota-indexer/Dockerfile index 5f7dbb450f6..528be6a7aed 100644 --- a/docker/iota-indexer/Dockerfile +++ b/docker/iota-indexer/Dockerfile @@ -1,40 +1,61 @@ -# Build application -# -# Copy in all crates, Cargo.toml and Cargo.lock unmodified, -# and build the application. -FROM rust:bullseye AS builder +# Build image (the specific rust version can also be passed, e.g. "1.82-bookworm") +ARG RUST_IMAGE_VERSION=bookworm +FROM rust:${RUST_IMAGE_VERSION} AS builder + ARG PROFILE=release +ARG CARGO_BUILD_FEATURES +# The GIT_REVISION environment variable is used during build time inside the rust crates ARG GIT_REVISION ENV GIT_REVISION=$GIT_REVISION -WORKDIR "$WORKDIR/iota" -RUN apt-get update && apt-get install -y cmake clang +WORKDIR "/iota" -# iota-indexer needs postgres libpq5 and ca-certificates -RUN apt update && apt install -y libpq5 ca-certificates libpq-dev postgresql +# Install build dependencies, including clang and lld for faster linking +RUN apt update && apt install -y cmake clang lld -COPY Cargo.toml Cargo.lock ./ +# Configure Rust to use clang and lld as the linker +RUN mkdir -p ~/.cargo && \ + echo -e "[target.x86_64-unknown-linux-gnu]\nlinker = \"clang\"\nrustflags = [\"-C\", \"link-arg=-fuse-ld=lld\"]" > ~/.cargo/config.toml + +# Install additional dependencies +RUN apt install -y libpq5 libpq-dev ca-certificates + +# Copy in all crates, Cargo.toml, and Cargo.lock COPY consensus consensus COPY crates crates -COPY iota-execution iota-execution -COPY external-crates external-crates COPY docs docs +COPY external-crates external-crates +COPY iota-execution iota-execution +COPY Cargo.toml Cargo.lock ./ + +RUN cargo build --profile ${PROFILE} --bin iota-indexer --features ${CARGO_BUILD_FEATURES:=default} + +# Copy the built binary to the working directory depending on the output folder of the profile, +# so we can copy it to the runtime image +RUN if [ -d target/release ]; then \ + TARGET_DIR="target/release"; \ +elif [ -d target/debug ]; then \ + TARGET_DIR="target/debug"; \ +else \ + echo "Error: No build directory found"; \ + exit 1; \ +fi && \ +mv $TARGET_DIR/iota-indexer ./; -RUN cargo build --profile ${PROFILE} --bin iota-indexer +# Production image +FROM debian:bookworm-slim AS runtime -# Copy the built binary to the working directory depending on the profile, so we can copy it to the runtime image -RUN mv target/$(if [ $PROFILE = "dev" ]; then echo "debug"; else echo "release";fi)/iota-indexer ./ +ARG WORKDIR="/iota" +WORKDIR "$WORKDIR" -# Production Image -FROM debian:bullseye-slim AS runtime +# Install runtime dependencies and tools +RUN apt update && apt install -y libpq5 ca-certificates curl -# Use jemalloc as memory allocator -RUN apt-get update && apt-get install -y libjemalloc-dev ca-certificates curl +# Install jemalloc as the default allocator +RUN apt install -y libjemalloc-dev ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libjemalloc.so -WORKDIR "$WORKDIR/iota" COPY --from=builder /iota/iota-indexer /usr/local/bin -RUN apt update && apt install -y libpq5 ca-certificates libpq-dev postgresql ARG BUILD_DATE ARG GIT_REVISION diff --git a/docker/iota-indexer/build.sh b/docker/iota-indexer/build.sh index a34a1f3f36e..e264587834f 100755 --- a/docker/iota-indexer/build.sh +++ b/docker/iota-indexer/build.sh @@ -1,26 +1,5 @@ -#!/bin/sh +#!/bin/bash # Copyright (c) Mysten Labs, Inc. # Modifications Copyright (c) 2024 IOTA Stiftung # SPDX-License-Identifier: Apache-2.0 - -# fast fail. -set -e - -DIR="$( cd "$( dirname "$0" )" && pwd )" -REPO_ROOT="$(git rev-parse --show-toplevel)" -DOCKERFILE="$DIR/Dockerfile" -GIT_REVISION="$(git describe --always --abbrev=12 --dirty --exclude '*')" -BUILD_DATE="$(date -u +'%Y-%m-%d')" - -echo -echo "Building iota-indexer docker image" -echo "Dockerfile: \t$DOCKERFILE" -echo "docker context: $REPO_ROOT" -echo "build date: \t$BUILD_DATE" -echo "git revision: \t$GIT_REVISION" -echo - -docker build -f "$DOCKERFILE" "$REPO_ROOT" \ - --build-arg GIT_REVISION="$GIT_REVISION" \ - --build-arg BUILD_DATE="$BUILD_DATE" \ - "$@" +./../utils/build-script.sh --container-name "iotaledger/iota-indexer" diff --git a/docker/iota-node-deterministic/Dockerfile b/docker/iota-node-deterministic/Dockerfile index 69220003dd5..ec48977018e 100644 --- a/docker/iota-node-deterministic/Dockerfile +++ b/docker/iota-node-deterministic/Dockerfile @@ -37,7 +37,7 @@ COPY --from=ca-certificates . / COPY . /iota -WORKDIR iota +WORKDIR "/iota" RUN cargo fetch diff --git a/docker/iota-node/Dockerfile b/docker/iota-node/Dockerfile index 9e6f8589172..cb935142d89 100644 --- a/docker/iota-node/Dockerfile +++ b/docker/iota-node/Dockerfile @@ -1,40 +1,60 @@ -# Build application -# -# Copy in all crates, Cargo.toml and Cargo.lock unmodified, -# and build the application. -FROM rust:bullseye AS builder +# Build image (the specific rust version can also be passed, e.g. "1.82-bookworm") +ARG RUST_IMAGE_VERSION=bookworm +FROM rust:${RUST_IMAGE_VERSION} AS builder + ARG PROFILE=release +ARG CARGO_BUILD_FEATURES +# The GIT_REVISION environment variable is used during build time inside the rust crates ARG GIT_REVISION ENV GIT_REVISION=$GIT_REVISION -WORKDIR "$WORKDIR/iota" -RUN apt-get update && apt-get install -y cmake clang +WORKDIR "/iota" -COPY Cargo.toml Cargo.lock ./ +# Install build dependencies, including clang and lld for faster linking +RUN apt update && apt install -y cmake clang lld + +# Configure Rust to use clang and lld as the linker +RUN mkdir -p ~/.cargo && \ + echo -e "[target.x86_64-unknown-linux-gnu]\nlinker = \"clang\"\nrustflags = [\"-C\", \"link-arg=-fuse-ld=lld\"]" > ~/.cargo/config.toml + +# Install additional dependencies +RUN apt install -y libpq5 libpq-dev ca-certificates + +# Copy in all crates, Cargo.toml, and Cargo.lock COPY consensus consensus COPY crates crates -COPY iota-execution iota-execution -COPY external-crates external-crates COPY docs docs +COPY external-crates external-crates +COPY iota-execution iota-execution +COPY Cargo.toml Cargo.lock ./ -RUN cargo build --profile ${PROFILE} --bin iota-node +RUN cargo build --profile ${PROFILE} --bin iota-node --features ${CARGO_BUILD_FEATURES:=default} -# Copy the built binary to the working directory depending on the profile, so we can copy it to the runtime image -RUN mv target/$(if [ $PROFILE = "dev" ]; then echo "debug"; else echo "release";fi)/iota-node ./ +# Copy the built binary to the working directory depending on the output folder of the profile, +# so we can copy it to the runtime image +RUN if [ -d target/release ]; then \ + TARGET_DIR="target/release"; \ +elif [ -d target/debug ]; then \ + TARGET_DIR="target/debug"; \ +else \ + echo "Error: No build directory found"; \ + exit 1; \ +fi && \ +mv $TARGET_DIR/iota-node ./; -# Production Image -FROM debian:bullseye-slim AS runtime +# Production image +FROM debian:bookworm-slim AS runtime -# Use jemalloc as memory allocator -RUN apt-get update && apt-get install -y libjemalloc-dev ca-certificates curl -ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libjemalloc.so +ARG WORKDIR="/iota" +WORKDIR "$WORKDIR" -WORKDIR "$WORKDIR/iota" +# Install runtime dependencies and tools +RUN apt update && apt install -y libpq5 ca-certificates curl -# Both bench and release profiles copy from release dir -COPY --from=builder /iota/iota-node /opt/iota/bin/iota-node +# Install jemalloc as the default allocator +RUN apt install -y libjemalloc-dev +ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libjemalloc.so -# Support legacy usages of /usr/local/bin/iota-node COPY --from=builder /iota/iota-node /usr/local/bin ARG BUILD_DATE diff --git a/docker/iota-node/build.sh b/docker/iota-node/build.sh index 2ec1541ab25..a0d732ffc24 100755 --- a/docker/iota-node/build.sh +++ b/docker/iota-node/build.sh @@ -1,36 +1,5 @@ -#!/bin/sh +#!/bin/bash # Copyright (c) Mysten Labs, Inc. # Modifications Copyright (c) 2024 IOTA Stiftung # SPDX-License-Identifier: Apache-2.0 - -# fast fail. -set -e - -DIR="$( cd "$( dirname "$0" )" && pwd )" -REPO_ROOT="$(git rev-parse --show-toplevel)" -DOCKERFILE="$DIR/Dockerfile" -GIT_REVISION="$(git describe --always --abbrev=12 --dirty --exclude '*')" -BUILD_DATE="$(date -u +'%Y-%m-%d')" - -# option to build using debug symbols -if [ "$1" = "--debug-symbols" ]; then - PROFILE="bench" - echo "Building with full debug info enabled ... WARNING: binary size might significantly increase" - shift -else - PROFILE="release" -fi - -echo -echo "Building iota-node docker image" -echo "Dockerfile: \t$DOCKERFILE" -echo "docker context: $REPO_ROOT" -echo "build date: \t$BUILD_DATE" -echo "git revision: \t$GIT_REVISION" -echo - -docker build -f "$DOCKERFILE" "$REPO_ROOT" \ - --build-arg GIT_REVISION="$GIT_REVISION" \ - --build-arg BUILD_DATE="$BUILD_DATE" \ - --build-arg PROFILE="$PROFILE" \ - "$@" +./../utils/build-script.sh --container-name "iotaledger/iota-node" diff --git a/docker/iota-rosetta-devnet/Dockerfile b/docker/iota-rosetta-devnet/Dockerfile new file mode 100644 index 00000000000..ff74ef77e5c --- /dev/null +++ b/docker/iota-rosetta-devnet/Dockerfile @@ -0,0 +1,68 @@ +# Build image (the specific rust version can also be passed, e.g. "1.82-bookworm") +ARG RUST_IMAGE_VERSION=bookworm +FROM rust:${RUST_IMAGE_VERSION} AS builder + +ARG PROFILE=release +ARG CARGO_BUILD_FEATURES +# The GIT_REVISION environment variable is used during build time inside the rust crates +ARG GIT_REVISION +ENV GIT_REVISION=$GIT_REVISION + +WORKDIR "/iota" + +# Install build dependencies, including clang and lld for faster linking +RUN apt update && apt install -y cmake clang lld git + +# Configure Rust to use clang and lld as the linker +RUN mkdir -p ~/.cargo && \ + echo -e "[target.x86_64-unknown-linux-gnu]\nlinker = \"clang\"\nrustflags = [\"-C\", \"link-arg=-fuse-ld=lld\"]" > ~/.cargo/config.toml + +# Install additional dependencies +RUN apt install -y libpq5 libpq-dev ca-certificates + +# Clone the repository and checkout the devnet branch +RUN git clone https://github.com/iotaledger/iota . +RUN git checkout devnet + +RUN cargo build --profile ${PROFILE} \ + --bin iota \ + --bin iota-rosetta \ + --features ${CARGO_BUILD_FEATURES:=default} + +# Copy the built binary to the working directory depending on the output folder of the profile, +# so we can copy it to the runtime image +RUN if [ -d target/release ]; then \ + TARGET_DIR="target/release"; \ +elif [ -d target/debug ]; then \ + TARGET_DIR="target/debug"; \ +else \ + echo "Error: No build directory found"; \ + exit 1; \ +fi && \ +mv $TARGET_DIR/iota ./ && \ +mv $TARGET_DIR/iota-rosetta ./; + +# Production image +FROM debian:bookworm-slim AS runtime + +ARG WORKDIR="/iota" +WORKDIR "$WORKDIR" + +# Install runtime dependencies and tools +RUN apt update && apt install -y libpq5 ca-certificates curl + +# Install rosetta-cli +RUN curl -sSfL https://raw.githubusercontent.com/coinbase/rosetta-cli/master/scripts/install.sh | sh -s + +# Download the genesis file and create the genesis state +RUN mkdir -p devnet && curl -fL -o devnet/genesis.blob https://github.com/iotaledger/iota-genesis/raw/main/devnet/genesis.blob + +COPY --from=builder /iota/iota /usr/local/bin +COPY --from=builder /iota/iota-rosetta /usr/local/bin +COPY --from=builder /iota/crates/iota-config/data/fullnode-template.yaml /iota/devnet/fullnode.yaml +RUN /usr/local/bin/iota genesis + +ARG BUILD_DATE +ARG GIT_REVISION +LABEL build-date=$BUILD_DATE +LABEL git-revision=$GIT_REVISION diff --git a/docker/iota-rosetta-devnet/build.sh b/docker/iota-rosetta-devnet/build.sh new file mode 100755 index 00000000000..2bbe14ee607 --- /dev/null +++ b/docker/iota-rosetta-devnet/build.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Copyright (c) Mysten Labs, Inc. +# Modifications Copyright (c) 2024 IOTA Stiftung +# SPDX-License-Identifier: Apache-2.0 +./../../docker/utils/build-script.sh --container-name "iotaledger/iota-rosetta-devnet" diff --git a/crates/iota-rosetta/docker/iota-rosetta-devnet/docker-compose.yaml b/docker/iota-rosetta-devnet/docker-compose.yaml similarity index 100% rename from crates/iota-rosetta/docker/iota-rosetta-devnet/docker-compose.yaml rename to docker/iota-rosetta-devnet/docker-compose.yaml diff --git a/crates/iota-rosetta/docker/iota-rosetta-devnet/remote/docker-compose.yaml b/docker/iota-rosetta-devnet/remote/docker-compose.yaml similarity index 100% rename from crates/iota-rosetta/docker/iota-rosetta-devnet/remote/docker-compose.yaml rename to docker/iota-rosetta-devnet/remote/docker-compose.yaml diff --git a/docker/iota-rosetta-local/Dockerfile b/docker/iota-rosetta-local/Dockerfile new file mode 100644 index 00000000000..78b7ccb4317 --- /dev/null +++ b/docker/iota-rosetta-local/Dockerfile @@ -0,0 +1,69 @@ +# Build image (the specific rust version can also be passed, e.g. "1.82-bookworm") +ARG RUST_IMAGE_VERSION=bookworm +FROM rust:${RUST_IMAGE_VERSION} AS builder + +ARG PROFILE=release +ARG CARGO_BUILD_FEATURES +# The GIT_REVISION environment variable is used during build time inside the rust crates +ARG GIT_REVISION +ENV GIT_REVISION=$GIT_REVISION + +WORKDIR "/iota" + +# Install build dependencies, including clang and lld for faster linking +RUN apt update && apt install -y cmake clang lld + +# Configure Rust to use clang and lld as the linker +RUN mkdir -p ~/.cargo && \ + echo -e "[target.x86_64-unknown-linux-gnu]\nlinker = \"clang\"\nrustflags = [\"-C\", \"link-arg=-fuse-ld=lld\"]" > ~/.cargo/config.toml + +# Install additional dependencies +RUN apt install -y libpq5 libpq-dev ca-certificates + +# Copy in all crates, Cargo.toml, and Cargo.lock +COPY consensus consensus +COPY crates crates +COPY docs docs +COPY external-crates external-crates +COPY iota-execution iota-execution +COPY Cargo.toml Cargo.lock ./ + +RUN cargo build --profile ${PROFILE} \ + --bin iota \ + --bin iota-rosetta \ + --features ${CARGO_BUILD_FEATURES:=default} + +# Copy the built binary to the working directory depending on the output folder of the profile, +# so we can copy it to the runtime image +RUN if [ -d target/release ]; then \ + TARGET_DIR="target/release"; \ +elif [ -d target/debug ]; then \ + TARGET_DIR="target/debug"; \ +else \ + echo "Error: No build directory found"; \ + exit 1; \ +fi && \ +mv $TARGET_DIR/iota ./ && \ +mv $TARGET_DIR/iota-rosetta ./; + +# Production image +FROM debian:bookworm-slim AS runtime + +ARG WORKDIR="/iota" +WORKDIR "$WORKDIR" + +# Install runtime dependencies and tools +RUN apt update && apt install -y libpq5 ca-certificates curl + +# Install rosetta-cli +RUN curl -sSfL https://raw.githubusercontent.com/coinbase/rosetta-cli/master/scripts/install.sh | sh -s + +COPY --from=builder /iota/iota /usr/local/bin +COPY --from=builder /iota/iota-rosetta /usr/local/bin +COPY --from=builder /iota/crates/iota-config/data/fullnode-template.yaml /iota/devnet/fullnode.yaml +RUN /usr/local/bin/iota genesis + +ARG BUILD_DATE +ARG GIT_REVISION +LABEL build-date=$BUILD_DATE +LABEL git-revision=$GIT_REVISION diff --git a/docker/iota-rosetta-local/build.sh b/docker/iota-rosetta-local/build.sh new file mode 100755 index 00000000000..fd013bdaa4d --- /dev/null +++ b/docker/iota-rosetta-local/build.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Copyright (c) Mysten Labs, Inc. +# Modifications Copyright (c) 2024 IOTA Stiftung +# SPDX-License-Identifier: Apache-2.0 +./../../docker/utils/build-script.sh --container-name "iotaledger/iota-rosetta-local" diff --git a/crates/iota-rosetta/docker/iota-rosetta-local/docker-compose.yaml b/docker/iota-rosetta-local/docker-compose.yaml similarity index 100% rename from crates/iota-rosetta/docker/iota-rosetta-local/docker-compose.yaml rename to docker/iota-rosetta-local/docker-compose.yaml diff --git a/docker/iota-services/Dockerfile b/docker/iota-services/Dockerfile deleted file mode 100644 index 70a4f1a5214..00000000000 --- a/docker/iota-services/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -FROM rust:bullseye AS chef -WORKDIR iota -ARG GIT_REVISION -ENV GIT_REVISION=$GIT_REVISION - -RUN apt-get update && apt-get install -y cmake clang libpq5 ca-certificates libpq-dev postgresql - -# Build application -FROM chef AS builder - -COPY Cargo.toml Cargo.lock ./ -COPY consensus consensus -COPY crates crates -COPY iota-execution iota-execution -COPY external-crates external-crates -COPY docs docs - -RUN mkdir /iota/bin/ -RUN find /iota/target/release/ -maxdepth 1 -type f -executable -print -RUN find /iota/target/release/ -maxdepth 1 -type f -executable -print | xargs cp -t /iota/bin/ - -# Production Image -FROM debian:bullseye-slim AS runtime -WORKDIR iota -COPY --from=builder /iota/bin/* /usr/local/bin - -RUN apt update && apt install -y libpq5 libpq-dev postgresql - -ARG BUILD_DATE -ARG GIT_REVISION -LABEL build-date=$BUILD_DATE -LABEL git-revision=$GIT_REVISION - diff --git a/docker/iota-services/build.sh b/docker/iota-services/build.sh deleted file mode 100755 index 031ebcede71..00000000000 --- a/docker/iota-services/build.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -# Copyright (c) Mysten Labs, Inc. -# Modifications Copyright (c) 2024 IOTA Stiftung -# SPDX-License-Identifier: Apache-2.0 - -# fast fail. -set -e - -DIR="$( cd "$( dirname "$0" )" && pwd )" -REPO_ROOT="$(git rev-parse --show-toplevel)" -DOCKERFILE="$DIR/Dockerfile" -GIT_REVISION="$(git describe --always --abbrev=12 --dirty --exclude '*')" -BUILD_DATE="$(date -u +'%Y-%m-%d')" - -echo -echo "Building iota-services docker image" -echo "Dockerfile: \t$DOCKERFILE" -echo "docker context: $REPO_ROOT" -echo "build date: \t$BUILD_DATE" -echo "git revision: \t$GIT_REVISION" -echo - -docker build -f "$DOCKERFILE" "$REPO_ROOT" \ - --build-arg GIT_REVISION="$GIT_REVISION" \ - --build-arg BUILD_DATE="$BUILD_DATE" \ - "$@" diff --git a/docker/iota-source-service/Dockerfile b/docker/iota-source-service/Dockerfile deleted file mode 100644 index f1a93befca0..00000000000 --- a/docker/iota-source-service/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -FROM rust:bullseye AS chef -WORKDIR iota -ARG GIT_REVISION -ENV GIT_REVISION=$GIT_REVISION - -RUN apt-get update && apt-get install -y cmake clang - -FROM chef AS builder - -# Build application -COPY Cargo.toml Cargo.lock ./ -COPY consensus consensus -COPY crates crates -COPY iota-execution iota-execution -COPY external-crates external-crates -COPY docs docs - -RUN cargo build --release \ - --bin iota-source-validation-service - -# Production Image -FROM debian:bullseye-slim AS runtime -WORKDIR iota -RUN apt update && apt install -y git -COPY --from=builder /iota/target/release/iota-source-validation-service /usr/local/bin -COPY crates/iota-source-validation-service/config.toml /var/iota/ - -ARG BUILD_DATE -ARG GIT_REVISION -LABEL build-date=$BUILD_DATE -LABEL git-revision=$GIT_REVISION diff --git a/docker/iota-source-service/build.sh b/docker/iota-source-service/build.sh deleted file mode 100755 index eff4c315369..00000000000 --- a/docker/iota-source-service/build.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -# Copyright (c) Mysten Labs, Inc. -# Modifications Copyright (c) 2024 IOTA Stiftung -# SPDX-License-Identifier: Apache-2.0 - -# fast fail. -set -e - -DIR="$( cd "$( dirname "$0" )" && pwd )" -REPO_ROOT="$(git rev-parse --show-toplevel)" -DOCKERFILE="$DIR/Dockerfile" -GIT_REVISION="$(git describe --always --abbrev=12 --dirty --exclude '*')" -BUILD_DATE="$(date -u +'%Y-%m-%d')" - -echo -echo "Building iota-source-service docker image" -echo "Dockerfile: \t$DOCKERFILE" -echo "docker context: $REPO_ROOT" -echo "build date: \t$BUILD_DATE" -echo "git revision: \t$GIT_REVISION" -echo - -docker build -f "$DOCKERFILE" "$REPO_ROOT" \ - --build-arg GIT_REVISION="$GIT_REVISION" \ - --build-arg BUILD_DATE="$BUILD_DATE" \ - "$@" diff --git a/docker/iota-source-validation-service/Dockerfile b/docker/iota-source-validation-service/Dockerfile new file mode 100644 index 00000000000..5d65e2b0cd4 --- /dev/null +++ b/docker/iota-source-validation-service/Dockerfile @@ -0,0 +1,60 @@ +# Build image (the specific rust version can also be passed, e.g. "1.82-bookworm") +ARG RUST_IMAGE_VERSION=bookworm +FROM rust:${RUST_IMAGE_VERSION} AS builder + +ARG PROFILE=release +ARG CARGO_BUILD_FEATURES +# The GIT_REVISION environment variable is used during build time inside the rust crates +ARG GIT_REVISION +ENV GIT_REVISION=$GIT_REVISION + +WORKDIR "/iota" + +# Install build dependencies, including clang and lld for faster linking +RUN apt update && apt install -y cmake clang lld + +# Configure Rust to use clang and lld as the linker +RUN mkdir -p ~/.cargo && \ + echo -e "[target.x86_64-unknown-linux-gnu]\nlinker = \"clang\"\nrustflags = [\"-C\", \"link-arg=-fuse-ld=lld\"]" > ~/.cargo/config.toml + +# Install additional dependencies +RUN apt install -y libpq5 libpq-dev ca-certificates + +# Copy in all crates, Cargo.toml, and Cargo.lock +COPY consensus consensus +COPY crates crates +COPY docs docs +COPY external-crates external-crates +COPY iota-execution iota-execution +COPY Cargo.toml Cargo.lock ./ + +RUN cargo build --profile ${PROFILE} --bin iota-source-validation-service --features ${CARGO_BUILD_FEATURES:=default} + +# Copy the built binary to the working directory depending on the output folder of the profile, +# so we can copy it to the runtime image +RUN if [ -d target/release ]; then \ + TARGET_DIR="target/release"; \ +elif [ -d target/debug ]; then \ + TARGET_DIR="target/debug"; \ +else \ + echo "Error: No build directory found"; \ + exit 1; \ +fi && \ +mv $TARGET_DIR/iota-source-validation-service ./; + +# Production image +FROM debian:bookworm-slim AS runtime + +ARG WORKDIR="/iota" +WORKDIR "$WORKDIR" + +# Install runtime dependencies and tools +RUN apt update && apt install -y libpq5 ca-certificates curl + +COPY --from=builder /iota/iota-source-validation-service /usr/local/bin +COPY --from=builder /iota/crates/iota-source-validation-service/config.toml /var/iota/ + +ARG BUILD_DATE +ARG GIT_REVISION +LABEL build-date=$BUILD_DATE +LABEL git-revision=$GIT_REVISION diff --git a/docker/iota-source-validation-service/build.sh b/docker/iota-source-validation-service/build.sh new file mode 100755 index 00000000000..cba260c7b5d --- /dev/null +++ b/docker/iota-source-validation-service/build.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Copyright (c) Mysten Labs, Inc. +# Modifications Copyright (c) 2024 IOTA Stiftung +# SPDX-License-Identifier: Apache-2.0 +./../utils/build-script.sh --container-name "iotaledger/iota-source-validation-service" diff --git a/docker/iota-tools/Dockerfile b/docker/iota-tools/Dockerfile index 0e949e467e0..145d13c5431 100644 --- a/docker/iota-tools/Dockerfile +++ b/docker/iota-tools/Dockerfile @@ -1,51 +1,86 @@ -# Build application -# -# Copy in all crates, Cargo.toml and Cargo.lock unmodified, -# and build the application. -FROM rust:bullseye AS builder +# Build image (the specific rust version can also be passed, e.g. "1.82-bookworm") +ARG RUST_IMAGE_VERSION=bookworm +FROM rust:${RUST_IMAGE_VERSION} AS builder + ARG PROFILE=release +ARG CARGO_BUILD_FEATURES +# The GIT_REVISION environment variable is used during build time inside the rust crates ARG GIT_REVISION ENV GIT_REVISION=$GIT_REVISION -WORKDIR "$WORKDIR/iota" -RUN apt-get update && apt-get install -y cmake clang libpq5 libpq-dev +WORKDIR "/iota" -COPY Cargo.toml Cargo.lock ./ +# Install build dependencies, including clang and lld for faster linking +RUN apt update && apt install -y cmake clang lld + +# Configure Rust to use clang and lld as the linker +RUN mkdir -p ~/.cargo && \ + echo -e "[target.x86_64-unknown-linux-gnu]\nlinker = \"clang\"\nrustflags = [\"-C\", \"link-arg=-fuse-ld=lld\"]" > ~/.cargo/config.toml + +# Install additional dependencies +RUN apt install -y libpq5 libpq-dev ca-certificates + +# Copy in all crates, Cargo.toml, and Cargo.lock COPY consensus consensus COPY crates crates -COPY iota-execution iota-execution -COPY external-crates external-crates COPY docs docs +COPY external-crates external-crates +COPY iota-execution iota-execution +COPY Cargo.toml Cargo.lock ./ RUN cargo build --profile ${PROFILE} \ - --bin iota-node \ - --bin stress \ - --bin iota-bridge \ - --bin bridge-indexer \ - --bin iota-bridge-cli \ - --bin iota-analytics-indexer \ - --bin iota \ - --bin iota-faucet \ - --bin iota-cluster-test \ - --bin iota-tool - -# Production Image -FROM debian:bullseye-slim AS runtime -WORKDIR "$WORKDIR/iota" - -# iota-tool needs libpq at runtime -RUN apt-get update && apt-get install -y libpq5 libpq-dev ca-certificates - -COPY --from=builder /iota/target/release/iota-node /usr/local/bin -COPY --from=builder /iota/target/release/stress /usr/local/bin -COPY --from=builder /iota/target/release/iota-bridge /usr/local/bin -COPY --from=builder /iota/target/release/bridge-indexer /usr/local/bin -COPY --from=builder /iota/target/release/iota-bridge-cli /usr/local/bin -COPY --from=builder /iota/target/release/iota-analytics-indexer /usr/local/bin -COPY --from=builder /iota/target/release/iota /usr/local/bin -COPY --from=builder /iota/target/release/iota-faucet /usr/local/bin -COPY --from=builder /iota/target/release/iota-cluster-test /usr/local/bin -COPY --from=builder /iota/target/release/iota-tool /usr/local/bin + --bin iota-node \ + --bin stress \ + --bin iota-bridge \ + --bin bridge-indexer \ + --bin iota-bridge-cli \ + --bin iota-analytics-indexer \ + --bin iota \ + --bin iota-faucet \ + --bin iota-cluster-test \ + --bin iota-tool \ + --features ${CARGO_BUILD_FEATURES:=default} + +# Copy the built binary to the working directory depending on the output folder of the profile, +# so we can copy it to the runtime image +RUN if [ -d target/release ]; then \ + TARGET_DIR="target/release"; \ +elif [ -d target/debug ]; then \ + TARGET_DIR="target/debug"; \ +else \ + echo "Error: No build directory found"; \ + exit 1; \ +fi && \ +mv $TARGET_DIR/iota-node ./ && \ +mv $TARGET_DIR/stress ./ && \ +mv $TARGET_DIR/iota-bridge ./ && \ +mv $TARGET_DIR/bridge-indexer ./ && \ +mv $TARGET_DIR/iota-bridge-cli ./ && \ +mv $TARGET_DIR/iota-analytics-indexer ./ && \ +mv $TARGET_DIR/iota ./ && \ +mv $TARGET_DIR/iota-faucet ./ && \ +mv $TARGET_DIR/iota-cluster-test ./ && \ +mv $TARGET_DIR/iota-tool ./; + +# Production image +FROM debian:bookworm-slim AS runtime + +ARG WORKDIR="/iota" +WORKDIR "$WORKDIR" + +# Install runtime dependencies and tools +RUN apt update && apt install -y libpq5 ca-certificates curl + +COPY --from=builder /iota/iota-node /usr/local/bin +COPY --from=builder /iota/stress /usr/local/bin +COPY --from=builder /iota/iota-bridge /usr/local/bin +COPY --from=builder /iota/bridge-indexer /usr/local/bin +COPY --from=builder /iota/iota-bridge-cli /usr/local/bin +COPY --from=builder /iota/iota-analytics-indexer /usr/local/bin +COPY --from=builder /iota/iota /usr/local/bin +COPY --from=builder /iota/iota-faucet /usr/local/bin +COPY --from=builder /iota/iota-cluster-test /usr/local/bin +COPY --from=builder /iota/iota-tool /usr/local/bin ARG BUILD_DATE ARG GIT_REVISION diff --git a/docker/iota-tools/build.sh b/docker/iota-tools/build.sh index fde1f0942f8..fc57fe73260 100755 --- a/docker/iota-tools/build.sh +++ b/docker/iota-tools/build.sh @@ -1,27 +1,5 @@ -#!/bin/sh +#!/bin/bash # Copyright (c) Mysten Labs, Inc. # Modifications Copyright (c) 2024 IOTA Stiftung # SPDX-License-Identifier: Apache-2.0 - -# fast fail. -set -e - -DIR="$( cd "$( dirname "$0" )" && pwd )" -REPO_ROOT="$(git rev-parse --show-toplevel)" -DOCKERFILE="$DIR/Dockerfile" -GIT_REVISION="$(git describe --always --abbrev=12 --dirty --exclude '*')" -BUILD_DATE="$(date -u +'%Y-%m-%d')" - -echo -echo "Building iota-tools docker image" -echo "Dockerfile: \t$DOCKERFILE" -echo "docker context: $REPO_ROOT" -echo "build date: \t$BUILD_DATE" -echo "git revision: \t$GIT_REVISION" -echo - -docker build -f "$DOCKERFILE" "$REPO_ROOT" \ - --build-arg GIT_REVISION="$GIT_REVISION" \ - --build-arg BUILD_DATE="$BUILD_DATE" \ - --target runtime \ - "$@" +./../utils/build-script.sh --container-name "iotaledger/iota-tools" diff --git a/docker/iota/Dockerfile b/docker/iota/Dockerfile index 2eb9be64f0d..a2dcf6c33ff 100644 --- a/docker/iota/Dockerfile +++ b/docker/iota/Dockerfile @@ -1,31 +1,55 @@ -# Build application -# -# Copy in all crates, Cargo.toml and Cargo.lock unmodified, -# and build the application. -FROM rust:bullseye AS builder +# Build image (the specific rust version can also be passed, e.g. "1.82-bookworm") +ARG RUST_IMAGE_VERSION=bookworm +FROM rust:${RUST_IMAGE_VERSION} AS builder + ARG PROFILE=release +ARG CARGO_BUILD_FEATURES +# The GIT_REVISION environment variable is used during build time inside the rust crates ARG GIT_REVISION ENV GIT_REVISION=$GIT_REVISION -ARG CARGO_BUILD_FEATURES + WORKDIR "/iota" -RUN apt-get update && apt-get install -y cmake clang libpq5 libpq-dev +# Install build dependencies, including clang and lld for faster linking +RUN apt update && apt install -y cmake clang lld -COPY Cargo.toml Cargo.lock ./ +# Configure Rust to use clang and lld as the linker +RUN mkdir -p ~/.cargo && \ + echo -e "[target.x86_64-unknown-linux-gnu]\nlinker = \"clang\"\nrustflags = [\"-C\", \"link-arg=-fuse-ld=lld\"]" > ~/.cargo/config.toml + +# Install additional dependencies +RUN apt install -y libpq5 libpq-dev ca-certificates + +# Copy in all crates, Cargo.toml, and Cargo.lock COPY consensus consensus COPY crates crates -COPY iota-execution iota-execution -COPY external-crates external-crates COPY docs docs +COPY external-crates external-crates +COPY iota-execution iota-execution +COPY Cargo.toml Cargo.lock ./ RUN cargo build --profile ${PROFILE} --bin iota --features ${CARGO_BUILD_FEATURES:=default} -RUN mv target/$(if [ $PROFILE = "dev" ]; then echo "debug"; else echo "release";fi)/iota ./ -# Production Image -FROM debian:bullseye-slim AS runtime +# Copy the built binary to the working directory depending on the output folder of the profile, +# so we can copy it to the runtime image +RUN if [ -d target/release ]; then \ + TARGET_DIR="target/release"; \ +elif [ -d target/debug ]; then \ + TARGET_DIR="target/debug"; \ +else \ + echo "Error: No build directory found"; \ + exit 1; \ +fi && \ +mv $TARGET_DIR/iota ./; + +# Production image +FROM debian:bookworm-slim AS runtime + +ARG WORKDIR="/iota" +WORKDIR "$WORKDIR" -# iota-tool needs libpq at runtime -RUN apt-get update && apt-get install -y libpq5 libpq-dev curl +# Install runtime dependencies and tools +RUN apt update && apt install -y libpq5 ca-certificates curl COPY --from=builder /iota/iota /usr/local/bin diff --git a/docker/iota/build.sh b/docker/iota/build.sh index 1aac6f69769..fdd4eceb480 100755 --- a/docker/iota/build.sh +++ b/docker/iota/build.sh @@ -1,28 +1,5 @@ -#!/bin/sh +#!/bin/bash # Copyright (c) Mysten Labs, Inc. # Modifications Copyright (c) 2024 IOTA Stiftung # SPDX-License-Identifier: Apache-2.0 - -# fast fail. -set -e - -DIR="$( cd "$( dirname "$0" )" && pwd )" -REPO_ROOT="$(git rev-parse --show-toplevel)" -DOCKERFILE="$DIR/Dockerfile" -GIT_REVISION="$(git describe --always --abbrev=12 --dirty --exclude '*')" -BUILD_DATE="$(date -u +'%Y-%m-%d')" - -echo -echo "Building iota docker image" -echo "Dockerfile: \t$DOCKERFILE" -echo "docker context: $REPO_ROOT" -echo "build date: \t$BUILD_DATE" -echo "git revision: \t$GIT_REVISION" -echo - -docker build -f "$DOCKERFILE" "$REPO_ROOT" \ - --build-arg GIT_REVISION="$GIT_REVISION" \ - --build-arg BUILD_DATE="$BUILD_DATE" \ - --build-arg CARGO_BUILD_FEATURES="$CARGO_BUILD_FEATURES" \ - --target runtime \ - "$@" +./../utils/build-script.sh --container-name "iotaledger/iota" diff --git a/docker/pg-services-local/docker-compose.yaml b/docker/pg-services-local/docker-compose.yaml index fe8e31ab08a..e5948b54dad 100644 --- a/docker/pg-services-local/docker-compose.yaml +++ b/docker/pg-services-local/docker-compose.yaml @@ -134,7 +134,7 @@ services: - RUST_BACKTRACE=1 - RUST_LOG=info command: - - /opt/iota/bin/iota-graphql-rpc + - /usr/local/bin/iota-graphql-rpc - start-server - --db-url=postgres://postgres:postgrespw@postgres:5432/iota_indexer - --host=0.0.0.0 diff --git a/docker/stress/Dockerfile b/docker/stress/Dockerfile index d70f250ccbe..376508e30fb 100644 --- a/docker/stress/Dockerfile +++ b/docker/stress/Dockerfile @@ -4,7 +4,7 @@ FROM iotaledger/iota-tools:$IOTA_TOOLS_IMAGE_TAG ARG IOTA_TOOLS_IMAGE_TAG -RUN apt-get update && apt-get -y --no-install-recommends install wget=1.21-1+deb11u1 \ +RUN apt update && apt -y --no-install-recommends install wget=1.21-1+deb11u1 \ iputils-ping netcat procps bind9-host bind9-dnsutils curl iproute2 git ca-certificates awscli # stress needs access to examples/move/basics diff --git a/docker/utils/build-script.sh b/docker/utils/build-script.sh new file mode 100755 index 00000000000..ef526167bdd --- /dev/null +++ b/docker/utils/build-script.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# Copyright (c) Mysten Labs, Inc. +# Modifications Copyright (c) 2024 IOTA Stiftung +# SPDX-License-Identifier: Apache-2.0 + +# Get the directory where build-script.sh is located +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# Source common.sh from the utils directory +source "$SCRIPT_DIR/common.sh" + +# fast fail. +set -e + +# Get the current working directory where the script was called +CURRENT_WORKING_DIR="$(pwd)" + +REPO_ROOT="$(git rev-parse --show-toplevel)" +DOCKERFILE="$CURRENT_WORKING_DIR/Dockerfile" +GIT_REVISION="$(git describe --always --abbrev=12 --dirty --exclude '*')" +BUILD_DATE="$(date -u +'%Y-%m-%d')" +PROFILE="release" +CONTAINER_NAME="" + +# Parse command line arguments +# Usage: +# --container-name - the name of the container +while [ "$#" -gt 0 ]; do + case "$1" in + --container-name=*) + CONTAINER_NAME="${1#*=}" + shift + ;; + --container-name) + CONTAINER_NAME="$2" + shift 2 + ;; + *) + print_error "Unknown argument: $1" + print_step "Usage: $0 --container-name " + exit 1 + ;; + esac +done + +# check if the container name is set +if [ -z "$CONTAINER_NAME" ]; then + print_error "Container name is not set" + print_step "Usage: $0 --container-name " + exit 1 +fi + +print_step "Parse the rust toolchain version from 'rust-toolchain.toml'..." +RUST_VERSION=$(grep -oE 'channel = "[^"]+' ${REPO_ROOT}/rust-toolchain.toml | sed 's/channel = "//') +if [ -z "$RUST_VERSION" ]; then + print_error "Failed to parse the rust toolchain version" + exit 1 +fi +RUST_IMAGE_VERSION=${RUST_VERSION}-bookworm + +echo +echo "Building \"$CONTAINER_NAME\" docker image" +echo "Dockerfile: $DOCKERFILE" +echo "docker context: $REPO_ROOT" +echo "profile: $PROFILE" +echo "builder rust image version: $RUST_IMAGE_VERSION" +echo "cargo build features: $CARGO_BUILD_FEATURES" +echo "build date: $BUILD_DATE" +echo "git revision: $GIT_REVISION" +echo + +docker build -f "$DOCKERFILE" "$REPO_ROOT" \ + -t ${CONTAINER_NAME} \ + --build-arg RUST_IMAGE_VERSION="${RUST_IMAGE_VERSION}" \ + --build-arg PROFILE="$PROFILE" \ + --build-arg CARGO_BUILD_FEATURES="$CARGO_BUILD_FEATURES" \ + --build-arg BUILD_DATE="$BUILD_DATE" \ + --build-arg GIT_REVISION="$GIT_REVISION" \ + --target runtime \ + "$@" diff --git a/docker/utils/common.sh b/docker/utils/common.sh new file mode 100755 index 00000000000..dea59dcc000 --- /dev/null +++ b/docker/utils/common.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# Copyright (c) 2024 IOTA Stiftung +# SPDX-License-Identifier: Apache-2.0 + +function print_step { + echo -e "\e[32m$1\e[0m" +} + +function print_error { + echo -e "\e[31m$1\e[0m" +} + +function check_error { + if [ $? -ne 0 ]; then + print_error "$1" + exit 1 + fi +} diff --git a/docs/site/src/components/NetworkInfo/index.tsx b/docs/site/src/components/NetworkInfo/index.tsx index 748d8638105..b87de0f6d92 100644 --- a/docs/site/src/components/NetworkInfo/index.tsx +++ b/docs/site/src/components/NetworkInfo/index.tsx @@ -35,13 +35,13 @@ function L1(props: NetworkProps) { {props.permaNodeApi} - {props.faucet && ( + {props.faucetUrl && ( Faucet - - {props.faucet} - + + {props.faucetUrl} + )} @@ -81,13 +81,13 @@ function Testnet(props: NetworkProps) { {props.permaNodeApi} - {props.faucet && ( + {props.faucetUrl && ( Faucet - - {props.faucet} - + + {props.faucetUrl} + )} @@ -127,13 +127,13 @@ function Devnet(props: NetworkProps) { {props.permaNodeApi} - {props.faucet && ( + {props.faucetUrl && ( Faucet - - {props.faucet} - + + {props.faucetUrl} + )} @@ -294,13 +294,13 @@ function Move(props: MoveProps) { {props.jsonRpcWebsocketUrl} - {props.faucet && ( + {props.faucetUrl && ( Faucet URL - + {props.faucetUrl} - + )} diff --git a/docs/site/src/components/constant.tsx b/docs/site/src/components/constant.tsx index 29c2a6f899c..e77d80b14e7 100644 --- a/docs/site/src/components/constant.tsx +++ b/docs/site/src/components/constant.tsx @@ -216,7 +216,7 @@ export interface NetworkProps { httpRestApi: string; eventApi: string; permaNodeApi: string; - faucet?: string; + faucetUrl?: string; explorer: string; evm: AddEthereumChainParameter; evmCustom: { diff --git a/sdk/bcs/README.md b/sdk/bcs/README.md index 617dcc0e9d6..fce39264c3f 100644 --- a/sdk/bcs/README.md +++ b/sdk/bcs/README.md @@ -1,5 +1,9 @@ # BCS - Binary Canonical Serialization +`@iota/bcs` is part of the **IOTA Rebased SDK**, designed specifically for interacting with the IOTA Rebased protocol. + +> **Note**: This package is currently supported **only in Testnet and Devnet**, it is **not yet supported in Mainnet**. + This small and lightweight library implements [Binary Canonical Serialization (BCS)](https://github.com/zefchain/bcs) in TypeScript, making BCS available in both Browser and NodeJS environments in a type-safe way.` diff --git a/sdk/create-dapp/README.md b/sdk/create-dapp/README.md index 43655d7126c..5cda509fd84 100644 --- a/sdk/create-dapp/README.md +++ b/sdk/create-dapp/README.md @@ -1,5 +1,9 @@ # @iota/create-dapp +`@iota/create-dapp` is part of the **IOTA Rebased SDK**, designed specifically for interacting with the IOTA Rebased protocol. + +> **Note**: This package is currently supported **only in Testnet and Devnet**, it is **not yet supported in Mainnet**. + `@iota/create-dapp` is a CLI tool that helps you to create a new dApp project. You can get started quickly by running the following command: diff --git a/sdk/dapp-kit/README.md b/sdk/dapp-kit/README.md index 8ee45dda9a2..b7c36ca127d 100644 --- a/sdk/dapp-kit/README.md +++ b/sdk/dapp-kit/README.md @@ -1,5 +1,9 @@ # IOTA dApp Kit +`@iota/dapp-kit` is part of the **IOTA Rebased SDK**, designed specifically for interacting with the IOTA Rebased protocol. + +> **Note**: This package is currently supported **only in Testnet and Devnet**, it is **not yet supported in Mainnet**. + The IOTA dApp Kit is a set of React components, hooks, and utilities that make it easy to build a dApp for the IOTA ecosystem. It provides hooks and components for querying data from the IOTA blockchain, and connecting to IOTA wallets. diff --git a/sdk/graphql-transport/README.md b/sdk/graphql-transport/README.md index 5674f0bf48f..fb320e192f1 100644 --- a/sdk/graphql-transport/README.md +++ b/sdk/graphql-transport/README.md @@ -1,5 +1,9 @@ # `@iota/graphql-transport` +`@iota/graphql-transport` is part of the **IOTA Rebased SDK**, designed specifically for interacting with the IOTA Rebased protocol. + +> **Note**: This package is currently supported **only in Testnet and Devnet**, it is **not yet supported in Mainnet**. + This package provides a `IotaTransport` that enables `IotaClient` to make requests using the RPC 2.0 (GraphQL) API instead of the JSON RPC API. diff --git a/sdk/kiosk/README.md b/sdk/kiosk/README.md index 5c76569cb4c..519630aa6dd 100644 --- a/sdk/kiosk/README.md +++ b/sdk/kiosk/README.md @@ -1,8 +1,41 @@ # Kiosk SDK +`@iota/kiosk` is part of the **IOTA Rebased SDK**, designed specifically for interacting with the IOTA Rebased protocol. + +> **Note**: This package is currently supported **only in Testnet and Devnet**, it is **not yet supported in Mainnet**. + This Kiosk SDK library provides different utilities to interact/create/manage a -[Kiosk](https://github.com/iotaledger/iota/tree/main/kiosk). +[Kiosk](https://github.com/iotaledger/iota/tree/develop/kiosk). [You can read the documentation and see examples by clicking here.](https://docs.iota.org/references/ts-sdk/kiosk) -[If you are migrating from `0.6.x`, you can follow these instructions](https://docs.iota.org/references/ts-sdk/kiosk/from-v1) +## Install + +To use the Kiosk SDK in your project, run the following command in your project root: + +```sh npm2yarn +npm i @iota/kiosk @iota/iota-sdk +``` + +To use the Kiosk SDK, you must create a [KioskClient](https://docs.iota.org/references/ts-sdk/kiosk/kiosk-client/introduction) instance. + +## Setup + +You can follow this example to create a KioskClient. + +```typescript +import { KioskClient } from '@iota/kiosk'; +import { getFullnodeUrl, IotaClient, Network } from '@iota/iota-sdk/client'; + +// We need a IOTA Client. You can re-use the IotaClient of your project +// (it's not recommended to create a new one). +const client = new IotaClient({ url: getFullnodeUrl(Network.Testnet) }); + +// Now we can use it to create a kiosk Client. +const kioskClient = new KioskClient({ + client, + network: Network.Testnet, +}); +``` + +You can read the KioskClient documentation to query kiosk data [here](https://docs.iota.org/references/ts-sdk/kiosk/kiosk-client/querying). diff --git a/sdk/ledgerjs-hw-app-iota/README.md b/sdk/ledgerjs-hw-app-iota/README.md index 3297361f3dd..cc52d55ffdb 100644 --- a/sdk/ledgerjs-hw-app-iota/README.md +++ b/sdk/ledgerjs-hw-app-iota/README.md @@ -4,6 +4,10 @@ # ledgerjs-hw-app-iota +`@iota/ledgerjs-hw-app-iota` is part of the **IOTA Rebased SDK**, designed specifically for interacting with the IOTA Rebased protocol. + +> **Note**: This package is currently supported **only in Testnet and Devnet**, it is **not yet supported in Mainnet**. + [Ledger Hardware Wallet](https://www.ledger.com/) JavaScript bindings for [IOTA](https://iota.org/), based on [LedgerJS](https://github.com/LedgerHQ/ledgerjs). diff --git a/sdk/typescript/README.md b/sdk/typescript/README.md index 619edbb58c2..3bc7758c018 100644 --- a/sdk/typescript/README.md +++ b/sdk/typescript/README.md @@ -5,6 +5,10 @@ For more complete docs, visit the # IOTA TypeScript SDK +`@iota/iota-sdk` is part of the **IOTA Rebased SDK**, designed specifically for interacting with the IOTA Rebased protocol. + +> **Note**: This package is currently supported **only in Testnet and Devnet**, it is **not yet supported in Mainnet**. + This is the IOTA TypeScript SDK built on the IOTA [JSON RPC API](https://github.com/iotaledger/iota/blob/main/docs/content/references/iota-api.mdx). It provides utility classes and functions for applications to sign transactions and interact with @@ -91,7 +95,7 @@ npx vitest txn-builder.test.ts Troubleshooting: If you see errors like `ECONNRESET or "socket hang up"`, run `node -v` to make sure your node -version is `v18.x.x`. Refer to this +version is `v20.x.x`. Refer to this [guide](https://blog.logrocket.com/how-switch-node-js-versions-nvm/) to switch node version. Some more follow up here is if you used homebrew to install node, there could be multiple paths to diff --git a/sdk/wallet-standard/README.md b/sdk/wallet-standard/README.md index 83b89e24ea2..3cba4242ec1 100644 --- a/sdk/wallet-standard/README.md +++ b/sdk/wallet-standard/README.md @@ -1,5 +1,9 @@ # `@iota/wallet-standard` +`@iota/wallet-standard` is part of the **IOTA Rebased SDK**, designed specifically for interacting with the IOTA Rebased protocol. + +> **Note**: This package is currently supported **only in Testnet and Devnet**, it is **not yet supported in Mainnet**. + A suite of standard utilities for implementing wallets and libraries based on the [Wallet Standard](https://github.com/wallet-standard/wallet-standard/).