Skip to content
Snippets Groups Projects
Select Git revision
  • 652e457b3296e21d016283f10868f26f95f06b64
  • master default protected
  • tuxmain/fix-change-owner-key
  • fix_picked_up_file_in_runtime_release
  • network/gtest-1000 protected
  • upgradable-multisig
  • runtime/gtest-1000
  • network/gdev-800 protected
  • cgeek/issue-297-cpu
  • gdev-800-tests
  • update-docker-compose-rpc-squid-names
  • fix-252
  • 1000i100-test
  • hugo/tmp-0.9.1
  • network/gdev-803 protected
  • hugo/endpoint-gossip
  • network/gdev-802 protected
  • hugo/distance-precompute
  • network/gdev-900 protected
  • tuxmain/anonymous-tx
  • debug/podman
  • gtest-1000-0.11.1 protected
  • gtest-1000-0.11.0 protected
  • gtest-1000 protected
  • gdev-900-0.10.1 protected
  • gdev-900-0.10.0 protected
  • gdev-900-0.9.2 protected
  • gdev-800-0.8.0 protected
  • gdev-900-0.9.1 protected
  • gdev-900-0.9.0 protected
  • gdev-803 protected
  • gdev-802 protected
  • runtime-801 protected
  • gdev-800 protected
  • runtime-800-bis protected
  • runtime-800 protected
  • runtime-800-backup protected
  • runtime-701 protected
  • runtime-700 protected
  • runtime-600 protected
  • runtime-500 protected
41 results

Dockerfile

Blame
  • Dockerfile 3.56 KiB
    # Workaround for https://github.com/containers/buildah/issues/4742
    FROM debian:bullseye-slim as target
    
    # ------------------------------------------------------------------------------
    # Build Stage
    # ------------------------------------------------------------------------------
    
    # When building for a foreign arch, use cross-compilation
    # https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/
    FROM --platform=$BUILDPLATFORM rust:1-bullseye as build
    ARG BUILDPLATFORM
    ARG TARGETPLATFORM
    
    # We need the target arch triplet in both Debian and rust flavor
    RUN echo "DEBIAN_ARCH_TRIPLET='$(dpkg-architecture -A${TARGETPLATFORM#linux/} -qDEB_TARGET_MULTIARCH)'" >>/root/dynenv
    RUN . /root/dynenv && \
        echo "RUST_ARCH_TRIPLET='$(echo "$DEBIAN_ARCH_TRIPLET" | sed -E 's/-linux-/-unknown&/')'" >>/root/dynenv
    
    WORKDIR /root
    
    # Copy source tree
    COPY . .
    
    RUN apt-get update && \
        DEBIAN_FRONTEND=noninteractive apt-get install -y clang cmake protobuf-compiler
    
    # build duniter
    ARG debug=0
    RUN if [ "$debug" = 0 ]; then \
            echo "CARGO_OPTIONS=--release" >>/root/dynenv && \
            echo "TARGET_FOLDER=release" >>/root/dynenv; \
        else \
            echo "TARGET_FOLDER=debug" >>/root/dynenv; \
        fi
    
    ARG benchmarks=0
    RUN if [ "$benchmarks" != 0 ]; then \
            echo "BENCH_OPTIONS=--features\ runtime-benchmarks" >>/root/dynenv; \
        fi
    
    # Configure cross-build environment if need be
    RUN set -x && \
        if [ "$TARGETPLATFORM" != "$BUILDPLATFORM" ]; then \
            . /root/dynenv && \
            apt install -y gcc-$DEBIAN_ARCH_TRIPLET binutils-$DEBIAN_ARCH_TRIPLET && \
            rustup target add "$RUST_ARCH_TRIPLET" && \
            : https://github.com/rust-lang/cargo/issues/4133 && \
            echo "RUSTFLAGS='-C linker=$DEBIAN_ARCH_TRIPLET-gcc'; export RUSTFLAGS" >>/root/dynenv; \
        fi
    
    # Build
    ARG chain="gdev"
    RUN set -x && \
        cat /root/dynenv && \
        . /root/dynenv && \
        cargo build --locked $CARGO_OPTIONS --no-default-features $BENCH_OPTIONS --features $chain --target "$RUST_ARCH_TRIPLET" && \
        cargo build --locked $CARGO_OPTIONS --target "$RUST_ARCH_TRIPLET" --package distance-oracle && \
        mkdir -p build && \
        mv target/$RUST_ARCH_TRIPLET/$TARGET_FOLDER/duniter build/ && \
        mv target/$RUST_ARCH_TRIPLET/$TARGET_FOLDER/distance-oracle build/
    
    # Run tests if requested, expted when cross-building
    ARG cucumber=0
    RUN if [ "$cucumber" != 0 ] && [ "$TARGETPLATFORM" = "$BUILDPLATFORM" ]; then \
            cargo ta && \
            cargo test --workspace --exclude duniter-end2end-tests --exclude duniter-live-tests --features runtime-benchmarks \
            cd target/debug/deps/ && \
            rm cucumber_tests-*.d && \
            mv cucumber_tests* ../../../build/duniter-cucumber; \
        fi
    
    # Run runtime benchmarks
    RUN if [ "$benchmarks" != 0 ]; then \
          build/duniter benchmark pallet --chain dev --execution=wasm --wasm-execution=compiled --pallet "*" --extrinsic "*" --steps 2 --repeat 1; \
        fi
    
    # ------------------------------------------------------------------------------
    # Final Stage
    # ------------------------------------------------------------------------------
    
    FROM target
    
    LABEL maintainer="Gilles Filippini <gilles.filippini@pini.fr>"
    LABEL version="0.0.0"
    LABEL description="Crypto-currency software (based on Substrate framework) to operate Ğ1 libre currency"
    
    RUN adduser --home /var/lib/duniter duniter
    
    # Configuration
    # rpc, rpc-ws, p2p, telemetry
    EXPOSE 9933 9944 30333 9615
    VOLUME /var/lib/duniter
    ENTRYPOINT ["docker-entrypoint"]
    USER duniter
    
    # Intall
    COPY --from=build /root/build /usr/local/bin/
    COPY docker/docker-entrypoint /usr/local/bin/